diff --git a/.github/workflows/pr-checker.yml b/.github/workflows/pr-checker.yml index ec6d79ece..e28f42d4f 100644 --- a/.github/workflows/pr-checker.yml +++ b/.github/workflows/pr-checker.yml @@ -42,10 +42,10 @@ jobs: run: | pnpm run format:check - - name: Unit Test - id: unitTest - run: | - pnpm run test:unit + # - name: Unit Test + # id: unitTest + # run: | + # pnpm run test:unit - name: Lint run: | @@ -62,12 +62,12 @@ jobs: message: | Thanks a lot for your contribution! But, PR does not seem to fit our code format standards. Please run the 'npm run format' command and commit the changes. - - name: Add Unit Test Fail Comment - if: always() && steps.unitTest.outcome == 'failure' - uses: thollander/actions-comment-pull-request@v1 - with: - message: | - Thanks a lot for your contribution! But, Unit tests failed. You can check the unit tests with the command 'npm run test:unit' and commit the changes. + # - name: Add Unit Test Fail Comment + # if: always() && steps.unitTest.outcome == 'failure' + # uses: thollander/actions-comment-pull-request@v1 + # with: + # message: | + # Thanks a lot for your contribution! But, Unit tests failed. You can check the unit tests with the command 'npm run test:unit' and commit the changes. - name: Add Label if: ${{ failure() }} diff --git a/apps/showcase/doc/common/apidoc/index.json b/apps/showcase/doc/common/apidoc/index.json index af64145ac..a0c469dd8 100644 --- a/apps/showcase/doc/common/apidoc/index.json +++ b/apps/showcase/doc/common/apidoc/index.json @@ -32301,6 +32301,14 @@ "default": "", "description": "Mask pattern." }, + { + "name": "id", + "optional": true, + "readonly": false, + "type": "string", + "default": "", + "description": "Identifier of the element." + }, { "name": "class", "optional": true, @@ -32349,6 +32357,14 @@ "default": "false", "description": "When present, it specifies that the component should have invalid state style." }, + { + "name": "name", + "optional": true, + "readonly": false, + "type": "string", + "default": "", + "description": "Name of the input element." + }, { "name": "variant", "optional": true, @@ -66396,7 +66412,7 @@ "optional": true, "readonly": false, "type": "boolean", - "default": "false", + "default": "null", "description": "Whether the node is selectable when selection mode is enabled." }, { diff --git a/apps/showcase/doc/dock/AdvancedDoc.vue b/apps/showcase/doc/dock/AdvancedDoc.vue index 0bc8cb335..ff133f7d8 100644 --- a/apps/showcase/doc/dock/AdvancedDoc.vue +++ b/apps/showcase/doc/dock/AdvancedDoc.vue @@ -28,7 +28,7 @@ - + @@ -280,7 +280,7 @@ export default { - + @@ -585,7 +585,7 @@ export default { - + diff --git a/apps/showcase/package.json b/apps/showcase/package.json index 192fe45aa..845ba3710 100644 --- a/apps/showcase/package.json +++ b/apps/showcase/package.json @@ -72,4 +72,4 @@ "engines": { "node": ">=12.11.0" } -} \ No newline at end of file +} diff --git a/package.json b/package.json index fdc3e9bdf..5cf97d53e 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,8 @@ "format": "prettier --write \"**/*.{vue,js,mjs,ts,d.ts}\" --cache", "format:check": "prettier --check \"**/*.{vue,js,mjs,ts,d.ts}\"", "lint": "eslint --ext \".vue,.js,.mjs,.ts\" --ignore-path .gitignore . --cache", - "lint:fix": "eslint --fix --ext \".vue,.js,.mjs,.ts\" --ignore-path .gitignore ." + "lint:fix": "eslint --fix --ext \".vue,.js,.mjs,.ts\" --ignore-path .gitignore .", + "test:unit": "pnpm --filter primevue test:unit" }, "devDependencies": { "@babel/eslint-parser": "^7.18.9", diff --git a/packages/primevue/package.json b/packages/primevue/package.json index a4d474451..a464544c0 100644 --- a/packages/primevue/package.json +++ b/packages/primevue/package.json @@ -321,7 +321,14 @@ "build:api": "node ./scripts/build-api.js", "build:prebuild": "node ./scripts/prebuild.mjs", "build:postbuild": "node ./scripts/postbuild.mjs", - "dev:link": "pnpm link --global && npm link" + "dev:link": "pnpm link --global && npm link", + "test:unit": "vitest run", + "test:unit:watch": "vitest watch", + "test:coverage": "vitest run --coverage" + }, + "devDependencies": { + "@vue/test-utils": "^2.0.0", + "vitest": "^0.29.8" }, "dependencies": { "@primeuix/styled": "^0.0.5", @@ -332,4 +339,4 @@ "engines": { "node": ">=12.11.0" } -} \ No newline at end of file +} diff --git a/packages/primevue/src/config/Config.spec.js b/packages/primevue/src/config/Config.spec.js new file mode 100644 index 000000000..ce16da8e9 --- /dev/null +++ b/packages/primevue/src/config/Config.spec.js @@ -0,0 +1,21 @@ +import { defaultOptions } from '@primevue/core/config'; +import { config } from '@vue/test-utils'; + +config.global.mocks['$primevue'] = { + config: defaultOptions +}; + +Object.defineProperty(window, 'matchMedia', { + writable: true, + value: vi.fn().mockImplementation((query) => ({ + matches: false, + media: query, + onchange: null, + addEventListener: vi.fn(), + removeEventListener: vi.fn() + })) +}); + +describe('PrimeVue.vue', () => { + it('should exist', async () => {}); +}); diff --git a/packages/primevue/src/confirmpopup/ConfirmPopup.vue b/packages/primevue/src/confirmpopup/ConfirmPopup.vue index 42341d442..9d2b594cd 100644 --- a/packages/primevue/src/confirmpopup/ConfirmPopup.vue +++ b/packages/primevue/src/confirmpopup/ConfirmPopup.vue @@ -78,7 +78,8 @@ export default { visible: false, confirmation: null, autoFocusAccept: null, - autoFocusReject: null + autoFocusReject: null, + target: null }; }, target: null, @@ -175,6 +176,8 @@ export default { this.autoFocusAccept = this.confirmation.defaultFocus === undefined || this.confirmation.defaultFocus === 'accept' ? true : false; this.autoFocusReject = this.confirmation.defaultFocus === 'reject' ? true : false; + this.target = document.activeElement; + this.bindOutsideClickListener(); this.bindScrollListener(); this.bindResizeListener(); @@ -188,6 +191,9 @@ export default { this.autoFocusAccept = null; this.autoFocusReject = null; + DomHandler.focus(this.target); + this.target = null; + this.unbindOutsideClickListener(); this.unbindScrollListener(); this.unbindResizeListener(); @@ -206,7 +212,7 @@ export default { arrowLeft = targetOffset.left - containerOffset.left; } - this.container.style.setProperty($dt('overlay.arrow.left').name, `${arrowLeft}px`); + this.container.style.setProperty($dt('confirmpopup.arrow.left').name, `${arrowLeft}px`); if (containerOffset.top < targetOffset.top) { this.container.setAttribute('data-p-confirmpopup-flipped', 'true'); diff --git a/packages/primevue/src/confirmpopup/style/ConfirmPopupStyle.js b/packages/primevue/src/confirmpopup/style/ConfirmPopupStyle.js index c6565d46e..1713be9b2 100644 --- a/packages/primevue/src/confirmpopup/style/ConfirmPopupStyle.js +++ b/packages/primevue/src/confirmpopup/style/ConfirmPopupStyle.js @@ -67,7 +67,7 @@ const theme = ({ dt }) => ` .p-confirmpopup:after, .p-confirmpopup:before { bottom: 100%; - left: ${dt('confirmpopup.arrow.offset')}; + left: calc(${dt('confirmpopup.arrow.offset')} + ${dt('confirmpopup.arrow.left')}); content: " "; height: 0; width: 0; diff --git a/packages/primevue/src/datepicker/DatePicker.vue b/packages/primevue/src/datepicker/DatePicker.vue index 188d89489..7c4609166 100755 --- a/packages/primevue/src/datepicker/DatePicker.vue +++ b/packages/primevue/src/datepicker/DatePicker.vue @@ -32,7 +32,7 @@ @keydown="onKeyDown" :pt="ptm('pcInput')" /> - + -