diff --git a/cypress/support/index.ts b/cypress/support/index.ts index 0df0d3c591..1976b6db94 100644 --- a/cypress/support/index.ts +++ b/cypress/support/index.ts @@ -3,7 +3,6 @@ import { mount } from 'cypress/vue' import { createMemoryHistory, createRouter } from 'vue-router/dist/vue-router.prod.cjs' import type { RouteRecordRaw } from 'vue-router' import type { App, ComputedOptions } from 'vue' -import { BindOncePlugin } from 'vue-bind-once' import Chainable = Cypress.Chainable import 'cypress-fail-fast' // Import Kongponent styles @@ -38,7 +37,7 @@ Cypress.Commands.add('mount', (component: ComputedOptions, options = {}): Chaina app.use(options.router) } }, - }, BindOncePlugin) + }) return mount(component, options) }) diff --git a/docs/guide/contributing.md b/docs/guide/contributing.md index 8639dca174..9107bdcf54 100644 --- a/docs/guide/contributing.md +++ b/docs/guide/contributing.md @@ -218,23 +218,35 @@ It's essential to choose context-aware and descriptive names. This practice ensu #### Attributes -Sometimes you will need to generate a random string to be used as value for various attributes (e.g. accessibility-related attributes like `id`, `for`, `aria-labelledby`, etc.). +Sometimes you will need to generate a random string to be used as value for various attributes (e.g. accessibility-related attributes like `id`, `for`, `aria-labelledby`, etc.). -To generate a unique id so that it is safe for SSR, you **must** use the `useUniqueId` composable in your component: +To generate a unique id so that it is safe for SSR, you **must** use the [`useId` composable](https://vuejs.org/api/composition-api-helpers#useid) in your component: ```html ``` -Then you must use the [`v-bind-once` directive](https://github.com/danielroe/vue-bind-once) to bind the unique id to element attributes (this prevents hydration issues in SSR apps): +Note that `useId` can only be used at the root of the setup function. If you need a random ID in a template or in any of your component functions (e.g. to give each `key` in a `v-for` loop a unique value), you should use the `getUniqueStringId` helper function: -```html - - +```vue + + + ``` ## Testing your component diff --git a/docs/guide/usage.md b/docs/guide/usage.md index c1c32b7705..c265f0e4b3 100644 --- a/docs/guide/usage.md +++ b/docs/guide/usage.md @@ -68,9 +68,6 @@ Import and registration can be done individually in the app entry file (e.g. `ma ```ts // main.ts (or Vue entry file) -// Kongponents rely on vue-bind-once directive to work properly -// The Kongponents bundle includes the vue-bind-once package so you won't need to install it separately, but it does need to be registered -import { BindOncePlugin } from 'vue-bind-once' import { createApp } from 'vue' import { KButton } from '@kong/kongponents' import '@kong/kongponents/dist/style.css' @@ -79,9 +76,6 @@ import '@kong/kongponents/dist/style.css' const app = createApp(App) -// Register the vue-bind-once directive as a Vue Plugin -app.use(BindOncePlugin) - // Register an individual Kongponent app.component('KButton', KButton) @@ -115,8 +109,6 @@ this path instead: import '~@kong/kongponents/dist/style.css' */ ``` -When using Kongponents individually like this you will still need to register [`vue-bind-once` plugin](https://github.com/danielroe/vue-bind-once). Please refer to [global registration](#global-registration) section for example. - ## TypeScript interfaces :::tip NOTE diff --git a/package.json b/package.json index 94a55c1373..0c3dab0085 100644 --- a/package.json +++ b/package.json @@ -60,16 +60,15 @@ "date-fns-tz": "^2.0.1", "focus-trap": "^7.6.0", "focus-trap-vue": "^4.0.3", - "nanoid": "^5.0.7", + "nanoid": "^5.0.9", "sortablejs": "^1.15.3", "swrv": "^1.0.4", "v-calendar": "^3.1.2", - "vue-bind-once": "^0.2.1", "vue-draggable-next": "^2.2.1" }, "peerDependencies": { "axios": "^1.7.7", - "vue": ">= 3.3.4 < 4", + "vue": ">= 3.5.0 < 4", "vue-router": "^4.4.5" }, "devDependencies": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4bb750ae0a..719240cc1e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -33,8 +33,8 @@ importers: specifier: ^4.0.3 version: 4.0.3(focus-trap@7.6.0)(vue@3.5.12(typescript@5.6.3)) nanoid: - specifier: ^5.0.7 - version: 5.0.7 + specifier: ^5.0.9 + version: 5.0.9 sortablejs: specifier: ^1.15.3 version: 1.15.3 @@ -44,9 +44,6 @@ importers: v-calendar: specifier: ^3.1.2 version: 3.1.2(@popperjs/core@2.11.8)(vue@3.5.12(typescript@5.6.3)) - vue-bind-once: - specifier: ^0.2.1 - version: 0.2.1(vue@3.5.12(typescript@5.6.3)) vue-draggable-next: specifier: ^2.2.1 version: 2.2.1(sortablejs@1.15.3)(vue@3.5.12(typescript@5.6.3)) @@ -824,7 +821,6 @@ packages: '@evilmartians/lefthook@1.8.2': resolution: {integrity: sha512-SZdQk3W9q7tcJwnSwEMUubQqVIK7SHxv52hEAnV7o3nPI+xKcmd+rN0hZIJg07wjBaJRAjzdvoQySKQQYPW5Qw==} - cpu: [x64, arm64, ia32] os: [darwin, linux, win32] hasBin: true @@ -3427,8 +3423,8 @@ packages: engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} hasBin: true - nanoid@5.0.7: - resolution: {integrity: sha512-oLxFY2gd2IqnjcYyOXD8XGCftpGtZP2AbHbOkthDkvRywH5ayNtPVy9YlOPcHckXzbLTCHpkb7FB+yuxKV13pQ==} + nanoid@5.0.9: + resolution: {integrity: sha512-Aooyr6MXU6HpvvWXKoVoXwKMs/KyVakWwg7xQfv5/S/RIgJMy0Ifa45H9qqYy7pTCszrHzP21Uk4PZq2HpEM8Q==} engines: {node: ^18 || >=20} hasBin: true @@ -4205,9 +4201,6 @@ packages: engines: {node: '>=14.0.0'} hasBin: true - scule@1.3.0: - resolution: {integrity: sha512-6FtHJEvt+pVMIB9IBY+IcCJ6Z5f1iQnytgyfKMhDKgmzYG+TeH/wx1y3l27rshSbLiSanrR9ffZDrEsmjlQF2g==} - search-insights@2.14.0: resolution: {integrity: sha512-OLN6MsPMCghDOqlCtsIsYgtsC0pnwVTyT9Mu6A3ewOj1DxvzZF6COrn2g86E/c05xbktB0XN04m/t1Z+n+fTGw==} @@ -4821,11 +4814,6 @@ packages: vscode-uri@3.0.8: resolution: {integrity: sha512-AyFQ0EVmsOZOlAnxoFOGOq1SQDWAB7C6aqMGS23svWAllfOaxbuFvcT8D1i8z3Gyn8fraVeZNNmN6e9bxxXkKw==} - vue-bind-once@0.2.1: - resolution: {integrity: sha512-17toDsxK7hc8folglp6TYtybi/Q0FVJal6plFeMeofWd2nOl4axHg9ckR/5ORNCj+GyjMAWh/OD10MvT6AXbHA==} - peerDependencies: - vue: ^3 - vue-demi@0.14.10: resolution: {integrity: sha512-nMZBOwuzabUO0nLgIcc6rycZEebF6eeUfaiQx9+WSk8e29IbLvPU9feI6tqW4kTo3hvoYAJkMh8n8D0fuISphg==} engines: {node: '>=12'} @@ -7644,7 +7632,7 @@ snapshots: execa@8.0.1: dependencies: - cross-spawn: 7.0.6 + cross-spawn: 7.0.3 get-stream: 8.0.1 human-signals: 5.0.0 is-stream: 3.0.0 @@ -7657,7 +7645,7 @@ snapshots: execa@9.2.0: dependencies: '@sindresorhus/merge-streams': 4.0.0 - cross-spawn: 7.0.6 + cross-spawn: 7.0.3 figures: 6.1.0 get-stream: 9.0.1 human-signals: 7.0.0 @@ -8651,7 +8639,7 @@ snapshots: nanoid@3.3.7: {} - nanoid@5.0.7: {} + nanoid@5.0.9: {} nanospinner@1.1.0: dependencies: @@ -9298,8 +9286,6 @@ snapshots: optionalDependencies: '@parcel/watcher': 2.4.1 - scule@1.3.0: {} - search-insights@2.14.0: {} semantic-release@24.2.0(typescript@5.6.3): @@ -10024,11 +10010,6 @@ snapshots: vscode-uri@3.0.8: {} - vue-bind-once@0.2.1(vue@3.5.12(typescript@5.6.3)): - dependencies: - scule: 1.3.0 - vue: 3.5.12(typescript@5.6.3) - vue-demi@0.14.10(vue@3.5.12(typescript@5.6.3)): dependencies: vue: 3.5.12(typescript@5.6.3) diff --git a/src/components/KCatalog/KCatalog.vue b/src/components/KCatalog/KCatalog.vue index 7ce5d90f93..12a83a3dbc 100644 --- a/src/components/KCatalog/KCatalog.vue +++ b/src/components/KCatalog/KCatalog.vue @@ -86,9 +86,9 @@
import type { PropType } from 'vue' -import { ref, computed, onMounted, watch, useSlots } from 'vue' +import { ref, computed, onMounted, watch, useSlots, useId } from 'vue' import type { CatalogItem, CatalogPreferences, @@ -177,7 +177,6 @@ import KEmptyState from '@/components/KEmptyState/KEmptyState.vue' import KButton from '@/components/KButton/KButton.vue' import KPagination from '@/components/KPagination/KPagination.vue' import KCatalogItem from './KCatalogItem.vue' -import useUniqueId from '@/composables/useUniqueId' const { useRequest, useDebounce, useSwrvState } = useUtilities() const DEFAULT_PAGE_SIZE = 15 @@ -372,7 +371,7 @@ const emit = defineEmits<{ const slots = useSlots() -const catalogId = useUniqueId() +const catalogId = useId() const getInitialPageSize = (): number => { const initialPageSize = props.paginationPageSizes?.[0] diff --git a/src/components/KCheckbox/KCheckbox.vue b/src/components/KCheckbox/KCheckbox.vue index 5dea546904..2d21c8fe9f 100644 --- a/src/components/KCheckbox/KCheckbox.vue +++ b/src/components/KCheckbox/KCheckbox.vue @@ -8,7 +8,7 @@ :class="{ 'has-label': hasLabel }" > {{ label }} @@ -63,12 +63,11 @@