@nuxt/ui 2.15.1 → 2.16.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/README.md +1 -18
- package/dist/module.d.mts +4 -24
- package/dist/module.d.ts +4 -24
- package/dist/module.json +1 -1
- package/dist/module.mjs +108 -329
- package/dist/runtime/components/data/Table.vue +35 -4
- package/dist/runtime/components/data/Table.vue.d.ts +25 -35
- package/dist/runtime/components/elements/Accordion.vue +25 -7
- package/dist/runtime/components/elements/Accordion.vue.d.ts +10 -1
- package/dist/runtime/components/elements/Alert.vue.d.ts +6 -6
- package/dist/runtime/components/elements/Avatar.vue.d.ts +10 -10
- package/dist/runtime/components/elements/Badge.vue.d.ts +5 -5
- package/dist/runtime/components/elements/Button.vue.d.ts +9 -9
- package/dist/runtime/components/elements/Carousel.vue +10 -4
- package/dist/runtime/components/elements/Carousel.vue.d.ts +3 -3
- package/dist/runtime/components/elements/Chip.vue.d.ts +8 -8
- package/dist/runtime/components/elements/Dropdown.vue +2 -2
- package/dist/runtime/components/elements/Dropdown.vue.d.ts +2 -2
- package/dist/runtime/components/elements/Kbd.vue.d.ts +2 -2
- package/dist/runtime/components/elements/Link.vue.d.ts +3 -3
- package/dist/runtime/components/elements/Meter.vue.d.ts +5 -5
- package/dist/runtime/components/elements/Progress.vue.d.ts +3 -3
- package/dist/runtime/components/forms/Checkbox.vue.d.ts +10 -10
- package/dist/runtime/components/forms/Form.vue.d.ts +2 -2
- package/dist/runtime/components/forms/FormGroup.vue.d.ts +7 -7
- package/dist/runtime/components/forms/Input.vue +1 -1
- package/dist/runtime/components/forms/Input.vue.d.ts +14 -14
- package/dist/runtime/components/forms/InputMenu.vue +6 -0
- package/dist/runtime/components/forms/InputMenu.vue.d.ts +30 -21
- package/dist/runtime/components/forms/Radio.vue.d.ts +11 -11
- package/dist/runtime/components/forms/RadioGroup.vue.d.ts +8 -8
- package/dist/runtime/components/forms/Range.vue.d.ts +8 -8
- package/dist/runtime/components/forms/Select.vue.d.ts +13 -13
- package/dist/runtime/components/forms/SelectMenu.vue +6 -0
- package/dist/runtime/components/forms/SelectMenu.vue.d.ts +30 -21
- package/dist/runtime/components/forms/Textarea.vue.d.ts +12 -12
- package/dist/runtime/components/forms/Toggle.vue.d.ts +7 -7
- package/dist/runtime/components/layout/Card.vue.d.ts +1 -1
- package/dist/runtime/components/layout/Container.vue.d.ts +1 -1
- package/dist/runtime/components/layout/Divider.vue.d.ts +5 -5
- package/dist/runtime/components/layout/Skeleton.vue.d.ts +1 -1
- package/dist/runtime/components/navigation/Breadcrumb.vue +1 -0
- package/dist/runtime/components/navigation/Breadcrumb.vue.d.ts +1 -1
- package/dist/runtime/components/navigation/CommandPalette.vue.d.ts +10 -10
- package/dist/runtime/components/navigation/HorizontalNavigation.vue.d.ts +1 -1
- package/dist/runtime/components/navigation/Pagination.vue +5 -0
- package/dist/runtime/components/navigation/Pagination.vue.d.ts +10 -1
- package/dist/runtime/components/navigation/Tabs.vue.d.ts +2 -2
- package/dist/runtime/components/navigation/VerticalNavigation.vue.d.ts +1 -1
- package/dist/runtime/components/overlays/ContextMenu.vue.d.ts +3 -3
- package/dist/runtime/components/overlays/Modal.vue +6 -2
- package/dist/runtime/components/overlays/Modal.vue.d.ts +7 -5
- package/dist/runtime/components/overlays/Modals.client.vue +8 -2
- package/dist/runtime/components/overlays/Notification.vue +8 -3
- package/dist/runtime/components/overlays/Notification.vue.d.ts +8 -8
- package/dist/runtime/components/overlays/Notifications.vue.d.ts +3 -1
- package/dist/runtime/components/overlays/Popover.vue +2 -2
- package/dist/runtime/components/overlays/Popover.vue.d.ts +3 -3
- package/dist/runtime/components/overlays/Slideover.vue +6 -2
- package/dist/runtime/components/overlays/Slideover.vue.d.ts +10 -8
- package/dist/runtime/components/overlays/Slideovers.client.vue +2 -1
- package/dist/runtime/components/overlays/Tooltip.vue.d.ts +2 -2
- package/dist/runtime/composables/useFormGroup.d.ts +1 -1
- package/dist/runtime/composables/useModal.d.ts +3 -2
- package/dist/runtime/composables/useModal.mjs +13 -3
- package/dist/runtime/composables/usePopper.d.ts +8 -8
- package/dist/runtime/composables/useSlideover.d.ts +2 -1
- package/dist/runtime/composables/useSlideover.mjs +8 -1
- package/dist/runtime/composables/useToast.d.ts +2 -0
- package/dist/runtime/composables/useToast.mjs +13 -1
- package/dist/runtime/types/slideover.d.ts +11 -12
- package/dist/runtime/ui.config/data/table.d.ts +4 -0
- package/dist/runtime/ui.config/data/table.mjs +4 -0
- package/dist/runtime/ui.config/forms/input.d.ts +0 -8
- package/dist/runtime/ui.config/forms/input.mjs +1 -9
- package/dist/runtime/ui.config/forms/select.d.ts +0 -8
- package/dist/runtime/ui.config/forms/textarea.d.ts +0 -8
- package/dist/runtime/ui.config/navigation/breadcrumb.mjs +1 -1
- package/dist/runtime/utils/colors.d.ts +11 -0
- package/dist/runtime/utils/colors.mjs +299 -0
- package/package.json +22 -25
|
@@ -5,20 +5,29 @@ function _useModal() {
|
|
|
5
5
|
const modalState = inject(modalInjectionKey);
|
|
6
6
|
const isOpen = ref(false);
|
|
7
7
|
function open(component, props) {
|
|
8
|
+
if (!modalState) {
|
|
9
|
+
throw new Error("useModal() is called without provider");
|
|
10
|
+
}
|
|
8
11
|
modalState.value = {
|
|
9
12
|
component,
|
|
10
13
|
props: props ?? {}
|
|
11
14
|
};
|
|
12
15
|
isOpen.value = true;
|
|
13
16
|
}
|
|
14
|
-
function close() {
|
|
17
|
+
async function close() {
|
|
18
|
+
if (!modalState)
|
|
19
|
+
return;
|
|
15
20
|
isOpen.value = false;
|
|
21
|
+
}
|
|
22
|
+
function reset() {
|
|
16
23
|
modalState.value = {
|
|
17
24
|
component: "div",
|
|
18
25
|
props: {}
|
|
19
26
|
};
|
|
20
27
|
}
|
|
21
28
|
function patch(props) {
|
|
29
|
+
if (!modalState)
|
|
30
|
+
return;
|
|
22
31
|
modalState.value = {
|
|
23
32
|
...modalState.value,
|
|
24
33
|
props: {
|
|
@@ -28,10 +37,11 @@ function _useModal() {
|
|
|
28
37
|
};
|
|
29
38
|
}
|
|
30
39
|
return {
|
|
31
|
-
isOpen,
|
|
32
40
|
open,
|
|
33
41
|
close,
|
|
34
|
-
|
|
42
|
+
reset,
|
|
43
|
+
patch,
|
|
44
|
+
isOpen
|
|
35
45
|
};
|
|
36
46
|
}
|
|
37
47
|
export const useModal = createSharedComposable(_useModal);
|
|
@@ -153,23 +153,23 @@ export declare function usePopper({ locked, overflowPadding, offsetDistance, off
|
|
|
153
153
|
};
|
|
154
154
|
} | undefined;
|
|
155
155
|
offset?: {
|
|
156
|
-
|
|
156
|
+
"bottom-end"?: {
|
|
157
157
|
y: number;
|
|
158
158
|
x: number;
|
|
159
159
|
} | undefined;
|
|
160
|
-
"bottom-
|
|
160
|
+
"bottom-start"?: {
|
|
161
161
|
y: number;
|
|
162
162
|
x: number;
|
|
163
163
|
} | undefined;
|
|
164
|
-
|
|
164
|
+
bottom?: {
|
|
165
165
|
y: number;
|
|
166
166
|
x: number;
|
|
167
167
|
} | undefined;
|
|
168
|
-
|
|
168
|
+
left?: {
|
|
169
169
|
y: number;
|
|
170
170
|
x: number;
|
|
171
171
|
} | undefined;
|
|
172
|
-
|
|
172
|
+
right?: {
|
|
173
173
|
y: number;
|
|
174
174
|
x: number;
|
|
175
175
|
} | undefined;
|
|
@@ -177,15 +177,15 @@ export declare function usePopper({ locked, overflowPadding, offsetDistance, off
|
|
|
177
177
|
y: number;
|
|
178
178
|
x: number;
|
|
179
179
|
} | undefined;
|
|
180
|
-
|
|
180
|
+
auto?: {
|
|
181
181
|
y: number;
|
|
182
182
|
x: number;
|
|
183
183
|
} | undefined;
|
|
184
|
-
|
|
184
|
+
"auto-start"?: {
|
|
185
185
|
y: number;
|
|
186
186
|
x: number;
|
|
187
187
|
} | undefined;
|
|
188
|
-
|
|
188
|
+
"auto-end"?: {
|
|
189
189
|
y: number;
|
|
190
190
|
x: number;
|
|
191
191
|
} | undefined;
|
|
@@ -4,7 +4,8 @@ import type { Slideover, SlideoverState } from '../types/slideover';
|
|
|
4
4
|
export declare const slidOverInjectionKey: InjectionKey<ShallowRef<SlideoverState>>;
|
|
5
5
|
declare function _useSlideover(): {
|
|
6
6
|
open: <T extends Component>(component: T, props?: Slideover & ComponentProps<T>) => void;
|
|
7
|
-
close: () => void
|
|
7
|
+
close: () => Promise<void>;
|
|
8
|
+
reset: () => void;
|
|
8
9
|
patch: <T_1 extends Component = {}>(props: Partial<Slideover & ComponentProps<T_1>>) => void;
|
|
9
10
|
isOpen: import("vue").Ref<boolean>;
|
|
10
11
|
};
|
|
@@ -14,11 +14,17 @@ function _useSlideover() {
|
|
|
14
14
|
};
|
|
15
15
|
isOpen.value = true;
|
|
16
16
|
}
|
|
17
|
-
function close() {
|
|
17
|
+
async function close() {
|
|
18
18
|
if (!slideoverState)
|
|
19
19
|
return;
|
|
20
20
|
isOpen.value = false;
|
|
21
21
|
}
|
|
22
|
+
function reset() {
|
|
23
|
+
slideoverState.value = {
|
|
24
|
+
component: "div",
|
|
25
|
+
props: {}
|
|
26
|
+
};
|
|
27
|
+
}
|
|
22
28
|
function patch(props) {
|
|
23
29
|
if (!slideoverState)
|
|
24
30
|
return;
|
|
@@ -33,6 +39,7 @@ function _useSlideover() {
|
|
|
33
39
|
return {
|
|
34
40
|
open,
|
|
35
41
|
close,
|
|
42
|
+
reset,
|
|
36
43
|
patch,
|
|
37
44
|
isOpen
|
|
38
45
|
};
|
|
@@ -15,8 +15,20 @@ export function useToast() {
|
|
|
15
15
|
function remove(id) {
|
|
16
16
|
notifications.value = notifications.value.filter((n) => n.id !== id);
|
|
17
17
|
}
|
|
18
|
+
function update(id, notification) {
|
|
19
|
+
const index = notifications.value.findIndex((n) => n.id === id);
|
|
20
|
+
if (index !== -1) {
|
|
21
|
+
const previous = notifications.value[index];
|
|
22
|
+
notifications.value.splice(index, 1, { ...previous, ...notification });
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function clear() {
|
|
26
|
+
notifications.value = [];
|
|
27
|
+
}
|
|
18
28
|
return {
|
|
19
29
|
add,
|
|
20
|
-
remove
|
|
30
|
+
remove,
|
|
31
|
+
update,
|
|
32
|
+
clear
|
|
21
33
|
};
|
|
22
34
|
}
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import type { Component } from 'vue'
|
|
2
2
|
|
|
3
|
-
interface Slideover {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
export interface Slideover {
|
|
4
|
+
ui?: any
|
|
5
|
+
side?: 'right' | 'left'
|
|
6
|
+
transition?: boolean
|
|
7
|
+
appear?: boolean
|
|
8
|
+
overlay?: boolean
|
|
9
|
+
preventClose?: boolean
|
|
10
|
+
modelValue?: boolean
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
interface SlideoverState {
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
export interface SlideoverState {
|
|
14
|
+
component: Component | string
|
|
15
|
+
props: Slideover
|
|
16
16
|
}
|
|
17
|
-
|
|
@@ -4,6 +4,7 @@ declare const _default: {
|
|
|
4
4
|
divide: string;
|
|
5
5
|
thead: string;
|
|
6
6
|
tbody: string;
|
|
7
|
+
caption: string;
|
|
7
8
|
tr: {
|
|
8
9
|
base: string;
|
|
9
10
|
selected: string;
|
|
@@ -50,6 +51,9 @@ declare const _default: {
|
|
|
50
51
|
variant: "ghost";
|
|
51
52
|
class: string;
|
|
52
53
|
};
|
|
54
|
+
checkbox: {
|
|
55
|
+
color: "primary";
|
|
56
|
+
};
|
|
53
57
|
progress: {
|
|
54
58
|
color: "primary";
|
|
55
59
|
animation: "carousel";
|
|
@@ -4,6 +4,7 @@ export default {
|
|
|
4
4
|
divide: "divide-y divide-gray-300 dark:divide-gray-700",
|
|
5
5
|
thead: "relative",
|
|
6
6
|
tbody: "divide-y divide-gray-200 dark:divide-gray-800",
|
|
7
|
+
caption: "sr-only",
|
|
7
8
|
tr: {
|
|
8
9
|
base: "",
|
|
9
10
|
selected: "bg-gray-50 dark:bg-gray-800/50",
|
|
@@ -50,6 +51,9 @@ export default {
|
|
|
50
51
|
variant: "ghost",
|
|
51
52
|
class: "-m-1.5"
|
|
52
53
|
},
|
|
54
|
+
checkbox: {
|
|
55
|
+
color: "primary"
|
|
56
|
+
},
|
|
53
57
|
progress: {
|
|
54
58
|
color: "primary",
|
|
55
59
|
animation: "carousel"
|
|
@@ -5,15 +5,7 @@ export default {
|
|
|
5
5
|
rounded: "rounded-md",
|
|
6
6
|
placeholder: "placeholder-gray-400 dark:placeholder-gray-500",
|
|
7
7
|
file: {
|
|
8
|
-
base: "file:
|
|
9
|
-
padding: {
|
|
10
|
-
"2xs": "ps-[85px]",
|
|
11
|
-
xs: "ps-[87px]",
|
|
12
|
-
sm: "ps-[96px]",
|
|
13
|
-
md: "ps-[98px]",
|
|
14
|
-
lg: "ps-[100px]",
|
|
15
|
-
xl: "ps-[109px]"
|
|
16
|
-
}
|
|
8
|
+
base: "file:mr-1.5 file:font-medium file:text-gray-500 dark:file:text-gray-400 file:bg-transparent file:border-0 file:p-0 file:outline-none"
|
|
17
9
|
},
|
|
18
10
|
size: {
|
|
19
11
|
"2xs": "text-xs",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export default {
|
|
2
|
-
wrapper: "relative",
|
|
2
|
+
wrapper: "relative min-w-0",
|
|
3
3
|
ol: "flex items-center gap-x-1.5",
|
|
4
4
|
li: "flex items-center gap-x-1.5 text-gray-500 dark:text-gray-400 text-sm leading-6 min-w-0",
|
|
5
5
|
base: "flex items-center gap-x-1.5 group font-semibold min-w-0",
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Config as TWConfig } from 'tailwindcss';
|
|
2
|
+
import defaultColors from 'tailwindcss/colors.js';
|
|
3
|
+
type ColorConfig = Exclude<TWConfig['theme']['colors'], Function>;
|
|
4
|
+
export declare const excludeColors: (colors: ColorConfig | typeof defaultColors) => string[];
|
|
5
|
+
export declare const setGlobalColors: (theme: TWConfig['theme']) => string[];
|
|
6
|
+
export declare const generateSafelist: (colors: string[], globalColors: string[]) => any[];
|
|
7
|
+
type SafelistFn = Exclude<NonNullable<Extract<TWConfig['content'], {
|
|
8
|
+
extract?: unknown;
|
|
9
|
+
}>['extract']>, Record<string, unknown>>;
|
|
10
|
+
export declare const customSafelistExtractor: (prefix: string, content: string, colors: string[], safelistColors: string[]) => ReturnType<SafelistFn>;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
import { omit } from "./lodash.mjs";
|
|
2
|
+
import { kebabCase, camelCase, upperFirst } from "scule";
|
|
3
|
+
import defaultColors from "tailwindcss/colors.js";
|
|
4
|
+
const colorsToExclude = [
|
|
5
|
+
"inherit",
|
|
6
|
+
"transparent",
|
|
7
|
+
"current",
|
|
8
|
+
"white",
|
|
9
|
+
"black",
|
|
10
|
+
"slate",
|
|
11
|
+
"gray",
|
|
12
|
+
"zinc",
|
|
13
|
+
"neutral",
|
|
14
|
+
"stone",
|
|
15
|
+
"cool"
|
|
16
|
+
];
|
|
17
|
+
const safelistByComponent = {
|
|
18
|
+
alert: (colorsAsRegex2) => [{
|
|
19
|
+
pattern: new RegExp(`bg-(${colorsAsRegex2})-50`)
|
|
20
|
+
}, {
|
|
21
|
+
pattern: new RegExp(`bg-(${colorsAsRegex2})-400`),
|
|
22
|
+
variants: ["dark"]
|
|
23
|
+
}, {
|
|
24
|
+
pattern: new RegExp(`bg-(${colorsAsRegex2})-500`)
|
|
25
|
+
}, {
|
|
26
|
+
pattern: new RegExp(`text-(${colorsAsRegex2})-400`),
|
|
27
|
+
variants: ["dark"]
|
|
28
|
+
}, {
|
|
29
|
+
pattern: new RegExp(`text-(${colorsAsRegex2})-500`)
|
|
30
|
+
}, {
|
|
31
|
+
pattern: new RegExp(`ring-(${colorsAsRegex2})-400`),
|
|
32
|
+
variants: ["dark"]
|
|
33
|
+
}, {
|
|
34
|
+
pattern: new RegExp(`ring-(${colorsAsRegex2})-500`)
|
|
35
|
+
}],
|
|
36
|
+
avatar: (colorsAsRegex2) => [{
|
|
37
|
+
pattern: new RegExp(`bg-(${colorsAsRegex2})-400`),
|
|
38
|
+
variants: ["dark"]
|
|
39
|
+
}, {
|
|
40
|
+
pattern: new RegExp(`bg-(${colorsAsRegex2})-500`)
|
|
41
|
+
}],
|
|
42
|
+
badge: (colorsAsRegex2) => [{
|
|
43
|
+
pattern: new RegExp(`bg-(${colorsAsRegex2})-50`)
|
|
44
|
+
}, {
|
|
45
|
+
pattern: new RegExp(`bg-(${colorsAsRegex2})-400`),
|
|
46
|
+
variants: ["dark"]
|
|
47
|
+
}, {
|
|
48
|
+
pattern: new RegExp(`bg-(${colorsAsRegex2})-500`)
|
|
49
|
+
}, {
|
|
50
|
+
pattern: new RegExp(`text-(${colorsAsRegex2})-400`),
|
|
51
|
+
variants: ["dark"]
|
|
52
|
+
}, {
|
|
53
|
+
pattern: new RegExp(`text-(${colorsAsRegex2})-500`)
|
|
54
|
+
}, {
|
|
55
|
+
pattern: new RegExp(`ring-(${colorsAsRegex2})-400`),
|
|
56
|
+
variants: ["dark"]
|
|
57
|
+
}, {
|
|
58
|
+
pattern: new RegExp(`ring-(${colorsAsRegex2})-500`)
|
|
59
|
+
}],
|
|
60
|
+
button: (colorsAsRegex2) => [{
|
|
61
|
+
pattern: new RegExp(`bg-(${colorsAsRegex2})-50`),
|
|
62
|
+
variants: ["hover", "disabled"]
|
|
63
|
+
}, {
|
|
64
|
+
pattern: new RegExp(`bg-(${colorsAsRegex2})-100`),
|
|
65
|
+
variants: ["hover"]
|
|
66
|
+
}, {
|
|
67
|
+
pattern: new RegExp(`bg-(${colorsAsRegex2})-400`),
|
|
68
|
+
variants: ["dark", "dark:disabled"]
|
|
69
|
+
}, {
|
|
70
|
+
pattern: new RegExp(`bg-(${colorsAsRegex2})-500`),
|
|
71
|
+
variants: ["disabled", "dark:hover"]
|
|
72
|
+
}, {
|
|
73
|
+
pattern: new RegExp(`bg-(${colorsAsRegex2})-600`),
|
|
74
|
+
variants: ["hover"]
|
|
75
|
+
}, {
|
|
76
|
+
pattern: new RegExp(`bg-(${colorsAsRegex2})-900`),
|
|
77
|
+
variants: ["dark:hover"]
|
|
78
|
+
}, {
|
|
79
|
+
pattern: new RegExp(`bg-(${colorsAsRegex2})-950`),
|
|
80
|
+
variants: ["dark", "dark:hover", "dark:disabled"]
|
|
81
|
+
}, {
|
|
82
|
+
pattern: new RegExp(`text-(${colorsAsRegex2})-400`),
|
|
83
|
+
variants: ["dark", "dark:disabled"]
|
|
84
|
+
}, {
|
|
85
|
+
pattern: new RegExp(`text-(${colorsAsRegex2})-500`),
|
|
86
|
+
variants: ["dark:hover", "disabled"]
|
|
87
|
+
}, {
|
|
88
|
+
pattern: new RegExp(`text-(${colorsAsRegex2})-600`),
|
|
89
|
+
variants: ["hover"]
|
|
90
|
+
}, {
|
|
91
|
+
pattern: new RegExp(`outline-(${colorsAsRegex2})-400`),
|
|
92
|
+
variants: ["dark:focus-visible"]
|
|
93
|
+
}, {
|
|
94
|
+
pattern: new RegExp(`outline-(${colorsAsRegex2})-500`),
|
|
95
|
+
variants: ["focus-visible"]
|
|
96
|
+
}, {
|
|
97
|
+
pattern: new RegExp(`ring-(${colorsAsRegex2})-400`),
|
|
98
|
+
variants: ["dark:focus-visible"]
|
|
99
|
+
}, {
|
|
100
|
+
pattern: new RegExp(`ring-(${colorsAsRegex2})-500`),
|
|
101
|
+
variants: ["focus-visible"]
|
|
102
|
+
}],
|
|
103
|
+
input: (colorsAsRegex2) => [{
|
|
104
|
+
pattern: new RegExp(`text-(${colorsAsRegex2})-400`),
|
|
105
|
+
variants: ["dark"]
|
|
106
|
+
}, {
|
|
107
|
+
pattern: new RegExp(`text-(${colorsAsRegex2})-500`)
|
|
108
|
+
}, {
|
|
109
|
+
pattern: new RegExp(`ring-(${colorsAsRegex2})-400`),
|
|
110
|
+
variants: ["dark", "dark:focus"]
|
|
111
|
+
}, {
|
|
112
|
+
pattern: new RegExp(`ring-(${colorsAsRegex2})-500`),
|
|
113
|
+
variants: ["focus"]
|
|
114
|
+
}],
|
|
115
|
+
radio: (colorsAsRegex2) => [{
|
|
116
|
+
pattern: new RegExp(`text-(${colorsAsRegex2})-400`),
|
|
117
|
+
variants: ["dark"]
|
|
118
|
+
}, {
|
|
119
|
+
pattern: new RegExp(`text-(${colorsAsRegex2})-500`)
|
|
120
|
+
}, {
|
|
121
|
+
pattern: new RegExp(`ring-(${colorsAsRegex2})-400`),
|
|
122
|
+
variants: ["dark:focus-visible"]
|
|
123
|
+
}, {
|
|
124
|
+
pattern: new RegExp(`ring-(${colorsAsRegex2})-500`),
|
|
125
|
+
variants: ["focus-visible"]
|
|
126
|
+
}],
|
|
127
|
+
checkbox: (colorsAsRegex2) => [{
|
|
128
|
+
pattern: new RegExp(`text-(${colorsAsRegex2})-400`),
|
|
129
|
+
variants: ["dark"]
|
|
130
|
+
}, {
|
|
131
|
+
pattern: new RegExp(`text-(${colorsAsRegex2})-500`)
|
|
132
|
+
}, {
|
|
133
|
+
pattern: new RegExp(`ring-(${colorsAsRegex2})-400`),
|
|
134
|
+
variants: ["dark:focus-visible"]
|
|
135
|
+
}, {
|
|
136
|
+
pattern: new RegExp(`ring-(${colorsAsRegex2})-500`),
|
|
137
|
+
variants: ["focus-visible"]
|
|
138
|
+
}],
|
|
139
|
+
toggle: (colorsAsRegex2) => [{
|
|
140
|
+
pattern: new RegExp(`bg-(${colorsAsRegex2})-400`),
|
|
141
|
+
variants: ["dark"]
|
|
142
|
+
}, {
|
|
143
|
+
pattern: new RegExp(`bg-(${colorsAsRegex2})-500`)
|
|
144
|
+
}, {
|
|
145
|
+
pattern: new RegExp(`text-(${colorsAsRegex2})-400`),
|
|
146
|
+
variants: ["dark"]
|
|
147
|
+
}, {
|
|
148
|
+
pattern: new RegExp(`text-(${colorsAsRegex2})-500`)
|
|
149
|
+
}, {
|
|
150
|
+
pattern: new RegExp(`ring-(${colorsAsRegex2})-400`),
|
|
151
|
+
variants: ["dark:focus-visible"]
|
|
152
|
+
}, {
|
|
153
|
+
pattern: new RegExp(`ring-(${colorsAsRegex2})-500`),
|
|
154
|
+
variants: ["focus-visible"]
|
|
155
|
+
}],
|
|
156
|
+
range: (colorsAsRegex2) => [{
|
|
157
|
+
pattern: new RegExp(`bg-(${colorsAsRegex2})-400`),
|
|
158
|
+
variants: ["dark"]
|
|
159
|
+
}, {
|
|
160
|
+
pattern: new RegExp(`bg-(${colorsAsRegex2})-500`)
|
|
161
|
+
}, {
|
|
162
|
+
pattern: new RegExp(`text-(${colorsAsRegex2})-400`),
|
|
163
|
+
variants: ["dark"]
|
|
164
|
+
}, {
|
|
165
|
+
pattern: new RegExp(`text-(${colorsAsRegex2})-500`)
|
|
166
|
+
}, {
|
|
167
|
+
pattern: new RegExp(`ring-(${colorsAsRegex2})-400`),
|
|
168
|
+
variants: ["dark:focus-visible"]
|
|
169
|
+
}, {
|
|
170
|
+
pattern: new RegExp(`ring-(${colorsAsRegex2})-500`),
|
|
171
|
+
variants: ["focus-visible"]
|
|
172
|
+
}],
|
|
173
|
+
progress: (colorsAsRegex2) => [{
|
|
174
|
+
pattern: new RegExp(`text-(${colorsAsRegex2})-400`),
|
|
175
|
+
variants: ["dark"]
|
|
176
|
+
}, {
|
|
177
|
+
pattern: new RegExp(`text-(${colorsAsRegex2})-500`)
|
|
178
|
+
}],
|
|
179
|
+
meter: (colorsAsRegex2) => [{
|
|
180
|
+
pattern: new RegExp(`bg-(${colorsAsRegex2})-400`),
|
|
181
|
+
variants: ["dark"]
|
|
182
|
+
}, {
|
|
183
|
+
pattern: new RegExp(`bg-(${colorsAsRegex2})-500`)
|
|
184
|
+
}, {
|
|
185
|
+
pattern: new RegExp(`text-(${colorsAsRegex2})-400`),
|
|
186
|
+
variants: ["dark"]
|
|
187
|
+
}, {
|
|
188
|
+
pattern: new RegExp(`text-(${colorsAsRegex2})-500`)
|
|
189
|
+
}],
|
|
190
|
+
notification: (colorsAsRegex2) => [{
|
|
191
|
+
pattern: new RegExp(`bg-(${colorsAsRegex2})-400`),
|
|
192
|
+
variants: ["dark"]
|
|
193
|
+
}, {
|
|
194
|
+
pattern: new RegExp(`bg-(${colorsAsRegex2})-500`)
|
|
195
|
+
}, {
|
|
196
|
+
pattern: new RegExp(`text-(${colorsAsRegex2})-400`),
|
|
197
|
+
variants: ["dark"]
|
|
198
|
+
}, {
|
|
199
|
+
pattern: new RegExp(`text-(${colorsAsRegex2})-500`)
|
|
200
|
+
}],
|
|
201
|
+
chip: (colorsAsRegex2) => [{
|
|
202
|
+
pattern: new RegExp(`bg-(${colorsAsRegex2})-400`),
|
|
203
|
+
variants: ["dark"]
|
|
204
|
+
}, {
|
|
205
|
+
pattern: new RegExp(`bg-(${colorsAsRegex2})-500`)
|
|
206
|
+
}]
|
|
207
|
+
};
|
|
208
|
+
const safelistComponentAliasesMap = {
|
|
209
|
+
"USelect": "UInput",
|
|
210
|
+
"USelectMenu": "UInput",
|
|
211
|
+
"UTextarea": "UInput",
|
|
212
|
+
"URadioGroup": "URadio",
|
|
213
|
+
"UMeterGroup": "UMeter"
|
|
214
|
+
};
|
|
215
|
+
const colorsAsRegex = (colors) => colors.join("|");
|
|
216
|
+
export const excludeColors = (colors) => {
|
|
217
|
+
return Object.entries(omit(colors, colorsToExclude)).filter(([, value]) => typeof value === "object").map(([key]) => kebabCase(key));
|
|
218
|
+
};
|
|
219
|
+
export const setGlobalColors = (theme) => {
|
|
220
|
+
const globalColors = {
|
|
221
|
+
...theme.colors || defaultColors,
|
|
222
|
+
...theme.extend?.colors
|
|
223
|
+
};
|
|
224
|
+
globalColors.primary = theme.extend.colors.primary = {
|
|
225
|
+
50: "rgb(var(--color-primary-50) / <alpha-value>)",
|
|
226
|
+
100: "rgb(var(--color-primary-100) / <alpha-value>)",
|
|
227
|
+
200: "rgb(var(--color-primary-200) / <alpha-value>)",
|
|
228
|
+
300: "rgb(var(--color-primary-300) / <alpha-value>)",
|
|
229
|
+
400: "rgb(var(--color-primary-400) / <alpha-value>)",
|
|
230
|
+
500: "rgb(var(--color-primary-500) / <alpha-value>)",
|
|
231
|
+
600: "rgb(var(--color-primary-600) / <alpha-value>)",
|
|
232
|
+
700: "rgb(var(--color-primary-700) / <alpha-value>)",
|
|
233
|
+
800: "rgb(var(--color-primary-800) / <alpha-value>)",
|
|
234
|
+
900: "rgb(var(--color-primary-900) / <alpha-value>)",
|
|
235
|
+
950: "rgb(var(--color-primary-950) / <alpha-value>)",
|
|
236
|
+
DEFAULT: "rgb(var(--color-primary-DEFAULT) / <alpha-value>)"
|
|
237
|
+
};
|
|
238
|
+
if (globalColors.gray) {
|
|
239
|
+
globalColors.cool = theme.extend.colors.cool = defaultColors.gray;
|
|
240
|
+
}
|
|
241
|
+
globalColors.gray = theme.extend.colors.gray = {
|
|
242
|
+
50: "rgb(var(--color-gray-50) / <alpha-value>)",
|
|
243
|
+
100: "rgb(var(--color-gray-100) / <alpha-value>)",
|
|
244
|
+
200: "rgb(var(--color-gray-200) / <alpha-value>)",
|
|
245
|
+
300: "rgb(var(--color-gray-300) / <alpha-value>)",
|
|
246
|
+
400: "rgb(var(--color-gray-400) / <alpha-value>)",
|
|
247
|
+
500: "rgb(var(--color-gray-500) / <alpha-value>)",
|
|
248
|
+
600: "rgb(var(--color-gray-600) / <alpha-value>)",
|
|
249
|
+
700: "rgb(var(--color-gray-700) / <alpha-value>)",
|
|
250
|
+
800: "rgb(var(--color-gray-800) / <alpha-value>)",
|
|
251
|
+
900: "rgb(var(--color-gray-900) / <alpha-value>)",
|
|
252
|
+
950: "rgb(var(--color-gray-950) / <alpha-value>)"
|
|
253
|
+
};
|
|
254
|
+
return excludeColors(globalColors);
|
|
255
|
+
};
|
|
256
|
+
export const generateSafelist = (colors, globalColors) => {
|
|
257
|
+
const baseSafelist = Object.keys(safelistByComponent).flatMap((component) => safelistByComponent[component](colorsAsRegex(colors)));
|
|
258
|
+
const formsSafelist = ["input", "radio", "checkbox", "toggle", "range"].flatMap((component) => safelistByComponent[component](colorsAsRegex(["red"])));
|
|
259
|
+
return [
|
|
260
|
+
...baseSafelist,
|
|
261
|
+
...formsSafelist,
|
|
262
|
+
// Ensure all global colors are safelisted for the Notification (toast.add)
|
|
263
|
+
...safelistByComponent["notification"](colorsAsRegex(globalColors)),
|
|
264
|
+
// Gray safelist for Avatar & Notification
|
|
265
|
+
"bg-gray-500",
|
|
266
|
+
"dark:bg-gray-400",
|
|
267
|
+
"text-gray-500",
|
|
268
|
+
"dark:text-gray-400"
|
|
269
|
+
];
|
|
270
|
+
};
|
|
271
|
+
export const customSafelistExtractor = (prefix, content, colors, safelistColors) => {
|
|
272
|
+
const classes = [];
|
|
273
|
+
const regex = /<([A-Za-z][A-Za-z0-9]*(?:-[A-Za-z][A-Za-z0-9]*)*)\s+(?![^>]*:color\b)[^>]*\bcolor=["']([^"']+)["'][^>]*>/gs;
|
|
274
|
+
const matches = content.matchAll(regex);
|
|
275
|
+
const components = Object.keys(safelistByComponent).map((component) => `${prefix}${component.charAt(0).toUpperCase() + component.slice(1)}`);
|
|
276
|
+
for (const match of matches) {
|
|
277
|
+
const [, component, color] = match;
|
|
278
|
+
const camelComponent = upperFirst(camelCase(component));
|
|
279
|
+
if (!colors.includes(color) || safelistColors.includes(color)) {
|
|
280
|
+
continue;
|
|
281
|
+
}
|
|
282
|
+
let name = safelistComponentAliasesMap[camelComponent] ? safelistComponentAliasesMap[camelComponent] : camelComponent;
|
|
283
|
+
if (!components.includes(name)) {
|
|
284
|
+
continue;
|
|
285
|
+
}
|
|
286
|
+
name = name.replace(prefix, "").toLowerCase();
|
|
287
|
+
const matchClasses = safelistByComponent[name](color).flatMap((group) => {
|
|
288
|
+
return typeof group === "string" ? "" : ["", ...group.variants || []].flatMap((variant) => {
|
|
289
|
+
const matches2 = group.pattern.source.match(/\(([^)]+)\)/g);
|
|
290
|
+
return matches2.map((match2) => {
|
|
291
|
+
const colorOptions = match2.substring(1, match2.length - 1).split("|");
|
|
292
|
+
return colorOptions.map((color2) => `${variant ? variant + ":" : ""}` + group.pattern.source.replace(match2, color2));
|
|
293
|
+
}).flat();
|
|
294
|
+
});
|
|
295
|
+
});
|
|
296
|
+
classes.push(...matchClasses);
|
|
297
|
+
}
|
|
298
|
+
return classes;
|
|
299
|
+
};
|