@vellira-ui/core 2.95.2 → 2.97.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,6 @@
1
1
  export * from './focus/index.js';
2
2
  export * from './overlay/index.js';
3
3
  export * from './portal/index.js';
4
+ export * from './select/index.js';
4
5
  export * from './utils/index.js';
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/behavior/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/behavior/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC"}
@@ -1,4 +1,5 @@
1
1
  export * from './focus/index.js';
2
2
  export * from './overlay/index.js';
3
3
  export * from './portal/index.js';
4
+ export * from './select/index.js';
4
5
  export * from './utils/index.js';
@@ -0,0 +1,13 @@
1
+ export type ResolveSelectGroupSelectionParams = {
2
+ selectedValues: readonly string[];
3
+ groupValues: readonly string[];
4
+ enabledValues: ReadonlySet<string>;
5
+ maxSelected?: number;
6
+ };
7
+ export type ResolveSelectGroupSelectionResult = {
8
+ selectedValues: string[];
9
+ clearedGroup: boolean;
10
+ addedValue?: string;
11
+ };
12
+ export declare function resolveSelectGroupSelection({ selectedValues, groupValues, enabledValues, maxSelected, }: ResolveSelectGroupSelectionParams): ResolveSelectGroupSelectionResult;
13
+ //# sourceMappingURL=groupSelection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"groupSelection.d.ts","sourceRoot":"","sources":["../../../src/behavior/select/groupSelection.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,iCAAiC,GAAG;IAC9C,cAAc,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/B,aAAa,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACnC,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,iCAAiC,GAAG;IAC9C,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,YAAY,EAAE,OAAO,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,wBAAgB,2BAA2B,CAAC,EAC1C,cAAc,EACd,WAAW,EACX,aAAa,EACb,WAAW,GACZ,EAAE,iCAAiC,GAAG,iCAAiC,CA4DvE"}
@@ -0,0 +1,38 @@
1
+ export function resolveSelectGroupSelection({ selectedValues, groupValues, enabledValues, maxSelected, }) {
2
+ const selectableGroupValues = groupValues.filter((value) => enabledValues.has(value));
3
+ if (selectableGroupValues.length === 0) {
4
+ return {
5
+ selectedValues: [...selectedValues],
6
+ clearedGroup: false,
7
+ };
8
+ }
9
+ const selectedGroupValues = selectableGroupValues.filter((value) => selectedValues.includes(value));
10
+ const outsideSelectedCount = selectedValues.filter((value) => !selectableGroupValues.includes(value)).length;
11
+ const maxSelectableGroupCount = typeof maxSelected === 'number'
12
+ ? Math.max(0, Math.min(selectableGroupValues.length, maxSelected - outsideSelectedCount))
13
+ : selectableGroupValues.length;
14
+ const shouldClearGroup = selectedGroupValues.length > 0 &&
15
+ selectedGroupValues.length >= maxSelectableGroupCount;
16
+ if (shouldClearGroup) {
17
+ return {
18
+ selectedValues: selectedValues.filter((value) => !selectableGroupValues.includes(value)),
19
+ clearedGroup: true,
20
+ };
21
+ }
22
+ const nextValues = [...selectedValues];
23
+ let addedValue;
24
+ for (const value of selectableGroupValues) {
25
+ if (nextValues.includes(value))
26
+ continue;
27
+ if (typeof maxSelected === 'number' && nextValues.length >= maxSelected) {
28
+ break;
29
+ }
30
+ nextValues.push(value);
31
+ addedValue = value;
32
+ }
33
+ return {
34
+ selectedValues: nextValues,
35
+ clearedGroup: false,
36
+ addedValue,
37
+ };
38
+ }
@@ -0,0 +1,3 @@
1
+ export type { ResolveSelectGroupSelectionParams, ResolveSelectGroupSelectionResult, } from './groupSelection.js';
2
+ export { resolveSelectGroupSelection } from './groupSelection.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/behavior/select/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,iCAAiC,EACjC,iCAAiC,GAClC,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1 @@
1
+ export { resolveSelectGroupSelection } from './groupSelection.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vellira-ui/core",
3
- "version": "2.95.2",
3
+ "version": "2.97.0",
4
4
  "description": "Shared logic and hooks for Vellira Design System",
5
5
  "keywords": [
6
6
  "vellira",