Skip to content

Commit d4c6dbf

Browse files
committed
Merge branch 'master' of https://github.com/primefaces/primevue
2 parents e427f85 + d406c26 commit d4c6dbf

File tree

58 files changed

+598
-745
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+598
-745
lines changed

apps/showcase/components/layout/designer/editor/DesignTokenField.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
</template>
4848

4949
<script>
50-
import { UniqueComponentId } from '@primevue/core/utils';
50+
import { uuid } from '@primeuix/utils';
5151
import { $dt } from '@primevue/themes';
5252
5353
export default {
@@ -85,7 +85,7 @@ export default {
8585
};
8686
},
8787
created() {
88-
this.id = 'dt_field_' + UniqueComponentId();
88+
this.id = uuid('dt_field_');
8989
},
9090
methods: {
9191
onOptionSelect(event) {

apps/showcase/doc/common/apidoc/index.json

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13463,7 +13463,7 @@
1346313463
"optional": true,
1346413464
"readonly": false,
1346513465
"type": "boolean",
13466-
"default": "true",
13466+
"default": "false",
1346713467
"description": "Displays a button to clear the column filtering."
1346813468
},
1346913469
{
@@ -23073,14 +23073,6 @@
2307323073
"default": "body",
2307423074
"description": "A valid query selector or an HTMLElement to specify where the overlay gets attached."
2307523075
},
23076-
{
23077-
"name": "id",
23078-
"optional": true,
23079-
"readonly": false,
23080-
"type": "string",
23081-
"default": "",
23082-
"description": "Identifier of the element."
23083-
},
2308423076
{
2308523077
"name": "inputId",
2308623078
"optional": true,

apps/showcase/rollup.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ function addPackageJson() {
273273
"*.vue"
274274
],
275275
"peerDependencies": {
276-
"vue": "^3.0.0"
276+
"vue": "^3.5.0"
277277
},
278278
"engines": {
279279
"node": ">=12.11.0"

packages/core/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"types": "./src/index.d.ts",
1919
"exports": {
2020
"./api": "./src/api/Api.js",
21+
"./useid": "./src/useid/UseId.js",
2122
"./base/style": "./src/base/style/BaseStyle.js",
2223
"./base": "./src/base/Base.js",
2324
"./basecomponent/style": "./src/basecomponent/style/BaseComponentStyle.js",
@@ -27,6 +28,7 @@
2728
"./baseinput": "./src/baseinput/BaseInput.vue",
2829
"./config": "./src/config/PrimeVue.js",
2930
"./service": "./src/service/PrimeVueService.js",
31+
"./useattrselector": "./src/useattrselector/UseAttrSelector.js",
3032
"./usestyle": "./src/usestyle/UseStyle.js",
3133
"./utils": "./src/utils/Utils.js"
3234
},
@@ -62,9 +64,9 @@
6264
"@primeuix/utils": "catalog:"
6365
},
6466
"peerDependencies": {
65-
"vue": "^3.3.0"
67+
"vue": "^3.5.0"
6668
},
6769
"engines": {
6870
"node": ">=12.11.0"
6971
}
70-
}
72+
}

packages/core/src/basecomponent/BaseComponent.vue

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<script>
22
import { Theme, ThemeService } from '@primeuix/styled';
3-
import { findSingle, isClient } from '@primeuix/utils/dom';
3+
import { findSingle, isElement } from '@primeuix/utils/dom';
44
import { getKeyValue, isArray, isFunction, isNotEmpty, isString, resolve, toFlatCase } from '@primeuix/utils/object';
5-
import { uuid } from '@primeuix/utils/uuid';
65
import Base from '@primevue/core/base';
76
import BaseStyle from '@primevue/core/base/style';
7+
import { useAttrSelector } from '@primevue/core/useattrselector';
88
import { mergeProps } from 'vue';
99
import BaseComponentStyle from './style/BaseComponentStyle';
1010
@@ -62,6 +62,7 @@ export default {
6262
},
6363
scopedStyleEl: undefined,
6464
rootEl: undefined,
65+
uid: undefined,
6566
$attrSelector: undefined,
6667
beforeCreate() {
6768
const _usept = this.pt?.['_usept'];
@@ -75,17 +76,18 @@ export default {
7576
const valueInConfig = _useptInConfig ? this.$primevue?.config?.pt?.value : this.$primevue?.config?.pt;
7677
7778
(valueInConfig || originalValueInConfig)?.[this.$.type.name]?.hooks?.['onBeforeCreate']?.();
78-
this.$attrSelector = uuid('pc');
79+
80+
this.$attrSelector = useAttrSelector();
81+
this.uid = this.$attrs.id || this.$attrSelector.replace('pc', 'pv_id_');
7982
},
8083
created() {
8184
this._hook('onCreated');
8285
},
8386
beforeMount() {
84-
// @todo - improve performance
85-
this.rootEl = findSingle(this.$el, `[data-pc-name="${toFlatCase(this.$.type.name)}"]`);
87+
// @deprecated - remove in v5
88+
this.rootEl = findSingle(isElement(this.$el) ? this.$el : this.$el?.parentElement, `[${this.$attrSelector}]`);
8689
8790
if (this.rootEl) {
88-
this.$attrSelector && !this.rootEl.hasAttribute(this.$attrSelector) && this.rootEl.setAttribute(this.$attrSelector, '');
8991
this.rootEl.$pc = { name: this.$.type.name, attrSelector: this.$attrSelector, ...this.$params };
9092
}
9193
@@ -245,7 +247,7 @@ export default {
245247
...(key === 'root' && {
246248
[`${datasetPrefix}name`]: toFlatCase(isExtended ? this.pt?.['data-pc-section'] : this.$.type.name),
247249
...(isExtended && { [`${datasetPrefix}extend`]: toFlatCase(this.$.type.name) }),
248-
...(isClient() && { [`${this.$attrSelector}`]: '' })
250+
[`${this.$attrSelector}`]: ''
249251
}),
250252
[`${datasetPrefix}section`]: toFlatCase(key)
251253
}
@@ -301,7 +303,11 @@ export default {
301303
},
302304
ptmi(key = '', params = {}) {
303305
// inheritAttrs:true
304-
return mergeProps(this.$_attrsWithoutPT, this.ptm(key, params));
306+
const attrs = mergeProps(this.$_attrsWithoutPT, this.ptm(key, params));
307+
308+
attrs?.hasOwnProperty('id') && (attrs.id ??= this.$id);
309+
310+
return attrs;
305311
},
306312
ptmo(obj = {}, key = '', params = {}) {
307313
return this._getPTValue(obj, key, { instance: this, ...params }, false);
@@ -330,6 +336,9 @@ export default {
330336
isUnstyled() {
331337
return this.unstyled !== undefined ? this.unstyled : this.$primevueConfig?.unstyled;
332338
},
339+
$id() {
340+
return this.$attrs.id || this.uid;
341+
},
333342
$inProps() {
334343
const nodePropKeys = Object.keys(this.$.vnode?.props || {});
335344

packages/core/src/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,7 @@ export * from '@primevue/core/baseinput';
5252
export * from '@primevue/core/config';
5353
export { default as PrimeVue } from '@primevue/core/config';
5454
export * from '@primevue/core/service';
55+
export * from '@primevue/core/useattrselector';
56+
export * from '@primevue/core/useid';
5557
export * from '@primevue/core/usestyle';
5658
export * from '@primevue/core/utils';

packages/core/src/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ export { default as PrimeVue } from '@primevue/core/config';
2525
// PrimeVueService
2626
export { default as PrimeVueService } from '@primevue/core/service';
2727

28+
// UseAttrSelector
29+
export * from '@primevue/core/useattrselector';
30+
31+
// UseId
32+
export * from '@primevue/core/useid';
33+
2834
// UseStyle
2935
export * from '@primevue/core/usestyle';
3036

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export declare function useAttrSelector(prefix?: string): string;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { useId } from 'vue';
2+
3+
export function useAttrSelector(prefix = 'pc') {
4+
const idx = useId();
5+
6+
return `${prefix}${idx.replace('v-', '').replaceAll('-', '_')}`;
7+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"main": "./UseAttrSelector.js",
3+
"module": "./UseAttrSelector.js",
4+
"types": "./UseAttrSelector.d.ts"
5+
}

0 commit comments

Comments
 (0)