@povio/ui 2.3.2 → 3.0.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.
- package/dist/assets/locales/sl/translation.json.js +2 -2
- package/dist/components/Breadcrumbs/Breadcrumbs.js +11 -11
- package/dist/components/Breadcrumbs/breadcrumbs.cva.d.ts +40 -14
- package/dist/components/Breadcrumbs/breadcrumbs.cva.js +21 -18
- package/dist/components/Menu/MenuItem.js +4 -4
- package/dist/components/Menu/MenuMobile.js +6 -6
- package/dist/components/Menu/MenuPopover.js +8 -8
- package/dist/components/Menu/menu.cva.d.ts +35 -13
- package/dist/components/Menu/menu.cva.js +30 -24
- package/dist/components/buttons/Button/Button.js +7 -7
- package/dist/components/buttons/Button/button.cva.d.ts +95 -26
- package/dist/components/buttons/Button/button.cva.js +601 -589
- package/dist/components/buttons/PillButton/PillButton.js +4 -4
- package/dist/components/buttons/PillButton/pillButton.cva.d.ts +33 -9
- package/dist/components/buttons/PillButton/pillButton.cva.js +247 -239
- package/dist/components/buttons/shared/ButtonContent.js +3 -3
- package/dist/components/buttons/shared/buttonContent.cva.d.ts +3 -5
- package/dist/components/buttons/shared/buttonContent.cva.js +1 -8
- package/dist/components/inputs/Checkbox/Checkbox.js +2 -2
- package/dist/components/inputs/Checkbox/CheckboxCheckmark.js +4 -4
- package/dist/components/inputs/Checkbox/checkbox.cva.d.ts +23 -10
- package/dist/components/inputs/Checkbox/checkbox.cva.js +46 -40
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.js +150 -68
- package/dist/components/inputs/DateTime/shared/DatePickerInput.js +4 -4
- package/dist/components/inputs/DateTime/shared/DateTimeDialog.js +3 -3
- package/dist/components/inputs/DateTime/shared/TimePickerInput.js +4 -4
- package/dist/components/inputs/File/shared/InputUploadContent.js +3 -3
- package/dist/components/inputs/File/shared/InputUploadFilled.js +3 -3
- package/dist/components/inputs/File/shared/fileUpload.cva.d.ts +26 -9
- package/dist/components/inputs/File/shared/fileUpload.cva.js +48 -40
- package/dist/components/inputs/File/shared/inputUploadButton.cva.d.ts +23 -6
- package/dist/components/inputs/File/shared/inputUploadButton.cva.js +29 -20
- package/dist/components/inputs/FormField/FormFieldError.js +3 -3
- package/dist/components/inputs/FormField/FormFieldHelper.js +3 -3
- package/dist/components/inputs/FormField/FormFieldLabel.js +6 -6
- package/dist/components/inputs/FormField/formFieldError.cva.d.ts +12 -5
- package/dist/components/inputs/FormField/formFieldError.cva.js +11 -8
- package/dist/components/inputs/FormField/formFieldHelper.cva.d.ts +12 -5
- package/dist/components/inputs/FormField/formFieldHelper.cva.js +11 -8
- package/dist/components/inputs/Input/NumberInput/NumberInput.js +3 -3
- package/dist/components/inputs/Input/TextArea/TextArea.js +4 -4
- package/dist/components/inputs/Input/TextInput/TextInput.js +3 -3
- package/dist/components/inputs/Input/shared/InputContent.js +5 -5
- package/dist/components/inputs/RadioGroup/RadioGroup.js +4 -4
- package/dist/components/inputs/RadioGroup/radio.cva.d.ts +12 -6
- package/dist/components/inputs/RadioGroup/radio.cva.js +27 -24
- package/dist/components/inputs/Selection/shared/SelectDesktop.js +3 -3
- package/dist/components/inputs/Selection/shared/SelectInput.js +4 -4
- package/dist/components/inputs/Selection/shared/SelectListBoxItem.js +3 -3
- package/dist/components/inputs/Selection/shared/SelectListBoxItemSelectAll.js +3 -3
- package/dist/components/inputs/Selection/shared/SelectListBoxLoadingItem.js +3 -3
- package/dist/components/inputs/Selection/shared/selectItem.cva.d.ts +16 -6
- package/dist/components/inputs/Selection/shared/selectItem.cva.js +21 -18
- package/dist/components/inputs/TextEditor/TextEditor.js +3 -3
- package/dist/components/inputs/TextEditor/Toolbar/ColorPickerDropdown.js +3 -3
- package/dist/components/inputs/Toggle/Toggle.js +4 -4
- package/dist/components/inputs/Toggle/toggle.cva.d.ts +12 -6
- package/dist/components/inputs/Toggle/toggle.cva.js +24 -21
- package/dist/components/inputs/shared/CheckContent.js +3 -3
- package/dist/components/inputs/shared/input.cva.d.ts +55 -16
- package/dist/components/inputs/shared/input.cva.js +279 -271
- package/dist/components/inputs/shared/label.cva.d.ts +15 -6
- package/dist/components/inputs/shared/label.cva.js +28 -25
- package/dist/components/navigation/Accordion/Accordion.js +3 -3
- package/dist/components/navigation/Accordion/AccordionItem.js +11 -11
- package/dist/components/navigation/Accordion/accordion.cva.d.ts +109 -44
- package/dist/components/navigation/Accordion/accordion.cva.js +114 -84
- package/dist/components/navigation/Stepper/Stepper.js +3 -3
- package/dist/components/navigation/Stepper/StepperItem.js +12 -12
- package/dist/components/navigation/Stepper/StepperSeparator.js +3 -3
- package/dist/components/navigation/Stepper/stepper.cva.d.ts +86 -30
- package/dist/components/navigation/Stepper/stepper.cva.js +104 -83
- package/dist/components/overlays/Modal/Modal.js +5 -5
- package/dist/components/overlays/Modal/modal.cva.d.ts +34 -9
- package/dist/components/overlays/Modal/modal.cva.js +38 -27
- package/dist/components/overlays/ResponsivePopover/ResponsivePopover.js +3 -3
- package/dist/components/overlays/Tooltip/Tooltip.js +9 -9
- package/dist/components/overlays/Tooltip/tooltip.cva.d.ts +45 -17
- package/dist/components/overlays/Tooltip/tooltip.cva.js +38 -26
- package/dist/components/segment/Segment.js +4 -4
- package/dist/components/segment/SegmentItem.js +4 -4
- package/dist/components/segment/segment.cva.d.ts +18 -7
- package/dist/components/segment/segment.cva.js +24 -21
- package/dist/components/shared/popover.cva.d.ts +7 -3
- package/dist/components/shared/popover.cva.js +3 -3
- package/dist/components/status/Alert/Alert.js +6 -6
- package/dist/components/status/Alert/alert.cva.d.ts +18 -6
- package/dist/components/status/Alert/alert.cva.js +60 -57
- package/dist/components/status/Loader/loader.cva.d.ts +23 -4
- package/dist/components/status/Loader/loader.cva.js +22 -13
- package/dist/components/status/Toast/Toast.js +6 -7
- package/dist/components/status/Toast/toast.cva.d.ts +61 -10
- package/dist/components/status/Toast/toast.cva.js +129 -64
- package/dist/components/status/shared/status.cva.d.ts +30 -8
- package/dist/components/status/shared/status.cva.js +56 -50
- package/dist/components/table/CellText.js +3 -3
- package/dist/components/table/HeaderText.js +3 -3
- package/dist/components/table/Table.js +6 -6
- package/dist/components/table/table.cva.d.ts +52 -19
- package/dist/components/table/table.cva.js +44 -35
- package/dist/components/text/Link/Link.js +3 -3
- package/dist/components/text/Link/link.cva.d.ts +11 -5
- package/dist/components/text/Link/link.cva.js +8 -5
- package/dist/components/text/Tag/Tag.js +3 -3
- package/dist/components/text/Tag/tag.cva.d.ts +15 -5
- package/dist/components/text/Tag/tag.cva.js +51 -48
- package/dist/components/text/Typography/Typography.js +3 -3
- package/dist/components/text/Typography/typography.cva.d.ts +48 -7
- package/dist/components/text/Typography/typography.cva.js +125 -122
- package/dist/config/uiOverrides.context.d.ts +174 -0
- package/dist/config/uiOverrides.context.js +73 -0
- package/dist/index.d.ts +29 -1
- package/dist/index.js +30 -2
- package/dist/utils/style-merge.util.d.ts +43 -0
- package/dist/utils/style-merge.util.js +233 -0
- package/dist/utils/style-merge.util.spec.d.ts +1 -0
- package/package.json +1 -1
- package/dist/config/uiStyle.context.d.ts +0 -162
- package/dist/config/uiStyle.context.js +0 -30
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import { clsx } from "clsx";
|
|
2
|
+
//#region src/utils/style-merge.util.ts
|
|
3
|
+
var StyleMergeUtils;
|
|
4
|
+
(function(_StyleMergeUtils) {
|
|
5
|
+
const CLASS_NAME_KEY = "className";
|
|
6
|
+
const CLASS_KEY = "class";
|
|
7
|
+
const CLASS_KEYS = new Set([CLASS_KEY, CLASS_NAME_KEY]);
|
|
8
|
+
const isClassKey = (key) => {
|
|
9
|
+
return CLASS_KEYS.has(key);
|
|
10
|
+
};
|
|
11
|
+
const getSelectorEntries = (entry) => {
|
|
12
|
+
const selectors = [];
|
|
13
|
+
for (const [key, value] of Object.entries(entry)) {
|
|
14
|
+
if (isClassKey(key)) continue;
|
|
15
|
+
selectors.push([key, value]);
|
|
16
|
+
}
|
|
17
|
+
return selectors;
|
|
18
|
+
};
|
|
19
|
+
const normalizeToArray = (value) => {
|
|
20
|
+
if (Array.isArray(value)) return value;
|
|
21
|
+
return [value];
|
|
22
|
+
};
|
|
23
|
+
const isSubsetValues = (subset, superset) => {
|
|
24
|
+
const subsetValues = normalizeToArray(subset).map((item) => String(item));
|
|
25
|
+
const supersetSet = new Set(normalizeToArray(superset).map((item) => String(item)));
|
|
26
|
+
for (const value of subsetValues) if (!supersetSet.has(value)) return false;
|
|
27
|
+
return true;
|
|
28
|
+
};
|
|
29
|
+
const canOverrideCompoundEntry = (baseEntry, overrideEntry) => {
|
|
30
|
+
const baseSelectors = getSelectorEntries(baseEntry);
|
|
31
|
+
const overrideSelectors = getSelectorEntries(overrideEntry);
|
|
32
|
+
if (baseSelectors.length !== overrideSelectors.length) return false;
|
|
33
|
+
const baseSelectorMap = new Map(baseSelectors);
|
|
34
|
+
for (const [overrideKey, overrideValue] of overrideSelectors) {
|
|
35
|
+
if (!baseSelectorMap.has(overrideKey)) return false;
|
|
36
|
+
if (!isSubsetValues(overrideValue, baseSelectorMap.get(overrideKey))) return false;
|
|
37
|
+
}
|
|
38
|
+
return true;
|
|
39
|
+
};
|
|
40
|
+
const splitCompoundEntryByOverride = (baseEntry, overrideEntry) => {
|
|
41
|
+
const baseWithoutClass = {};
|
|
42
|
+
for (const [key, value] of Object.entries(baseEntry)) {
|
|
43
|
+
if (isClassKey(key)) continue;
|
|
44
|
+
baseWithoutClass[key] = value;
|
|
45
|
+
}
|
|
46
|
+
let hasSplit = false;
|
|
47
|
+
for (const [key, overrideValue] of getSelectorEntries(overrideEntry)) {
|
|
48
|
+
const baseValue = baseWithoutClass[key];
|
|
49
|
+
if (!Array.isArray(baseValue)) continue;
|
|
50
|
+
const baseValues = [...baseValue];
|
|
51
|
+
const overrideValues = new Set(normalizeToArray(overrideValue).map((item) => String(item)));
|
|
52
|
+
const remainingValues = baseValues.filter((item) => !overrideValues.has(String(item)));
|
|
53
|
+
if (remainingValues.length === baseValues.length) continue;
|
|
54
|
+
hasSplit = true;
|
|
55
|
+
if (remainingValues.length === 1) baseWithoutClass[key] = remainingValues[0];
|
|
56
|
+
else baseWithoutClass[key] = remainingValues;
|
|
57
|
+
}
|
|
58
|
+
if (!hasSplit) return;
|
|
59
|
+
const className = getCompoundClass(baseEntry);
|
|
60
|
+
if (className) baseWithoutClass.className = className;
|
|
61
|
+
return normalizeCompoundEntry(baseWithoutClass);
|
|
62
|
+
};
|
|
63
|
+
const getCompoundClass = (entry) => {
|
|
64
|
+
const fromClassName = entry[CLASS_NAME_KEY];
|
|
65
|
+
if (fromClassName) return clsx(fromClassName);
|
|
66
|
+
const fromClass = entry[CLASS_KEY];
|
|
67
|
+
if (fromClass) return clsx(fromClass);
|
|
68
|
+
return "";
|
|
69
|
+
};
|
|
70
|
+
const normalizeCompoundEntry = (entry) => {
|
|
71
|
+
const normalized = {};
|
|
72
|
+
for (const [key, value] of Object.entries(entry)) {
|
|
73
|
+
if (key === CLASS_KEY || key === CLASS_NAME_KEY) continue;
|
|
74
|
+
normalized[key] = value;
|
|
75
|
+
}
|
|
76
|
+
const className = getCompoundClass(entry);
|
|
77
|
+
if (className) normalized.className = className;
|
|
78
|
+
return normalized;
|
|
79
|
+
};
|
|
80
|
+
const getCompoundIdentity = (entry) => {
|
|
81
|
+
const keys = Object.keys(entry).sort();
|
|
82
|
+
const identityParts = [];
|
|
83
|
+
for (const key of keys) {
|
|
84
|
+
if (isClassKey(key)) continue;
|
|
85
|
+
const value = entry[key];
|
|
86
|
+
if (Array.isArray(value)) {
|
|
87
|
+
const normalizedValues = value.map((item) => String(item)).sort();
|
|
88
|
+
identityParts.push(`${key}:[${normalizedValues.join(",")}]`);
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
identityParts.push(`${key}:${String(value)}`);
|
|
92
|
+
}
|
|
93
|
+
return identityParts.join("|");
|
|
94
|
+
};
|
|
95
|
+
const mergeClassNames = (baseClassName, overrideClassName, mode) => {
|
|
96
|
+
if (mode !== "merge") return clsx(overrideClassName);
|
|
97
|
+
return clsx(baseClassName, overrideClassName);
|
|
98
|
+
};
|
|
99
|
+
const mergeClassLists = (baseClassNames, overrideClassNames, mode) => {
|
|
100
|
+
if (mode !== "merge") return [...overrideClassNames];
|
|
101
|
+
return [...baseClassNames, ...overrideClassNames];
|
|
102
|
+
};
|
|
103
|
+
const mergeVariants = (baseVariants, overrideVariants, mode = "merge") => {
|
|
104
|
+
const merged = {};
|
|
105
|
+
if (baseVariants) for (const [variantKey, variantValues] of Object.entries(baseVariants)) merged[variantKey] = { ...variantValues };
|
|
106
|
+
if (!overrideVariants) {
|
|
107
|
+
if (!baseVariants) return;
|
|
108
|
+
return merged;
|
|
109
|
+
}
|
|
110
|
+
for (const [variantKey, overrideValues] of Object.entries(overrideVariants)) {
|
|
111
|
+
if (!overrideValues) continue;
|
|
112
|
+
if (!merged[variantKey]) merged[variantKey] = {};
|
|
113
|
+
for (const [valueKey, overrideValue] of Object.entries(overrideValues)) {
|
|
114
|
+
const baseClass = merged[variantKey][valueKey] ?? "";
|
|
115
|
+
merged[variantKey][valueKey] = mergeClassNames(baseClass, overrideValue, mode);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return merged;
|
|
119
|
+
};
|
|
120
|
+
const mergeCompoundVariants = (baseCompound, overrideCompound, mode = "merge") => {
|
|
121
|
+
if (!baseCompound) {
|
|
122
|
+
if (!overrideCompound) return;
|
|
123
|
+
return overrideCompound.map((entry) => normalizeCompoundEntry(entry));
|
|
124
|
+
}
|
|
125
|
+
const merged = baseCompound.map((entry) => normalizeCompoundEntry(entry));
|
|
126
|
+
if (!overrideCompound) return merged;
|
|
127
|
+
if (mode === "merge") {
|
|
128
|
+
for (const overrideEntry of overrideCompound) {
|
|
129
|
+
const normalizedOverride = normalizeCompoundEntry(overrideEntry);
|
|
130
|
+
const overrideIdentity = getCompoundIdentity(normalizedOverride);
|
|
131
|
+
let index = -1;
|
|
132
|
+
for (let i = 0; i < merged.length; i++) if (getCompoundIdentity(merged[i]) === overrideIdentity) {
|
|
133
|
+
index = i;
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
if (index < 0) {
|
|
137
|
+
merged.push(normalizedOverride);
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
const mergedClassName = mergeClassNames(getCompoundClass(merged[index]), getCompoundClass(normalizedOverride), "merge");
|
|
141
|
+
const nextEntry = { ...normalizedOverride };
|
|
142
|
+
nextEntry.className = mergedClassName;
|
|
143
|
+
merged[index] = nextEntry;
|
|
144
|
+
}
|
|
145
|
+
return merged;
|
|
146
|
+
}
|
|
147
|
+
for (const overrideEntry of overrideCompound) {
|
|
148
|
+
const normalizedOverride = normalizeCompoundEntry(overrideEntry);
|
|
149
|
+
const overrideIdentity = getCompoundIdentity(normalizedOverride);
|
|
150
|
+
let exactMatchIndex = -1;
|
|
151
|
+
for (let i = 0; i < merged.length; i++) {
|
|
152
|
+
const currentEntry = merged[i];
|
|
153
|
+
if (getCompoundIdentity(currentEntry) === overrideIdentity) {
|
|
154
|
+
exactMatchIndex = i;
|
|
155
|
+
break;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
if (exactMatchIndex >= 0) {
|
|
159
|
+
merged[exactMatchIndex] = normalizedOverride;
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
let candidateIndex = -1;
|
|
163
|
+
for (let i = 0; i < merged.length; i++) if (canOverrideCompoundEntry(merged[i], normalizedOverride)) {
|
|
164
|
+
candidateIndex = i;
|
|
165
|
+
break;
|
|
166
|
+
}
|
|
167
|
+
if (candidateIndex < 0) {
|
|
168
|
+
merged.push(normalizedOverride);
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
const candidate = merged[candidateIndex];
|
|
172
|
+
const splitBaseEntry = splitCompoundEntryByOverride(candidate, normalizedOverride);
|
|
173
|
+
if (splitBaseEntry) {
|
|
174
|
+
merged[candidateIndex] = splitBaseEntry;
|
|
175
|
+
merged.push(normalizedOverride);
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
merged[candidateIndex] = normalizedOverride;
|
|
179
|
+
}
|
|
180
|
+
return merged;
|
|
181
|
+
};
|
|
182
|
+
const mergeDefaultVariants = (baseDefaults, overrideDefaults) => {
|
|
183
|
+
if (!baseDefaults) {
|
|
184
|
+
if (!overrideDefaults) return;
|
|
185
|
+
return { ...overrideDefaults };
|
|
186
|
+
}
|
|
187
|
+
if (!overrideDefaults) return { ...baseDefaults };
|
|
188
|
+
return {
|
|
189
|
+
...baseDefaults,
|
|
190
|
+
...overrideDefaults
|
|
191
|
+
};
|
|
192
|
+
};
|
|
193
|
+
const hasConfigContent = (config) => {
|
|
194
|
+
if (!config) return false;
|
|
195
|
+
if (config.variants) return true;
|
|
196
|
+
if (config.compoundVariants) return true;
|
|
197
|
+
if (config.defaultVariants) return true;
|
|
198
|
+
return false;
|
|
199
|
+
};
|
|
200
|
+
_StyleMergeUtils.mergeCvaDefinition = (baseDefinition, override) => {
|
|
201
|
+
if (!override) return baseDefinition;
|
|
202
|
+
const mode = override.mode ?? "merge";
|
|
203
|
+
const overrideConfig = override.config;
|
|
204
|
+
if (mode === "overrideCva") {
|
|
205
|
+
const overrideBase = [];
|
|
206
|
+
if (override.base && Array.isArray(override.base)) {
|
|
207
|
+
for (const item of override.base) if (typeof item === "string") overrideBase.push(item);
|
|
208
|
+
}
|
|
209
|
+
let finalOverrideConfig = void 0;
|
|
210
|
+
if (hasConfigContent(overrideConfig)) finalOverrideConfig = overrideConfig;
|
|
211
|
+
return {
|
|
212
|
+
base: overrideBase,
|
|
213
|
+
config: finalOverrideConfig
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
let mergedBase = [...baseDefinition.base];
|
|
217
|
+
if (override.base && Array.isArray(override.base)) mergedBase = mergeClassLists(baseDefinition.base, override.base, mode);
|
|
218
|
+
const baseConfig = baseDefinition.config;
|
|
219
|
+
const mergedConfig = {
|
|
220
|
+
variants: mergeVariants(baseConfig?.variants, overrideConfig?.variants, mode),
|
|
221
|
+
compoundVariants: mergeCompoundVariants(baseConfig?.compoundVariants, overrideConfig?.compoundVariants, mode),
|
|
222
|
+
defaultVariants: mergeDefaultVariants(baseConfig?.defaultVariants, overrideConfig?.defaultVariants)
|
|
223
|
+
};
|
|
224
|
+
let finalConfig = void 0;
|
|
225
|
+
if (hasConfigContent(mergedConfig)) finalConfig = mergedConfig;
|
|
226
|
+
return {
|
|
227
|
+
base: mergedBase,
|
|
228
|
+
config: finalConfig
|
|
229
|
+
};
|
|
230
|
+
};
|
|
231
|
+
})(StyleMergeUtils || (StyleMergeUtils = {}));
|
|
232
|
+
//#endregion
|
|
233
|
+
export { StyleMergeUtils };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
import { ClassProp } from 'class-variance-authority/types';
|
|
2
|
-
import { PropsWithChildren } from 'react';
|
|
3
|
-
import { BreadcrumbChevronVariantProps, BreadcrumbIconVariantProps, BreadcrumbItemVariantProps, BreadcrumbSegmentVariantProps, BreadcrumbsVariantProps } from '../components/Breadcrumbs/breadcrumbs.cva';
|
|
4
|
-
import { ButtonVariantProps } from '../components/buttons/Button/button.cva';
|
|
5
|
-
import { PillButtonVariants } from '../components/buttons/PillButton/pillButton.cva';
|
|
6
|
-
import { CheckboxIconVariantProps, CheckboxVariantProps } from '../components/inputs/Checkbox/checkbox.cva';
|
|
7
|
-
import { FormFieldErrorVariantProps } from '../components/inputs/FormField/formFieldError.cva';
|
|
8
|
-
import { FormFieldHelperVariantProps } from '../components/inputs/FormField/formFieldHelper.cva';
|
|
9
|
-
import { RadioVariantProps } from '../components/inputs/RadioGroup/radio.cva';
|
|
10
|
-
import { InputBaseProps, InputSideProps, InputSizeProps } from '../components/inputs/shared/input.cva';
|
|
11
|
-
import { LabelBaseProps } from '../components/inputs/shared/label.cva';
|
|
12
|
-
import { ToggleVariantProps } from '../components/inputs/Toggle/toggle.cva';
|
|
13
|
-
import { MenuCvaVariantProps, MenuItemVariantProps, MenuPopoverVariantProps, MenuPopoverWrapperVariantProps } from '../components/Menu/menu.cva';
|
|
14
|
-
import { AccordionChevronVariantProps, AccordionHeadingSubtitleVariantProps, AccordionHeadingTitleVariantProps, AccordionHeadingVariantProps, AccordionIconVariantProps, AccordionItemVariantProps, AccordionPanelContentVariantProps, AccordionPanelVariantProps, AccordionTriggerVariantProps, AccordionVariantProps } from '../components/navigation/Accordion/accordion.cva';
|
|
15
|
-
import { StepperIconVariantProps, StepperItemVariantProps, StepperNumberVariantProps, StepperSeparatorVariantProps, StepperSubtextVariantProps, StepperTitleVariantProps, StepperVariantProps } from '../components/navigation/Stepper/stepper.cva';
|
|
16
|
-
import { ModalVariantProps } from '../components/overlays/Modal/modal.cva';
|
|
17
|
-
import { TooltipPointerHorizontalVariantProps, TooltipPointerVerticalVariantProps, TooltipTextVariantProps, TooltipVariantProps } from '../components/overlays/Tooltip/tooltip.cva';
|
|
18
|
-
import { SegmentItemVariantProps, SegmentVariantProps } from '../components/segment/segment.cva';
|
|
19
|
-
import { PopoverVariantProps } from '../components/shared/popover.cva';
|
|
20
|
-
import { AlertVariantProps } from '../components/status/Alert/alert.cva';
|
|
21
|
-
import { ToastVariantProps } from '../components/status/Toast/toast.cva';
|
|
22
|
-
import { TableCellTextVariantProps, TableDataVariantProps, TableHeadDataVariantProps, TableHeadRowVariantProps, TableHeaderTextVariantProps, TableRowVariantProps } from '../components/table/table.cva';
|
|
23
|
-
import { LinkVariantProps } from '../components/text/Link/link.cva';
|
|
24
|
-
import { TagVariantProps } from '../components/text/Tag/tag.cva';
|
|
25
|
-
import { TypographyVariantProps } from '../components/text/Typography/typography.cva';
|
|
26
|
-
import { CompoundMapper, ConfigSchema } from '../utils/compoundMapper';
|
|
27
|
-
import { SelectListBoxItemCva } from '../components/inputs/Selection/shared/selectItem.cva';
|
|
28
|
-
export declare namespace UIStyle {
|
|
29
|
-
export type Cva<T> = (props: (T & ClassProp) | ClassProp) => string;
|
|
30
|
-
type OptionKey = {
|
|
31
|
-
[K in keyof Options]: Options[K] extends object ? `${K & string}.${keyof Options[K] & string}` : never;
|
|
32
|
-
}[keyof Options];
|
|
33
|
-
interface Options {
|
|
34
|
-
button: {
|
|
35
|
-
cva?: Cva<ButtonVariantProps>;
|
|
36
|
-
sizeCva?: Cva<ButtonVariantProps>;
|
|
37
|
-
contentCva?: Cva<ButtonVariantProps>;
|
|
38
|
-
iconSize?: Cva<Pick<ButtonVariantProps, "size">>;
|
|
39
|
-
typography?: CompoundMapper<TypographyVariantProps, ButtonVariantProps>;
|
|
40
|
-
};
|
|
41
|
-
pillButton: {
|
|
42
|
-
cva?: Cva<PillButtonVariants>;
|
|
43
|
-
typography?: CompoundMapper<TypographyVariantProps, PillButtonVariants>;
|
|
44
|
-
};
|
|
45
|
-
checkbox: {
|
|
46
|
-
cva?: Cva<CheckboxVariantProps>;
|
|
47
|
-
iconCva?: Cva<CheckboxIconVariantProps>;
|
|
48
|
-
typography?: CompoundMapper<TypographyVariantProps, CheckboxVariantProps>;
|
|
49
|
-
};
|
|
50
|
-
radio: {
|
|
51
|
-
cva?: Cva<RadioVariantProps>;
|
|
52
|
-
typography?: CompoundMapper<TypographyVariantProps, RadioVariantProps>;
|
|
53
|
-
};
|
|
54
|
-
status: {
|
|
55
|
-
iconCva?: Cva<ToastVariantProps>;
|
|
56
|
-
separatorCva?: Cva<ToastVariantProps>;
|
|
57
|
-
};
|
|
58
|
-
toast: {
|
|
59
|
-
cva?: Cva<ToastVariantProps>;
|
|
60
|
-
buttonColor?: CompoundMapper<Pick<ButtonVariantProps, "color" | "inverted">, ToastVariantProps>;
|
|
61
|
-
};
|
|
62
|
-
alert: {
|
|
63
|
-
cva?: Cva<AlertVariantProps>;
|
|
64
|
-
};
|
|
65
|
-
input: {
|
|
66
|
-
baseCva?: Cva<InputBaseProps>;
|
|
67
|
-
sizeCva?: Cva<InputSizeProps>;
|
|
68
|
-
sideCva?: Cva<InputSideProps>;
|
|
69
|
-
};
|
|
70
|
-
label: {
|
|
71
|
-
cva?: Cva<LabelBaseProps>;
|
|
72
|
-
typography?: CompoundMapper<TypographyVariantProps, LabelBaseProps>;
|
|
73
|
-
};
|
|
74
|
-
toggle: {
|
|
75
|
-
cva?: Cva<ToggleVariantProps>;
|
|
76
|
-
typography?: CompoundMapper<TypographyVariantProps, ToggleVariantProps>;
|
|
77
|
-
};
|
|
78
|
-
typography: {
|
|
79
|
-
cva?: Cva<TypographyVariantProps>;
|
|
80
|
-
};
|
|
81
|
-
link: {
|
|
82
|
-
cva?: Cva<LinkVariantProps>;
|
|
83
|
-
};
|
|
84
|
-
tag: {
|
|
85
|
-
cva?: Cva<TagVariantProps>;
|
|
86
|
-
};
|
|
87
|
-
table: {
|
|
88
|
-
headRowCva?: Cva<TableHeadRowVariantProps>;
|
|
89
|
-
headDataCva?: Cva<TableHeadDataVariantProps>;
|
|
90
|
-
rowCva?: Cva<TableRowVariantProps>;
|
|
91
|
-
dataCva?: Cva<TableDataVariantProps>;
|
|
92
|
-
headerTextCva?: Cva<TableHeaderTextVariantProps>;
|
|
93
|
-
cellTextCva?: Cva<TableCellTextVariantProps>;
|
|
94
|
-
};
|
|
95
|
-
tooltip: {
|
|
96
|
-
cva?: Cva<TooltipVariantProps>;
|
|
97
|
-
pointerHorizontalCva?: Cva<TooltipPointerHorizontalVariantProps>;
|
|
98
|
-
pointerVerticalCva?: Cva<TooltipPointerVerticalVariantProps>;
|
|
99
|
-
textCva?: Cva<TooltipTextVariantProps>;
|
|
100
|
-
};
|
|
101
|
-
modal: {
|
|
102
|
-
contentCva?: Cva<ModalVariantProps>;
|
|
103
|
-
overlayCva?: Cva<ModalVariantProps>;
|
|
104
|
-
mainCva?: Cva<ModalVariantProps>;
|
|
105
|
-
};
|
|
106
|
-
menu: {
|
|
107
|
-
cva?: Cva<MenuCvaVariantProps>;
|
|
108
|
-
itemCva?: Cva<MenuItemVariantProps>;
|
|
109
|
-
popoverCva?: Cva<MenuPopoverVariantProps>;
|
|
110
|
-
popoverWrapperCva?: Cva<MenuPopoverWrapperVariantProps>;
|
|
111
|
-
};
|
|
112
|
-
segment: {
|
|
113
|
-
cva?: Cva<SegmentVariantProps>;
|
|
114
|
-
itemCva?: Cva<SegmentItemVariantProps>;
|
|
115
|
-
};
|
|
116
|
-
stepper: {
|
|
117
|
-
cva?: Cva<StepperVariantProps>;
|
|
118
|
-
itemCva?: Cva<StepperItemVariantProps>;
|
|
119
|
-
iconCva?: Cva<StepperIconVariantProps>;
|
|
120
|
-
numberCva?: Cva<StepperNumberVariantProps>;
|
|
121
|
-
titleCva?: Cva<StepperTitleVariantProps>;
|
|
122
|
-
subtextCva?: Cva<StepperSubtextVariantProps>;
|
|
123
|
-
separatorCva?: Cva<StepperSeparatorVariantProps>;
|
|
124
|
-
};
|
|
125
|
-
accordion: {
|
|
126
|
-
cva?: Cva<AccordionVariantProps>;
|
|
127
|
-
itemCva?: Cva<AccordionItemVariantProps>;
|
|
128
|
-
triggerCva?: Cva<AccordionTriggerVariantProps>;
|
|
129
|
-
headingCva?: Cva<AccordionHeadingVariantProps>;
|
|
130
|
-
headingTitleCva?: Cva<AccordionHeadingTitleVariantProps>;
|
|
131
|
-
headingSubtitleCva?: Cva<AccordionHeadingSubtitleVariantProps>;
|
|
132
|
-
chevronCva?: Cva<AccordionChevronVariantProps>;
|
|
133
|
-
iconCva?: Cva<AccordionIconVariantProps>;
|
|
134
|
-
panelCva?: Cva<AccordionPanelVariantProps>;
|
|
135
|
-
panelContentCva?: Cva<AccordionPanelContentVariantProps>;
|
|
136
|
-
};
|
|
137
|
-
breadcrumbs: {
|
|
138
|
-
cva?: Cva<BreadcrumbsVariantProps>;
|
|
139
|
-
itemCva?: Cva<BreadcrumbItemVariantProps>;
|
|
140
|
-
segmentCva?: Cva<BreadcrumbSegmentVariantProps>;
|
|
141
|
-
chevronCva?: Cva<BreadcrumbChevronVariantProps>;
|
|
142
|
-
iconCva?: Cva<BreadcrumbIconVariantProps>;
|
|
143
|
-
};
|
|
144
|
-
popover: {
|
|
145
|
-
cva?: Cva<PopoverVariantProps>;
|
|
146
|
-
};
|
|
147
|
-
formField: {
|
|
148
|
-
errorLabelCva?: Cva<FormFieldErrorVariantProps>;
|
|
149
|
-
helperLabelCva?: Cva<FormFieldHelperVariantProps>;
|
|
150
|
-
};
|
|
151
|
-
select: {
|
|
152
|
-
listBoxItemCva?: Cva<SelectListBoxItemCva>;
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
interface ProviderProps {
|
|
156
|
-
config?: Partial<Options>;
|
|
157
|
-
}
|
|
158
|
-
export const Provider: ({ children, config }: PropsWithChildren<ProviderProps>) => import("react/jsx-runtime").JSX.Element;
|
|
159
|
-
export const useCva: <T>(key: OptionKey, fallback: Cva<T>) => Cva<T>;
|
|
160
|
-
export const useMapper: <T, K extends ConfigSchema>(key: OptionKey, fallback: CompoundMapper<T, K>) => CompoundMapper<T, K>;
|
|
161
|
-
export {};
|
|
162
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { createContext, use } from "react";
|
|
3
|
-
//#region src/config/uiStyle.context.tsx
|
|
4
|
-
var UIStyle;
|
|
5
|
-
(function(_UIStyle) {
|
|
6
|
-
const Context = createContext(null);
|
|
7
|
-
_UIStyle.Provider = ({ children, config }) => {
|
|
8
|
-
return /* @__PURE__ */ jsx(Context.Provider, {
|
|
9
|
-
value: config,
|
|
10
|
-
children
|
|
11
|
-
});
|
|
12
|
-
};
|
|
13
|
-
const useConfig = () => {
|
|
14
|
-
return use(Context);
|
|
15
|
-
};
|
|
16
|
-
_UIStyle.useCva = (key, fallback) => {
|
|
17
|
-
const uiStyle = useConfig();
|
|
18
|
-
if (!uiStyle) return fallback;
|
|
19
|
-
const [k1, k2] = key.split(".");
|
|
20
|
-
return uiStyle[k1]?.[k2] ?? fallback;
|
|
21
|
-
};
|
|
22
|
-
_UIStyle.useMapper = (key, fallback) => {
|
|
23
|
-
const uiStyle = useConfig();
|
|
24
|
-
if (!uiStyle) return fallback;
|
|
25
|
-
const [k1, k2] = key.split(".");
|
|
26
|
-
return uiStyle[k1]?.[k2] ?? fallback;
|
|
27
|
-
};
|
|
28
|
-
})(UIStyle || (UIStyle = {}));
|
|
29
|
-
//#endregion
|
|
30
|
-
export { UIStyle };
|