@bccampus/ui-components 0.5.0 → 0.5.2
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.
- package/.yarn/install-state.gz +0 -0
- package/.yarn/releases/yarn-4.10.3.cjs +942 -0
- package/.yarnrc.yml +3 -0
- package/dist/_chunks/createLucideIcon.js +0 -24
- package/dist/_chunks/index.js +16 -38
- package/dist/_chunks/index3.js +26 -520
- package/dist/_chunks/index4.js +615 -0
- package/dist/_chunks/utils.js +199 -143
- package/dist/components/index.js +2 -2
- package/dist/components/ui/banner.js +0 -6
- package/dist/components/ui/composite/CompositeData.js +1 -1
- package/dist/components/ui/composite/CompositeDataItem.js +109 -3
- package/dist/components/ui/composite/FocusProvider/AbstractFocusProvider.js +2 -1
- package/dist/components/ui/composite/SelectionProvider/AbstractSelectionProvider.js +2 -1
- package/dist/components/ui/composite/SelectionProvider/MultipleSelectionProvider.js +1 -1
- package/dist/components/ui/composite/SelectionProvider/SingleSelectionProvider.js +1 -1
- package/dist/components/ui/composite/composite-component-item.js +2 -24
- package/dist/components/ui/composite/index.d.ts +1 -0
- package/dist/components/ui/composite/index.js +2 -2
- package/dist/components/ui/composite/listbox.js +1 -0
- package/dist/components/ui/horizontal-list.js +0 -12
- package/dist/components/ui/navigation-menu.js +86 -10
- package/dist/components/ui/popover.js +85 -3
- package/dist/components/ui/search-input.js +0 -6
- package/package.json +75 -67
- package/src/App.tsx +44 -14
- package/src/components/ui/composite/index.ts +2 -1
- package/src/components/ui/page-header.tsx +6 -9
- package/src/main.tsx +12 -12
- package/vite.config.ts +6 -2
- package/dist/_chunks/CompositeDataItem.js +0 -204
package/dist/_chunks/utils.js
CHANGED
|
@@ -11,7 +11,28 @@ function clsx() {
|
|
|
11
11
|
for (var e, t, f = 0, n = "", o = arguments.length; f < o; f++) (e = arguments[f]) && (t = r(e)) && (n && (n += " "), n += t);
|
|
12
12
|
return n;
|
|
13
13
|
}
|
|
14
|
+
const concatArrays = (array1, array2) => {
|
|
15
|
+
const combinedArray = new Array(array1.length + array2.length);
|
|
16
|
+
for (let i = 0; i < array1.length; i++) {
|
|
17
|
+
combinedArray[i] = array1[i];
|
|
18
|
+
}
|
|
19
|
+
for (let i = 0; i < array2.length; i++) {
|
|
20
|
+
combinedArray[array1.length + i] = array2[i];
|
|
21
|
+
}
|
|
22
|
+
return combinedArray;
|
|
23
|
+
};
|
|
24
|
+
const createClassValidatorObject = (classGroupId, validator) => ({
|
|
25
|
+
classGroupId,
|
|
26
|
+
validator
|
|
27
|
+
});
|
|
28
|
+
const createClassPartObject = (nextPart = /* @__PURE__ */ new Map(), validators = null, classGroupId) => ({
|
|
29
|
+
nextPart,
|
|
30
|
+
validators,
|
|
31
|
+
classGroupId
|
|
32
|
+
});
|
|
14
33
|
const CLASS_PART_SEPARATOR = "-";
|
|
34
|
+
const EMPTY_CONFLICTS = [];
|
|
35
|
+
const ARBITRARY_PROPERTY_PREFIX = "arbitrary..";
|
|
15
36
|
const createClassGroupUtils = (config) => {
|
|
16
37
|
const classMap = createClassMap(config);
|
|
17
38
|
const {
|
|
@@ -19,103 +40,134 @@ const createClassGroupUtils = (config) => {
|
|
|
19
40
|
conflictingClassGroupModifiers
|
|
20
41
|
} = config;
|
|
21
42
|
const getClassGroupId = (className) => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
classParts.shift();
|
|
43
|
+
if (className.startsWith("[") && className.endsWith("]")) {
|
|
44
|
+
return getGroupIdForArbitraryProperty(className);
|
|
25
45
|
}
|
|
26
|
-
|
|
46
|
+
const classParts = className.split(CLASS_PART_SEPARATOR);
|
|
47
|
+
const startIndex = classParts[0] === "" && classParts.length > 1 ? 1 : 0;
|
|
48
|
+
return getGroupRecursive(classParts, startIndex, classMap);
|
|
27
49
|
};
|
|
28
50
|
const getConflictingClassGroupIds = (classGroupId, hasPostfixModifier) => {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
51
|
+
if (hasPostfixModifier) {
|
|
52
|
+
const modifierConflicts = conflictingClassGroupModifiers[classGroupId];
|
|
53
|
+
const baseConflicts = conflictingClassGroups[classGroupId];
|
|
54
|
+
if (modifierConflicts) {
|
|
55
|
+
if (baseConflicts) {
|
|
56
|
+
return concatArrays(baseConflicts, modifierConflicts);
|
|
57
|
+
}
|
|
58
|
+
return modifierConflicts;
|
|
59
|
+
}
|
|
60
|
+
return baseConflicts || EMPTY_CONFLICTS;
|
|
32
61
|
}
|
|
33
|
-
return
|
|
62
|
+
return conflictingClassGroups[classGroupId] || EMPTY_CONFLICTS;
|
|
34
63
|
};
|
|
35
64
|
return {
|
|
36
65
|
getClassGroupId,
|
|
37
66
|
getConflictingClassGroupIds
|
|
38
67
|
};
|
|
39
68
|
};
|
|
40
|
-
const getGroupRecursive = (classParts, classPartObject) => {
|
|
41
|
-
|
|
69
|
+
const getGroupRecursive = (classParts, startIndex, classPartObject) => {
|
|
70
|
+
const classPathsLength = classParts.length - startIndex;
|
|
71
|
+
if (classPathsLength === 0) {
|
|
42
72
|
return classPartObject.classGroupId;
|
|
43
73
|
}
|
|
44
|
-
const currentClassPart = classParts[
|
|
74
|
+
const currentClassPart = classParts[startIndex];
|
|
45
75
|
const nextClassPartObject = classPartObject.nextPart.get(currentClassPart);
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
return
|
|
76
|
+
if (nextClassPartObject) {
|
|
77
|
+
const result = getGroupRecursive(classParts, startIndex + 1, nextClassPartObject);
|
|
78
|
+
if (result) return result;
|
|
49
79
|
}
|
|
50
|
-
|
|
80
|
+
const validators = classPartObject.validators;
|
|
81
|
+
if (validators === null) {
|
|
51
82
|
return void 0;
|
|
52
83
|
}
|
|
53
|
-
const classRest = classParts.join(CLASS_PART_SEPARATOR);
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const getGroupIdForArbitraryProperty = (className) => {
|
|
60
|
-
if (arbitraryPropertyRegex.test(className)) {
|
|
61
|
-
const arbitraryPropertyClassName = arbitraryPropertyRegex.exec(className)[1];
|
|
62
|
-
const property = arbitraryPropertyClassName?.substring(0, arbitraryPropertyClassName.indexOf(":"));
|
|
63
|
-
if (property) {
|
|
64
|
-
return "arbitrary.." + property;
|
|
84
|
+
const classRest = startIndex === 0 ? classParts.join(CLASS_PART_SEPARATOR) : classParts.slice(startIndex).join(CLASS_PART_SEPARATOR);
|
|
85
|
+
const validatorsLength = validators.length;
|
|
86
|
+
for (let i = 0; i < validatorsLength; i++) {
|
|
87
|
+
const validatorObj = validators[i];
|
|
88
|
+
if (validatorObj.validator(classRest)) {
|
|
89
|
+
return validatorObj.classGroupId;
|
|
65
90
|
}
|
|
66
91
|
}
|
|
92
|
+
return void 0;
|
|
67
93
|
};
|
|
94
|
+
const getGroupIdForArbitraryProperty = (className) => className.slice(1, -1).indexOf(":") === -1 ? void 0 : (() => {
|
|
95
|
+
const content = className.slice(1, -1);
|
|
96
|
+
const colonIndex = content.indexOf(":");
|
|
97
|
+
const property = content.slice(0, colonIndex);
|
|
98
|
+
return property ? ARBITRARY_PROPERTY_PREFIX + property : void 0;
|
|
99
|
+
})();
|
|
68
100
|
const createClassMap = (config) => {
|
|
69
101
|
const {
|
|
70
102
|
theme,
|
|
71
103
|
classGroups
|
|
72
104
|
} = config;
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
105
|
+
return processClassGroups(classGroups, theme);
|
|
106
|
+
};
|
|
107
|
+
const processClassGroups = (classGroups, theme) => {
|
|
108
|
+
const classMap = createClassPartObject();
|
|
77
109
|
for (const classGroupId in classGroups) {
|
|
78
|
-
|
|
110
|
+
const group = classGroups[classGroupId];
|
|
111
|
+
processClassesRecursively(group, classMap, classGroupId, theme);
|
|
79
112
|
}
|
|
80
113
|
return classMap;
|
|
81
114
|
};
|
|
82
115
|
const processClassesRecursively = (classGroup, classPartObject, classGroupId, theme) => {
|
|
83
|
-
classGroup.
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
116
|
+
const len = classGroup.length;
|
|
117
|
+
for (let i = 0; i < len; i++) {
|
|
118
|
+
const classDefinition = classGroup[i];
|
|
119
|
+
processClassDefinition(classDefinition, classPartObject, classGroupId, theme);
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
const processClassDefinition = (classDefinition, classPartObject, classGroupId, theme) => {
|
|
123
|
+
if (typeof classDefinition === "string") {
|
|
124
|
+
processStringDefinition(classDefinition, classPartObject, classGroupId);
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
if (typeof classDefinition === "function") {
|
|
128
|
+
processFunctionDefinition(classDefinition, classPartObject, classGroupId, theme);
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
processObjectDefinition(classDefinition, classPartObject, classGroupId, theme);
|
|
132
|
+
};
|
|
133
|
+
const processStringDefinition = (classDefinition, classPartObject, classGroupId) => {
|
|
134
|
+
const classPartObjectToEdit = classDefinition === "" ? classPartObject : getPart(classPartObject, classDefinition);
|
|
135
|
+
classPartObjectToEdit.classGroupId = classGroupId;
|
|
136
|
+
};
|
|
137
|
+
const processFunctionDefinition = (classDefinition, classPartObject, classGroupId, theme) => {
|
|
138
|
+
if (isThemeGetter(classDefinition)) {
|
|
139
|
+
processClassesRecursively(classDefinition(theme), classPartObject, classGroupId, theme);
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
if (classPartObject.validators === null) {
|
|
143
|
+
classPartObject.validators = [];
|
|
144
|
+
}
|
|
145
|
+
classPartObject.validators.push(createClassValidatorObject(classGroupId, classDefinition));
|
|
146
|
+
};
|
|
147
|
+
const processObjectDefinition = (classDefinition, classPartObject, classGroupId, theme) => {
|
|
148
|
+
const entries = Object.entries(classDefinition);
|
|
149
|
+
const len = entries.length;
|
|
150
|
+
for (let i = 0; i < len; i++) {
|
|
151
|
+
const [key, value] = entries[i];
|
|
152
|
+
processClassesRecursively(value, getPart(classPartObject, key), classGroupId, theme);
|
|
153
|
+
}
|
|
104
154
|
};
|
|
105
155
|
const getPart = (classPartObject, path) => {
|
|
106
|
-
let
|
|
107
|
-
path.split(CLASS_PART_SEPARATOR)
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
156
|
+
let current = classPartObject;
|
|
157
|
+
const parts = path.split(CLASS_PART_SEPARATOR);
|
|
158
|
+
const len = parts.length;
|
|
159
|
+
for (let i = 0; i < len; i++) {
|
|
160
|
+
const part = parts[i];
|
|
161
|
+
let next = current.nextPart.get(part);
|
|
162
|
+
if (!next) {
|
|
163
|
+
next = createClassPartObject();
|
|
164
|
+
current.nextPart.set(part, next);
|
|
113
165
|
}
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
return
|
|
166
|
+
current = next;
|
|
167
|
+
}
|
|
168
|
+
return current;
|
|
117
169
|
};
|
|
118
|
-
const isThemeGetter = (func) => func.isThemeGetter;
|
|
170
|
+
const isThemeGetter = (func) => "isThemeGetter" in func && func.isThemeGetter === true;
|
|
119
171
|
const createLruCache = (maxCacheSize) => {
|
|
120
172
|
if (maxCacheSize < 1) {
|
|
121
173
|
return {
|
|
@@ -125,31 +177,31 @@ const createLruCache = (maxCacheSize) => {
|
|
|
125
177
|
};
|
|
126
178
|
}
|
|
127
179
|
let cacheSize = 0;
|
|
128
|
-
let cache = /* @__PURE__ */
|
|
129
|
-
let previousCache = /* @__PURE__ */
|
|
180
|
+
let cache = /* @__PURE__ */ Object.create(null);
|
|
181
|
+
let previousCache = /* @__PURE__ */ Object.create(null);
|
|
130
182
|
const update = (key, value) => {
|
|
131
|
-
cache
|
|
183
|
+
cache[key] = value;
|
|
132
184
|
cacheSize++;
|
|
133
185
|
if (cacheSize > maxCacheSize) {
|
|
134
186
|
cacheSize = 0;
|
|
135
187
|
previousCache = cache;
|
|
136
|
-
cache = /* @__PURE__ */
|
|
188
|
+
cache = /* @__PURE__ */ Object.create(null);
|
|
137
189
|
}
|
|
138
190
|
};
|
|
139
191
|
return {
|
|
140
192
|
get(key) {
|
|
141
|
-
let value = cache
|
|
193
|
+
let value = cache[key];
|
|
142
194
|
if (value !== void 0) {
|
|
143
195
|
return value;
|
|
144
196
|
}
|
|
145
|
-
if ((value = previousCache
|
|
197
|
+
if ((value = previousCache[key]) !== void 0) {
|
|
146
198
|
update(key, value);
|
|
147
199
|
return value;
|
|
148
200
|
}
|
|
149
201
|
},
|
|
150
202
|
set(key, value) {
|
|
151
|
-
if (cache
|
|
152
|
-
cache
|
|
203
|
+
if (key in cache) {
|
|
204
|
+
cache[key] = value;
|
|
153
205
|
} else {
|
|
154
206
|
update(key, value);
|
|
155
207
|
}
|
|
@@ -158,7 +210,14 @@ const createLruCache = (maxCacheSize) => {
|
|
|
158
210
|
};
|
|
159
211
|
const IMPORTANT_MODIFIER = "!";
|
|
160
212
|
const MODIFIER_SEPARATOR = ":";
|
|
161
|
-
const
|
|
213
|
+
const EMPTY_MODIFIERS = [];
|
|
214
|
+
const createResultObject = (modifiers, hasImportantModifier, baseClassName, maybePostfixModifierPosition, isExternal) => ({
|
|
215
|
+
modifiers,
|
|
216
|
+
hasImportantModifier,
|
|
217
|
+
baseClassName,
|
|
218
|
+
maybePostfixModifierPosition,
|
|
219
|
+
isExternal
|
|
220
|
+
});
|
|
162
221
|
const createParseClassName = (config) => {
|
|
163
222
|
const {
|
|
164
223
|
prefix,
|
|
@@ -170,12 +229,13 @@ const createParseClassName = (config) => {
|
|
|
170
229
|
let parenDepth = 0;
|
|
171
230
|
let modifierStart = 0;
|
|
172
231
|
let postfixModifierPosition;
|
|
173
|
-
|
|
174
|
-
|
|
232
|
+
const len = className.length;
|
|
233
|
+
for (let index = 0; index < len; index++) {
|
|
234
|
+
const currentCharacter = className[index];
|
|
175
235
|
if (bracketDepth === 0 && parenDepth === 0) {
|
|
176
236
|
if (currentCharacter === MODIFIER_SEPARATOR) {
|
|
177
237
|
modifiers.push(className.slice(modifierStart, index));
|
|
178
|
-
modifierStart = index +
|
|
238
|
+
modifierStart = index + 1;
|
|
179
239
|
continue;
|
|
180
240
|
}
|
|
181
241
|
if (currentCharacter === "/") {
|
|
@@ -183,37 +243,34 @@ const createParseClassName = (config) => {
|
|
|
183
243
|
continue;
|
|
184
244
|
}
|
|
185
245
|
}
|
|
186
|
-
if (currentCharacter === "[")
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
246
|
+
if (currentCharacter === "[") bracketDepth++;
|
|
247
|
+
else if (currentCharacter === "]") bracketDepth--;
|
|
248
|
+
else if (currentCharacter === "(") parenDepth++;
|
|
249
|
+
else if (currentCharacter === ")") parenDepth--;
|
|
250
|
+
}
|
|
251
|
+
const baseClassNameWithImportantModifier = modifiers.length === 0 ? className : className.slice(modifierStart);
|
|
252
|
+
let baseClassName = baseClassNameWithImportantModifier;
|
|
253
|
+
let hasImportantModifier = false;
|
|
254
|
+
if (baseClassNameWithImportantModifier.endsWith(IMPORTANT_MODIFIER)) {
|
|
255
|
+
baseClassName = baseClassNameWithImportantModifier.slice(0, -1);
|
|
256
|
+
hasImportantModifier = true;
|
|
257
|
+
} else if (
|
|
258
|
+
/**
|
|
259
|
+
* In Tailwind CSS v3 the important modifier was at the start of the base class name. This is still supported for legacy reasons.
|
|
260
|
+
* @see https://github.com/dcastil/tailwind-merge/issues/513#issuecomment-2614029864
|
|
261
|
+
*/
|
|
262
|
+
baseClassNameWithImportantModifier.startsWith(IMPORTANT_MODIFIER)
|
|
263
|
+
) {
|
|
264
|
+
baseClassName = baseClassNameWithImportantModifier.slice(1);
|
|
265
|
+
hasImportantModifier = true;
|
|
195
266
|
}
|
|
196
|
-
const baseClassNameWithImportantModifier = modifiers.length === 0 ? className : className.substring(modifierStart);
|
|
197
|
-
const baseClassName = stripImportantModifier(baseClassNameWithImportantModifier);
|
|
198
|
-
const hasImportantModifier = baseClassName !== baseClassNameWithImportantModifier;
|
|
199
267
|
const maybePostfixModifierPosition = postfixModifierPosition && postfixModifierPosition > modifierStart ? postfixModifierPosition - modifierStart : void 0;
|
|
200
|
-
return
|
|
201
|
-
modifiers,
|
|
202
|
-
hasImportantModifier,
|
|
203
|
-
baseClassName,
|
|
204
|
-
maybePostfixModifierPosition
|
|
205
|
-
};
|
|
268
|
+
return createResultObject(modifiers, hasImportantModifier, baseClassName, maybePostfixModifierPosition);
|
|
206
269
|
};
|
|
207
270
|
if (prefix) {
|
|
208
271
|
const fullPrefix = prefix + MODIFIER_SEPARATOR;
|
|
209
272
|
const parseClassNameOriginal = parseClassName;
|
|
210
|
-
parseClassName = (className) => className.startsWith(fullPrefix) ? parseClassNameOriginal(className.
|
|
211
|
-
isExternal: true,
|
|
212
|
-
modifiers: [],
|
|
213
|
-
hasImportantModifier: false,
|
|
214
|
-
baseClassName: className,
|
|
215
|
-
maybePostfixModifierPosition: void 0
|
|
216
|
-
};
|
|
273
|
+
parseClassName = (className) => className.startsWith(fullPrefix) ? parseClassNameOriginal(className.slice(fullPrefix.length)) : createResultObject(EMPTY_MODIFIERS, false, className, void 0, true);
|
|
217
274
|
}
|
|
218
275
|
if (experimentalParseClassName) {
|
|
219
276
|
const parseClassNameOriginal = parseClassName;
|
|
@@ -224,36 +281,35 @@ const createParseClassName = (config) => {
|
|
|
224
281
|
}
|
|
225
282
|
return parseClassName;
|
|
226
283
|
};
|
|
227
|
-
const stripImportantModifier = (baseClassName) => {
|
|
228
|
-
if (baseClassName.endsWith(IMPORTANT_MODIFIER)) {
|
|
229
|
-
return baseClassName.substring(0, baseClassName.length - 1);
|
|
230
|
-
}
|
|
231
|
-
if (baseClassName.startsWith(IMPORTANT_MODIFIER)) {
|
|
232
|
-
return baseClassName.substring(1);
|
|
233
|
-
}
|
|
234
|
-
return baseClassName;
|
|
235
|
-
};
|
|
236
284
|
const createSortModifiers = (config) => {
|
|
237
|
-
const
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
const
|
|
243
|
-
let
|
|
244
|
-
modifiers.
|
|
245
|
-
const
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
285
|
+
const modifierWeights = /* @__PURE__ */ new Map();
|
|
286
|
+
config.orderSensitiveModifiers.forEach((mod, index) => {
|
|
287
|
+
modifierWeights.set(mod, 1e6 + index);
|
|
288
|
+
});
|
|
289
|
+
return (modifiers) => {
|
|
290
|
+
const result = [];
|
|
291
|
+
let currentSegment = [];
|
|
292
|
+
for (let i = 0; i < modifiers.length; i++) {
|
|
293
|
+
const modifier = modifiers[i];
|
|
294
|
+
const isArbitrary = modifier[0] === "[";
|
|
295
|
+
const isOrderSensitive = modifierWeights.has(modifier);
|
|
296
|
+
if (isArbitrary || isOrderSensitive) {
|
|
297
|
+
if (currentSegment.length > 0) {
|
|
298
|
+
currentSegment.sort();
|
|
299
|
+
result.push(...currentSegment);
|
|
300
|
+
currentSegment = [];
|
|
301
|
+
}
|
|
302
|
+
result.push(modifier);
|
|
249
303
|
} else {
|
|
250
|
-
|
|
304
|
+
currentSegment.push(modifier);
|
|
251
305
|
}
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
|
|
306
|
+
}
|
|
307
|
+
if (currentSegment.length > 0) {
|
|
308
|
+
currentSegment.sort();
|
|
309
|
+
result.push(...currentSegment);
|
|
310
|
+
}
|
|
311
|
+
return result;
|
|
255
312
|
};
|
|
256
|
-
return sortModifiers;
|
|
257
313
|
};
|
|
258
314
|
const createConfigUtils = (config) => ({
|
|
259
315
|
cache: createLruCache(config.cacheSize),
|
|
@@ -299,10 +355,10 @@ const mergeClassList = (classList, configUtils) => {
|
|
|
299
355
|
}
|
|
300
356
|
hasPostfixModifier = false;
|
|
301
357
|
}
|
|
302
|
-
const variantModifier = sortModifiers(modifiers).join(":");
|
|
358
|
+
const variantModifier = modifiers.length === 0 ? "" : modifiers.length === 1 ? modifiers[0] : sortModifiers(modifiers).join(":");
|
|
303
359
|
const modifierId = hasImportantModifier ? variantModifier + IMPORTANT_MODIFIER : variantModifier;
|
|
304
360
|
const classId = modifierId + classGroupId;
|
|
305
|
-
if (classGroupsInConflict.
|
|
361
|
+
if (classGroupsInConflict.indexOf(classId) > -1) {
|
|
306
362
|
continue;
|
|
307
363
|
}
|
|
308
364
|
classGroupsInConflict.push(classId);
|
|
@@ -315,13 +371,13 @@ const mergeClassList = (classList, configUtils) => {
|
|
|
315
371
|
}
|
|
316
372
|
return result;
|
|
317
373
|
};
|
|
318
|
-
|
|
374
|
+
const twJoin = (...classLists) => {
|
|
319
375
|
let index = 0;
|
|
320
376
|
let argument;
|
|
321
377
|
let resolvedValue;
|
|
322
378
|
let string = "";
|
|
323
|
-
while (index <
|
|
324
|
-
if (argument =
|
|
379
|
+
while (index < classLists.length) {
|
|
380
|
+
if (argument = classLists[index++]) {
|
|
325
381
|
if (resolvedValue = toValue(argument)) {
|
|
326
382
|
string && (string += " ");
|
|
327
383
|
string += resolvedValue;
|
|
@@ -329,7 +385,7 @@ function twJoin() {
|
|
|
329
385
|
}
|
|
330
386
|
}
|
|
331
387
|
return string;
|
|
332
|
-
}
|
|
388
|
+
};
|
|
333
389
|
const toValue = (mix) => {
|
|
334
390
|
if (typeof mix === "string") {
|
|
335
391
|
return mix;
|
|
@@ -346,20 +402,20 @@ const toValue = (mix) => {
|
|
|
346
402
|
}
|
|
347
403
|
return string;
|
|
348
404
|
};
|
|
349
|
-
|
|
405
|
+
const createTailwindMerge = (createConfigFirst, ...createConfigRest) => {
|
|
350
406
|
let configUtils;
|
|
351
407
|
let cacheGet;
|
|
352
408
|
let cacheSet;
|
|
353
|
-
let functionToCall
|
|
354
|
-
|
|
409
|
+
let functionToCall;
|
|
410
|
+
const initTailwindMerge = (classList) => {
|
|
355
411
|
const config = createConfigRest.reduce((previousConfig, createConfigCurrent) => createConfigCurrent(previousConfig), createConfigFirst());
|
|
356
412
|
configUtils = createConfigUtils(config);
|
|
357
413
|
cacheGet = configUtils.cache.get;
|
|
358
414
|
cacheSet = configUtils.cache.set;
|
|
359
415
|
functionToCall = tailwindMerge;
|
|
360
416
|
return tailwindMerge(classList);
|
|
361
|
-
}
|
|
362
|
-
|
|
417
|
+
};
|
|
418
|
+
const tailwindMerge = (classList) => {
|
|
363
419
|
const cachedResult = cacheGet(classList);
|
|
364
420
|
if (cachedResult) {
|
|
365
421
|
return cachedResult;
|
|
@@ -367,13 +423,13 @@ function createTailwindMerge(createConfigFirst, ...createConfigRest) {
|
|
|
367
423
|
const result = mergeClassList(classList, configUtils);
|
|
368
424
|
cacheSet(classList, result);
|
|
369
425
|
return result;
|
|
370
|
-
}
|
|
371
|
-
return function callTailwindMerge() {
|
|
372
|
-
return functionToCall(twJoin.apply(null, arguments));
|
|
373
426
|
};
|
|
374
|
-
|
|
427
|
+
functionToCall = initTailwindMerge;
|
|
428
|
+
return (...args) => functionToCall(twJoin(...args));
|
|
429
|
+
};
|
|
430
|
+
const fallbackThemeArr = [];
|
|
375
431
|
const fromTheme = (key) => {
|
|
376
|
-
const themeGetter = (theme) => theme[key] ||
|
|
432
|
+
const themeGetter = (theme) => theme[key] || fallbackThemeArr;
|
|
377
433
|
themeGetter.isThemeGetter = true;
|
|
378
434
|
return themeGetter;
|
|
379
435
|
};
|
package/dist/components/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CompositeData } from "./ui/composite/CompositeData.js";
|
|
2
|
-
import {
|
|
2
|
+
import { CompositeDataItem } from "./ui/composite/CompositeDataItem.js";
|
|
3
3
|
import { AbstractFocusProvider } from "./ui/composite/FocusProvider/AbstractFocusProvider.js";
|
|
4
4
|
import { ListboxFocusProvider } from "./ui/composite/FocusProvider/ListboxFocusProvider.js";
|
|
5
5
|
import { AbstractSelectionProvider } from "./ui/composite/SelectionProvider/AbstractSelectionProvider.js";
|
|
@@ -47,7 +47,7 @@ export {
|
|
|
47
47
|
CompositeComponent,
|
|
48
48
|
CompositeComponentItem,
|
|
49
49
|
CompositeData,
|
|
50
|
-
|
|
50
|
+
CompositeDataItem,
|
|
51
51
|
HorizontalList,
|
|
52
52
|
IconGenerator,
|
|
53
53
|
Input,
|
|
@@ -4,12 +4,6 @@ import { c as cn } from "../../_chunks/utils.js";
|
|
|
4
4
|
import { useState } from "react";
|
|
5
5
|
import { Button } from "./button.js";
|
|
6
6
|
import { c as createLucideIcon } from "../../_chunks/createLucideIcon.js";
|
|
7
|
-
/**
|
|
8
|
-
* @license lucide-react v0.544.0 - ISC
|
|
9
|
-
*
|
|
10
|
-
* This source code is licensed under the ISC license.
|
|
11
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
12
|
-
*/
|
|
13
7
|
const __iconNode = [
|
|
14
8
|
["path", { d: "M18 6 6 18", key: "1bl5f8" }],
|
|
15
9
|
["path", { d: "m6 6 12 12", key: "d8bk6v" }]
|
|
@@ -1,5 +1,111 @@
|
|
|
1
|
-
import "../../../lib/object.js";
|
|
2
|
-
import {
|
|
1
|
+
import { omit } from "../../../lib/object.js";
|
|
2
|
+
import { map } from "nanostores";
|
|
3
|
+
class CompositeDataItem {
|
|
4
|
+
#key;
|
|
5
|
+
parent = null;
|
|
6
|
+
children;
|
|
7
|
+
level;
|
|
8
|
+
data;
|
|
9
|
+
state;
|
|
10
|
+
pointers;
|
|
11
|
+
childrenProp;
|
|
12
|
+
constructor(item, options, parent) {
|
|
13
|
+
this.#key = options.getItemKey(item);
|
|
14
|
+
this.data = map(omit(item, [options.itemChildrenProp]));
|
|
15
|
+
this.state = map({
|
|
16
|
+
focused: false,
|
|
17
|
+
selected: false,
|
|
18
|
+
disabled: false,
|
|
19
|
+
...options.initialState
|
|
20
|
+
});
|
|
21
|
+
this.pointers = {};
|
|
22
|
+
this.parent = parent;
|
|
23
|
+
this.level = parent ? parent.level + 1 : 0;
|
|
24
|
+
this.childrenProp = options.itemChildrenProp;
|
|
25
|
+
const children = options.getItemChildren(item);
|
|
26
|
+
if (children) {
|
|
27
|
+
this.children = children.map((child) => {
|
|
28
|
+
const childItem = new CompositeDataItem(child, options, this);
|
|
29
|
+
return childItem;
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
get key() {
|
|
34
|
+
return this.#key;
|
|
35
|
+
}
|
|
36
|
+
*[Symbol.iterator]() {
|
|
37
|
+
if (this.key !== "ALL") yield this;
|
|
38
|
+
if (this.children)
|
|
39
|
+
for (const child of this.children)
|
|
40
|
+
for (const item of child) yield item;
|
|
41
|
+
}
|
|
42
|
+
toJSON() {
|
|
43
|
+
const json = { ...this.data.get() };
|
|
44
|
+
if (this.children) {
|
|
45
|
+
json[this.childrenProp] = [];
|
|
46
|
+
for (const child of this.children)
|
|
47
|
+
json[this.childrenProp].push(child.toJSON());
|
|
48
|
+
}
|
|
49
|
+
return json;
|
|
50
|
+
}
|
|
51
|
+
descendants() {
|
|
52
|
+
if (!this.children) return [];
|
|
53
|
+
const descendants = [];
|
|
54
|
+
this.children.forEach(
|
|
55
|
+
(child) => {
|
|
56
|
+
descendants.push(child);
|
|
57
|
+
const childDescendants = child.descendants();
|
|
58
|
+
if (childDescendants) descendants.push(...childDescendants);
|
|
59
|
+
}
|
|
60
|
+
);
|
|
61
|
+
return descendants;
|
|
62
|
+
}
|
|
63
|
+
ancestors() {
|
|
64
|
+
const ancestors = [];
|
|
65
|
+
let parent = this.parent;
|
|
66
|
+
while (parent) {
|
|
67
|
+
ancestors.push(parent);
|
|
68
|
+
parent = parent.parent;
|
|
69
|
+
}
|
|
70
|
+
return ancestors;
|
|
71
|
+
}
|
|
72
|
+
toggleSelect(recursive = false) {
|
|
73
|
+
if (this.state.get().selected) this.deselect(recursive);
|
|
74
|
+
else this.select(recursive);
|
|
75
|
+
}
|
|
76
|
+
select(recursive = false) {
|
|
77
|
+
this.state.setKey("selected", true);
|
|
78
|
+
if (recursive && this.children) {
|
|
79
|
+
const selectedChildKeys = this.children.map((child) => child.select(true)).flat();
|
|
80
|
+
return [this.key, ...selectedChildKeys];
|
|
81
|
+
}
|
|
82
|
+
return [this.key];
|
|
83
|
+
}
|
|
84
|
+
deselect(recursive = false) {
|
|
85
|
+
this.state.setKey("selected", false);
|
|
86
|
+
if (recursive && this.children) {
|
|
87
|
+
const deselectedChildKeys = this.children.map((child) => child.deselect(true)).flat();
|
|
88
|
+
return [this.key, ...deselectedChildKeys];
|
|
89
|
+
}
|
|
90
|
+
return [this.key];
|
|
91
|
+
}
|
|
92
|
+
disable(recursive = false) {
|
|
93
|
+
this.state.setKey("disabled", true);
|
|
94
|
+
if (recursive && this.children) {
|
|
95
|
+
const disabledChildKeys = this.children.map((child) => child.disable(true)).flat();
|
|
96
|
+
return [this.key, ...disabledChildKeys];
|
|
97
|
+
}
|
|
98
|
+
return [this.key];
|
|
99
|
+
}
|
|
100
|
+
enable(recursive = false) {
|
|
101
|
+
this.state.setKey("disabled", false);
|
|
102
|
+
if (recursive && this.children) {
|
|
103
|
+
const enabledChildKeys = this.children.map((child) => child.enable(true)).flat();
|
|
104
|
+
return [this.key, ...enabledChildKeys];
|
|
105
|
+
}
|
|
106
|
+
return [this.key];
|
|
107
|
+
}
|
|
108
|
+
}
|
|
3
109
|
export {
|
|
4
|
-
|
|
110
|
+
CompositeDataItem
|
|
5
111
|
};
|