vueless 0.0.478-beta.3 → 0.0.479
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/composables/useBreakpoint.js +1 -1
- package/composables/useUI.js +1 -204
- package/constants.js +1 -2
- package/directives/clickOutside/vClickOutside.js +2 -2
- package/directives/tooltip/storybook/stories.js +5 -5
- package/{index.ts → index.js} +7 -10
- package/package.json +18 -28
- package/preset.tailwind.js +7 -16
- package/ui.button/config.js +0 -12
- package/ui.button/storybook/stories.js +2 -2
- package/ui.button-link/ULink.vue +1 -1
- package/ui.button-link/config.js +0 -9
- package/ui.button-link/storybook/stories.js +1 -1
- package/ui.button-toggle/storybook/stories.js +1 -1
- package/ui.container-divider/storybook/stories.js +1 -1
- package/ui.container-modal/storybook/stories.js +1 -1
- package/ui.container-modal-confirm/storybook/stories.js +1 -1
- package/ui.container-row/storybook/stories.js +1 -1
- package/ui.data-list/UDataList.vue +4 -4
- package/ui.data-table/UTable.vue +1 -1
- package/ui.dropdown-badge/config.js +0 -1
- package/ui.dropdown-badge/storybook/stories.js +1 -1
- package/ui.dropdown-button/config.js +0 -1
- package/ui.dropdown-button/storybook/stories.js +2 -2
- package/ui.dropdown-link/storybook/stories.js +1 -1
- package/ui.dropdown-list/storybook/stories.js +1 -1
- package/ui.form-checkbox/config.js +0 -9
- package/ui.form-checkbox/storybook/stories.js +1 -1
- package/ui.form-checkbox-group/storybook/stories.js +1 -1
- package/ui.form-checkbox-multi-state/storybook/stories.js +1 -1
- package/ui.form-color-picker/config.js +0 -7
- package/ui.form-color-picker/storybook/stories.js +1 -1
- package/ui.form-date-picker/storybook/stories.js +2 -2
- package/ui.form-date-picker-range/storybook/stories.js +1 -1
- package/ui.form-input/UInput.vue +1 -1
- package/ui.form-input/storybook/stories.js +1 -1
- package/ui.form-input-file/storybook/stories.js +1 -1
- package/ui.form-input-money/storybook/stories.js +1 -1
- package/ui.form-input-money/useFormatCurrency.js +1 -1
- package/ui.form-input-number/UInputNumber.vue +3 -4
- package/ui.form-input-number/storybook/stories.js +1 -1
- package/ui.form-input-rating/storybook/stories.js +1 -1
- package/ui.form-input-search/storybook/stories.js +1 -1
- package/ui.form-label/config.js +2 -2
- package/ui.form-label/storybook/stories.js +1 -1
- package/ui.form-radio/config.js +0 -6
- package/ui.form-radio-group/storybook/stories.js +1 -1
- package/ui.form-select/storybook/stories.js +1 -1
- package/ui.form-switch/config.js +0 -6
- package/ui.form-switch/storybook/stories.js +1 -1
- package/ui.form-textarea/storybook/stories.js +1 -1
- package/ui.image-avatar/config.js +0 -5
- package/ui.image-avatar/storybook/stories.js +1 -1
- package/ui.image-icon/UIcon.vue +14 -5
- package/ui.image-icon/config.js +0 -5
- package/ui.image-icon/storybook/stories.js +1 -1
- package/ui.loader/config.js +0 -1
- package/ui.loader/storybook/stories.js +1 -1
- package/ui.loader-overlay/config.js +0 -1
- package/ui.loader-progress/config.js +0 -1
- package/ui.loader-progress/storybook/stories.js +1 -1
- package/ui.navigation-progress/config.js +0 -9
- package/ui.navigation-progress/storybook/stories.js +1 -1
- package/ui.navigation-tabs/storybook/stories.js +1 -1
- package/ui.other-dot/config.js +0 -1
- package/ui.other-dot/storybook/stories.js +1 -1
- package/ui.text-alert/config.js +0 -7
- package/ui.text-alert/storybook/stories.js +1 -1
- package/ui.text-badge/config.js +0 -8
- package/ui.text-badge/storybook/stories.js +2 -10
- package/ui.text-block/UText.vue +62 -18
- package/ui.text-block/storybook/Docs.mdx +3 -3
- package/ui.text-block/storybook/{stories.ts → stories.js} +8 -13
- package/ui.text-block/useAttrs.js +15 -0
- package/ui.text-empty/storybook/stories.js +1 -1
- package/ui.text-file/UFile.vue +15 -12
- package/ui.text-file/config.js +2 -12
- package/ui.text-files/config.js +1 -1
- package/ui.text-header/config.js +0 -1
- package/ui.text-header/storybook/stories.js +1 -1
- package/ui.text-money/config.js +0 -1
- package/ui.text-money/storybook/stories.js +1 -1
- package/ui.text-money/utilMoney.js +2 -2
- package/{utilsTs/utilTheme.ts → utils/utilTheme.js} +27 -31
- package/utils/utilUI.js +205 -1
- package/web-types.json +9580 -0
- package/composablesTs/useAutoPosition.ts +0 -115
- package/composablesTs/useBreakpoint.ts +0 -106
- package/composablesTs/useLocale.ts +0 -25
- package/composablesTs/useMutationObserver.ts +0 -50
- package/composablesTs/useUI.ts +0 -557
- package/constants.ts +0 -73
- package/types.ts +0 -223
- package/ui.text-block/types.ts +0 -33
- package/ui.text-block/useAttrs.ts +0 -20
- package/utilsTs/utilHelper.ts +0 -68
- package/utilsTs/utilPlatform.ts +0 -53
- package/utilsTs/utilStorybook.ts +0 -296
- package/utilsTs/utilTailwind.ts +0 -38
- package/utilsTs/utilUI.ts +0 -143
- /package/ui.text-block/{config.ts → config.js} +0 -0
- /package/ui.text-block/{constants.ts → constants.js} +0 -0
package/types.ts
DELETED
|
@@ -1,223 +0,0 @@
|
|
|
1
|
-
import { hasSlotContent } from "./composablesTs/useUI.ts";
|
|
2
|
-
|
|
3
|
-
// TODO: Import all components here
|
|
4
|
-
import UTextDefaultConfig from "./ui.text-block/config.ts";
|
|
5
|
-
import UButtonDefaultConfig from "./ui.button/config.ts";
|
|
6
|
-
|
|
7
|
-
import type { ComputedRef } from "vue";
|
|
8
|
-
|
|
9
|
-
export interface ThemeConfig {
|
|
10
|
-
/**
|
|
11
|
-
* Components brand (primary) color.
|
|
12
|
-
*/
|
|
13
|
-
brand?: BrandColors;
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Components gray (secondary) color.
|
|
17
|
-
*/
|
|
18
|
-
gray?: GrayColors;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Default components rounding (border-radius).
|
|
22
|
-
*/
|
|
23
|
-
rounding?: number;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Default components ring width.
|
|
27
|
-
*/
|
|
28
|
-
ring?: number;
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Default components ring offset width.
|
|
32
|
-
*/
|
|
33
|
-
ringOffset?: number;
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Default components ring color for light theme.
|
|
37
|
-
*/
|
|
38
|
-
ringOffsetColorLight?: string;
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Default components ring color for dark theme.
|
|
42
|
-
*/
|
|
43
|
-
ringOffsetColorDark?: string;
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Default dark mode state.
|
|
47
|
-
*/
|
|
48
|
-
darkMode?: boolean;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export interface Config extends ThemeConfig {
|
|
52
|
-
/**
|
|
53
|
-
* Component classes merge behavior.
|
|
54
|
-
* – merge (default) – smartly merge provided custom classes with default config classes.
|
|
55
|
-
* – replace – replace default config keys by provided custom keys (override only provided keys, the rest classes will be taken from the default config).
|
|
56
|
-
* – override – override default config by provided custom config (keeps only custom config, removes all default classes).
|
|
57
|
-
*/
|
|
58
|
-
strategy?: Strategies;
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Component configs.
|
|
62
|
-
*/
|
|
63
|
-
component?: Partial<Components>;
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Tailwind-merge config extension for custom classes.
|
|
67
|
-
* All lists of rules available here:
|
|
68
|
-
* https://github.com/dcastil/tailwind-merge/blob/v2.3.0/src/lib/default-config.ts.
|
|
69
|
-
*/
|
|
70
|
-
tailwindMerge?: UnknownObject;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export type UnknownObject = Record<string, unknown>;
|
|
74
|
-
export type ComponentNames = keyof Components; // keys union
|
|
75
|
-
export type Strategies = "merge" | "replace" | "override";
|
|
76
|
-
export type GrayColors = "slate" | "cool" | "zinc" | "neutral" | "stone";
|
|
77
|
-
export type BrandColors =
|
|
78
|
-
| "grayscale"
|
|
79
|
-
| "red"
|
|
80
|
-
| "orange"
|
|
81
|
-
| "amber"
|
|
82
|
-
| "yellow"
|
|
83
|
-
| "lime"
|
|
84
|
-
| "green"
|
|
85
|
-
| "emerald"
|
|
86
|
-
| "teal"
|
|
87
|
-
| "cyan"
|
|
88
|
-
| "sky"
|
|
89
|
-
| "blue"
|
|
90
|
-
| "indigo"
|
|
91
|
-
| "violet"
|
|
92
|
-
| "purple"
|
|
93
|
-
| "fuchsia"
|
|
94
|
-
| "pink"
|
|
95
|
-
| "rose";
|
|
96
|
-
|
|
97
|
-
export interface Components {
|
|
98
|
-
UText?: Partial<typeof UTextDefaultConfig>;
|
|
99
|
-
UButton?: Partial<typeof UButtonDefaultConfig>;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
export interface Component {
|
|
103
|
-
i18n?: UnknownObject;
|
|
104
|
-
defaults?: Defaults;
|
|
105
|
-
safelist?: () => TailwindSafelist[];
|
|
106
|
-
strategy?: Strategies;
|
|
107
|
-
transition?: Transition;
|
|
108
|
-
safelistColors?: BrandColors;
|
|
109
|
-
[key: string]: (CVA & NestedComponent) | object | string | undefined;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
export type Defaults = {
|
|
113
|
-
color?: string;
|
|
114
|
-
[key: string]: unknown;
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
export interface NestedComponent {
|
|
118
|
-
component: string;
|
|
119
|
-
[key: string]: Record<string, string | object> | string;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
export interface Transition {
|
|
123
|
-
enterFromClass?: string;
|
|
124
|
-
enterActiveClass?: string;
|
|
125
|
-
enterToClass?: string;
|
|
126
|
-
leaveFromClass?: string;
|
|
127
|
-
leaveActiveClass?: string;
|
|
128
|
-
leaveToClass?: string;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
export interface CVA {
|
|
132
|
-
base?: string;
|
|
133
|
-
variants?: UnknownObject;
|
|
134
|
-
compoundVariants?: CVACompoundVariants[] & never[];
|
|
135
|
-
defaultVariants?: UnknownObject;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
export interface CVACompoundVariants {
|
|
139
|
-
class: string;
|
|
140
|
-
[key: string]: string | number | undefined | null;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
export interface VueAttrs {
|
|
144
|
-
id?: string;
|
|
145
|
-
class?: string;
|
|
146
|
-
value?: string;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
export interface UseAttrs {
|
|
150
|
-
hasSlotContent: typeof hasSlotContent;
|
|
151
|
-
[key: string]: object | undefined;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
export interface KeyAttrs extends VueAttrs {
|
|
155
|
-
"vl-component"?: string | null;
|
|
156
|
-
"vl-key"?: string | null;
|
|
157
|
-
"vl-child-component"?: string | null;
|
|
158
|
-
"vl-child-key"?: string | null;
|
|
159
|
-
config?: UnknownObject;
|
|
160
|
-
[key: string]: string | UnknownObject | undefined | null;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
export interface KeysToExtend {
|
|
164
|
-
base?: ComputedRef;
|
|
165
|
-
extend?: ComputedRef;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
export interface CreateVuelessOptions {
|
|
169
|
-
i18n?: Record<string, string | object>;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
export interface TailwindSafelist {
|
|
173
|
-
pattern: string;
|
|
174
|
-
variants?: string[];
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
export interface TailwindColorShades {
|
|
178
|
-
DEFAULT: string;
|
|
179
|
-
50: string;
|
|
180
|
-
100: string;
|
|
181
|
-
200: string;
|
|
182
|
-
300: string;
|
|
183
|
-
400: string;
|
|
184
|
-
500: string;
|
|
185
|
-
600: string;
|
|
186
|
-
700: string;
|
|
187
|
-
800: string;
|
|
188
|
-
900: string;
|
|
189
|
-
950: string;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
export interface VuelessCssVariables {
|
|
193
|
-
"--vl-ring": string;
|
|
194
|
-
"--vl-ring-offset": string;
|
|
195
|
-
"--vl-ring-offset-color": string;
|
|
196
|
-
"--vl-rounding": string;
|
|
197
|
-
/* Gray CSS variables */
|
|
198
|
-
"--vl-color-gray-50": string;
|
|
199
|
-
"--vl-color-gray-100": string;
|
|
200
|
-
"--vl-color-gray-200": string;
|
|
201
|
-
"--vl-color-gray-300": string;
|
|
202
|
-
"--vl-color-gray-400": string;
|
|
203
|
-
"--vl-color-gray-500": string;
|
|
204
|
-
"--vl-color-gray-600": string;
|
|
205
|
-
"--vl-color-gray-700": string;
|
|
206
|
-
"--vl-color-gray-800": string;
|
|
207
|
-
"--vl-color-gray-900": string;
|
|
208
|
-
"--vl-color-gray-950": string;
|
|
209
|
-
"--vl-color-gray-default": string;
|
|
210
|
-
/* Brand CSS variables */
|
|
211
|
-
"--vl-color-brand-50": string;
|
|
212
|
-
"--vl-color-brand-100": string;
|
|
213
|
-
"--vl-color-brand-200": string;
|
|
214
|
-
"--vl-color-brand-300": string;
|
|
215
|
-
"--vl-color-brand-400": string;
|
|
216
|
-
"--vl-color-brand-500": string;
|
|
217
|
-
"--vl-color-brand-600": string;
|
|
218
|
-
"--vl-color-brand-700": string;
|
|
219
|
-
"--vl-color-brand-800": string;
|
|
220
|
-
"--vl-color-brand-900": string;
|
|
221
|
-
"--vl-color-brand-950": string;
|
|
222
|
-
"--vl-color-brand-default": string;
|
|
223
|
-
}
|
package/ui.text-block/types.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import defaultConfig from "./config.ts";
|
|
2
|
-
|
|
3
|
-
export interface UTextProps {
|
|
4
|
-
/**
|
|
5
|
-
* HTML markdown or plain text.
|
|
6
|
-
*/
|
|
7
|
-
html?: string;
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Text size.
|
|
11
|
-
*/
|
|
12
|
-
size?: "sm" | "md" | "lg";
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Text align.
|
|
16
|
-
*/
|
|
17
|
-
align?: "left" | "center" | "right";
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Remove line height (useful for 1-line text).
|
|
21
|
-
*/
|
|
22
|
-
line?: boolean;
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Component config object.
|
|
26
|
-
*/
|
|
27
|
-
config?: Partial<typeof defaultConfig>;
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Data-test attribute for automated testing.
|
|
31
|
-
*/
|
|
32
|
-
dataTest?: string;
|
|
33
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import useUI from "../composablesTs/useUI.ts";
|
|
2
|
-
|
|
3
|
-
import defaultConfig from "./config.ts";
|
|
4
|
-
|
|
5
|
-
import type { UseAttrs } from "../types.ts";
|
|
6
|
-
import type { UTextProps } from "./types.ts";
|
|
7
|
-
|
|
8
|
-
type Config = Partial<typeof defaultConfig>;
|
|
9
|
-
|
|
10
|
-
export default function useAttrs(props: UTextProps): UseAttrs {
|
|
11
|
-
const { config, getKeysAttrs, hasSlotContent } = useUI<Config>(defaultConfig, () => props.config);
|
|
12
|
-
|
|
13
|
-
const keysAttrs = getKeysAttrs();
|
|
14
|
-
|
|
15
|
-
return {
|
|
16
|
-
config,
|
|
17
|
-
...keysAttrs,
|
|
18
|
-
hasSlotContent,
|
|
19
|
-
};
|
|
20
|
-
}
|
package/utilsTs/utilHelper.ts
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Deeply clone given object (same as lodash.cloneDeep).
|
|
3
|
-
*/
|
|
4
|
-
export function cloneDeep(entity: unknown, cache = new WeakMap()): unknown {
|
|
5
|
-
// primitives
|
|
6
|
-
if (Object(entity) !== entity || !entity) {
|
|
7
|
-
return entity;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
// cyclic reference
|
|
11
|
-
if (cache.has(entity)) {
|
|
12
|
-
return cache.get(entity);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const result =
|
|
16
|
-
entity instanceof Set
|
|
17
|
-
? new Set(entity)
|
|
18
|
-
: entity instanceof Map
|
|
19
|
-
? new Map(Array.from(entity, ([key, val]) => [key, cloneDeep(val, cache)]))
|
|
20
|
-
: entity instanceof Date
|
|
21
|
-
? new Date(entity)
|
|
22
|
-
: entity instanceof RegExp
|
|
23
|
-
? new RegExp(entity.source, entity.flags)
|
|
24
|
-
: entity.constructor
|
|
25
|
-
? new (entity.constructor as { new (): typeof entity })()
|
|
26
|
-
: Object.create(null);
|
|
27
|
-
|
|
28
|
-
cache.set(entity, result);
|
|
29
|
-
|
|
30
|
-
return Object.assign(
|
|
31
|
-
result,
|
|
32
|
-
...Object.keys(entity).map((key) => ({
|
|
33
|
-
[key]: cloneDeep((entity as Record<string | number, unknown>)[key], cache),
|
|
34
|
-
})),
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Creates a debounced function with delay (same as lodash.debounce).
|
|
40
|
-
*/
|
|
41
|
-
export function createDebounce(func: () => void, ms: number) {
|
|
42
|
-
let timeout: ReturnType<typeof setTimeout>;
|
|
43
|
-
|
|
44
|
-
return function (...args: []) {
|
|
45
|
-
clearTimeout(timeout);
|
|
46
|
-
// @ts-expect-error - this implicitly has type any because it does not have a type annotation.
|
|
47
|
-
timeout = setTimeout(() => func.apply(this as unknown, args), ms);
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Change page title in runtime by provided config.
|
|
53
|
-
*/
|
|
54
|
-
export function setTitle({ title = "", separator = " / ", suffix = "" }) {
|
|
55
|
-
if (isCSR) {
|
|
56
|
-
document.title = title ? title + separator + suffix : suffix;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Check is code rendering on the server side.
|
|
62
|
-
*/
|
|
63
|
-
export const isSSR: boolean = typeof window === "undefined";
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Check is code rendering on the client side.
|
|
67
|
-
*/
|
|
68
|
-
export const isCSR: boolean = typeof window !== "undefined";
|
package/utilsTs/utilPlatform.ts
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { isCSR } from "./utilHelper.ts";
|
|
2
|
-
|
|
3
|
-
interface ModernNavigator extends Navigator {
|
|
4
|
-
standalone: string;
|
|
5
|
-
userAgentData: {
|
|
6
|
-
platform: string;
|
|
7
|
-
};
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const isWindows = isCSR && checkIsWindows();
|
|
11
|
-
const isMac = isCSR && checkIsMac();
|
|
12
|
-
const isPWA = isCSR && checkIsPWA();
|
|
13
|
-
const isIOS = isCSR && checkIsIOS();
|
|
14
|
-
const isAndroid = isCSR && checkIsAndroid();
|
|
15
|
-
const isMobileApp = isPWA || isIOS || isAndroid;
|
|
16
|
-
|
|
17
|
-
function checkIsWindows() {
|
|
18
|
-
return getPlatform().toUpperCase().indexOf("WINDOWS") >= 0;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function checkIsMac() {
|
|
22
|
-
return getPlatform().toUpperCase().indexOf("MAC") >= 0;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function checkIsPWA() {
|
|
26
|
-
return !!(navigator as ModernNavigator).standalone;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function checkIsIOS() {
|
|
30
|
-
const iOSDevices = [
|
|
31
|
-
"iPad Simulator",
|
|
32
|
-
"iPhone Simulator",
|
|
33
|
-
"iPod Simulator",
|
|
34
|
-
"iPad",
|
|
35
|
-
"iPhone",
|
|
36
|
-
"iPod",
|
|
37
|
-
];
|
|
38
|
-
|
|
39
|
-
const platform = getPlatform();
|
|
40
|
-
const isIpodIOS13 = platform.includes("Mac") && "ontouchend" in document;
|
|
41
|
-
|
|
42
|
-
return iOSDevices.includes(platform) || isIpodIOS13;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function checkIsAndroid() {
|
|
46
|
-
return getPlatform().toUpperCase().indexOf("ANDROID") >= 0;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
function getPlatform() {
|
|
50
|
-
return (navigator as ModernNavigator).userAgentData?.platform || navigator.platform || "unknown";
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export { isMac, isPWA, isIOS, isAndroid, isMobileApp, isWindows };
|
package/utilsTs/utilStorybook.ts
DELETED
|
@@ -1,296 +0,0 @@
|
|
|
1
|
-
interface WebTypes {
|
|
2
|
-
framework: string;
|
|
3
|
-
name: string;
|
|
4
|
-
version: string;
|
|
5
|
-
contributions: Contributions;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
interface Contributions {
|
|
9
|
-
html: HtmlContributions;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
interface HtmlContributions {
|
|
13
|
-
"description-markup": string;
|
|
14
|
-
"types-syntax": string;
|
|
15
|
-
tags: Tag[];
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
interface Tag {
|
|
19
|
-
name: string;
|
|
20
|
-
description?: string;
|
|
21
|
-
attributes?: Attribute[];
|
|
22
|
-
events?: Event[];
|
|
23
|
-
slots?: Slot[];
|
|
24
|
-
exposes?: Expose[];
|
|
25
|
-
source?: Source;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
interface Attribute {
|
|
29
|
-
name: string;
|
|
30
|
-
required?: boolean;
|
|
31
|
-
description?: string;
|
|
32
|
-
value: AttributeValue;
|
|
33
|
-
default?: unknown;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
interface AttributeValue {
|
|
37
|
-
kind: string;
|
|
38
|
-
type: string;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
interface Event {
|
|
42
|
-
name: string;
|
|
43
|
-
description?: string;
|
|
44
|
-
properties?: EventProperty[];
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
interface EventProperty {
|
|
48
|
-
type: string[];
|
|
49
|
-
name: string;
|
|
50
|
-
description?: string;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
interface Slot {
|
|
54
|
-
name: string;
|
|
55
|
-
description?: string;
|
|
56
|
-
scoped?: boolean;
|
|
57
|
-
bindings?: SlotBinding[];
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
interface SlotBinding {
|
|
61
|
-
type: string;
|
|
62
|
-
name: string;
|
|
63
|
-
description?: string;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
interface Expose {
|
|
67
|
-
name: string;
|
|
68
|
-
description?: string;
|
|
69
|
-
properties: ExposeProperty[];
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
interface ExposeProperty {
|
|
73
|
-
type: string;
|
|
74
|
-
description?: string;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
interface Source {
|
|
78
|
-
module: string;
|
|
79
|
-
symbol: string;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
interface Types {
|
|
83
|
-
[key: string]: ArgType | undefined;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
interface ArgType {
|
|
87
|
-
control?: "text" | "number" | "boolean" | "array" | "select" | false;
|
|
88
|
-
options?: string[];
|
|
89
|
-
table?: TableConfig;
|
|
90
|
-
name?: string;
|
|
91
|
-
description?: string;
|
|
92
|
-
type?: string | null;
|
|
93
|
-
action?: string;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
interface TableConfig {
|
|
97
|
-
disable?: boolean;
|
|
98
|
-
defaultValue?: { summary: unknown };
|
|
99
|
-
category?: "slots" | "expose" | "Storybook Events";
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/* Load Web-Types from the project root. */
|
|
103
|
-
const [webTypes]: WebTypes[] = Object.values(
|
|
104
|
-
import.meta.glob("/web-types.json", { eager: true, import: "default" }),
|
|
105
|
-
);
|
|
106
|
-
|
|
107
|
-
const getComponentData = (componentName: string | undefined) => {
|
|
108
|
-
if (!componentName) return;
|
|
109
|
-
|
|
110
|
-
return webTypes.contributions.html.tags.find((item: Tag) => item.name === componentName);
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
export function getSlotNames(componentName: string | undefined) {
|
|
114
|
-
if (!componentName) return;
|
|
115
|
-
|
|
116
|
-
return getComponentData(componentName)?.slots?.map((item) => item.name);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
export function getArgTypes(componentName: string | undefined) {
|
|
120
|
-
const component = getComponentData(componentName);
|
|
121
|
-
|
|
122
|
-
if (!component) return;
|
|
123
|
-
|
|
124
|
-
const types: Partial<Types> = {
|
|
125
|
-
// Hide default template arg in docs.
|
|
126
|
-
defaultTemplate: { table: { disable: true } },
|
|
127
|
-
// Hide slot template arg in docs.
|
|
128
|
-
slotTemplate: { table: { disable: true } },
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
component.attributes?.forEach((attribute: Attribute) => {
|
|
132
|
-
const type = attribute.value.type;
|
|
133
|
-
|
|
134
|
-
if (type === "string" || type.includes("string")) {
|
|
135
|
-
types[attribute.name] = {
|
|
136
|
-
control: "text",
|
|
137
|
-
table: {
|
|
138
|
-
defaultValue: { summary: attribute.default || "" },
|
|
139
|
-
},
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
if (type === "number") {
|
|
144
|
-
types[attribute.name] = {
|
|
145
|
-
control: "number",
|
|
146
|
-
table: {
|
|
147
|
-
defaultValue: { summary: attribute.default || "" },
|
|
148
|
-
},
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
if (type === "boolean") {
|
|
153
|
-
types[attribute.name] = {
|
|
154
|
-
control: "boolean",
|
|
155
|
-
table: {
|
|
156
|
-
defaultValue: { summary: attribute.default || "" },
|
|
157
|
-
},
|
|
158
|
-
};
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
if (type === "array") {
|
|
162
|
-
types[attribute.name] = {
|
|
163
|
-
control: "array",
|
|
164
|
-
table: {
|
|
165
|
-
defaultValue: { summary: attribute.default || [] },
|
|
166
|
-
},
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
if (type.includes("|")) {
|
|
171
|
-
const options = attribute.value.type.replace(/['|]/g, "").split(/\s+/);
|
|
172
|
-
|
|
173
|
-
if (options.length > 1) {
|
|
174
|
-
types[attribute.name] = {
|
|
175
|
-
options,
|
|
176
|
-
control: "select",
|
|
177
|
-
table: {
|
|
178
|
-
defaultValue: { summary: attribute.default || "" },
|
|
179
|
-
},
|
|
180
|
-
};
|
|
181
|
-
} else {
|
|
182
|
-
types[attribute.name] = {
|
|
183
|
-
control: type.split("|")[0] as ArgType["control"],
|
|
184
|
-
table: {
|
|
185
|
-
defaultValue: { summary: attribute.default || "" },
|
|
186
|
-
},
|
|
187
|
-
};
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
if (attribute.description?.includes("@ignore")) {
|
|
192
|
-
types[attribute.name] = {
|
|
193
|
-
table: {
|
|
194
|
-
disable: true,
|
|
195
|
-
},
|
|
196
|
-
};
|
|
197
|
-
}
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
component.slots?.forEach((slot) => {
|
|
201
|
-
const bindings: string[] = [];
|
|
202
|
-
|
|
203
|
-
slot.bindings?.forEach((binding: SlotBinding) => {
|
|
204
|
-
if (binding.name === "name") return;
|
|
205
|
-
|
|
206
|
-
const description = binding.description ? ` (${binding.description})` : "";
|
|
207
|
-
|
|
208
|
-
bindings.push(`${binding.name}: ${binding.type}${description}`);
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
types[`${slot.name}Slot`] = {
|
|
212
|
-
name: slot.name,
|
|
213
|
-
description: slot.description,
|
|
214
|
-
type: slot.bindings ? `{ ${bindings.join(", ")} }` : null,
|
|
215
|
-
control: "text",
|
|
216
|
-
table: { category: "slots" },
|
|
217
|
-
};
|
|
218
|
-
|
|
219
|
-
// Hide autogenerated slot docs, but keep props with the same name
|
|
220
|
-
if (!component.attributes?.map((item) => item.name)?.includes(slot.name)) {
|
|
221
|
-
types[slot.name] = {
|
|
222
|
-
table: {
|
|
223
|
-
disable: true,
|
|
224
|
-
},
|
|
225
|
-
};
|
|
226
|
-
}
|
|
227
|
-
});
|
|
228
|
-
|
|
229
|
-
component.exposes?.forEach((expose) => {
|
|
230
|
-
const properties: string[] = [];
|
|
231
|
-
|
|
232
|
-
expose.properties?.forEach((property: ExposeProperty) => {
|
|
233
|
-
const description = property.description ? ` (${property.description})` : "";
|
|
234
|
-
|
|
235
|
-
properties.push(`${property.type}${description}`);
|
|
236
|
-
});
|
|
237
|
-
|
|
238
|
-
types[`${expose.name}Expose`] = {
|
|
239
|
-
type: expose.properties ? properties.join(", ") : null,
|
|
240
|
-
name: expose.name,
|
|
241
|
-
description: expose.description,
|
|
242
|
-
control: false,
|
|
243
|
-
table: { category: "expose" },
|
|
244
|
-
};
|
|
245
|
-
|
|
246
|
-
// Hide autogenerated expose docs, but keep props with the same name
|
|
247
|
-
if (!component.attributes?.map((item) => item.name)?.includes(expose.name)) {
|
|
248
|
-
types[expose.name] = {
|
|
249
|
-
table: {
|
|
250
|
-
disable: true,
|
|
251
|
-
},
|
|
252
|
-
};
|
|
253
|
-
}
|
|
254
|
-
});
|
|
255
|
-
|
|
256
|
-
component.events?.forEach((event) => {
|
|
257
|
-
const properties: string[] = [];
|
|
258
|
-
|
|
259
|
-
event.properties?.forEach((property: EventProperty) => {
|
|
260
|
-
const description = property.description ? ` (${property.description})` : "";
|
|
261
|
-
|
|
262
|
-
properties.push(`${property.name}: ${property.type}${description}`);
|
|
263
|
-
});
|
|
264
|
-
|
|
265
|
-
types[event.name] = {
|
|
266
|
-
type: event.properties ? properties.join(", ") : null,
|
|
267
|
-
name: event.name,
|
|
268
|
-
description: event.description,
|
|
269
|
-
};
|
|
270
|
-
|
|
271
|
-
if (import.meta.env.STORYBOOK_FULL) {
|
|
272
|
-
const eventName = "on" + event.name.charAt(0).toUpperCase() + event.name.slice(1);
|
|
273
|
-
|
|
274
|
-
types[eventName] = {
|
|
275
|
-
action: event.name,
|
|
276
|
-
table: { category: "Storybook Events" },
|
|
277
|
-
};
|
|
278
|
-
}
|
|
279
|
-
});
|
|
280
|
-
|
|
281
|
-
return types;
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
export function getSource(defaultConfig: string) {
|
|
285
|
-
return defaultConfig.replace("export default /*tw*/ ", "").replace(";", "");
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
export function getSlotsFragment(defaultTemplate: string) {
|
|
289
|
-
return `
|
|
290
|
-
<template v-for="(slot, index) of slots" :key="index" v-slot:[slot]>
|
|
291
|
-
<template v-if="slot === 'default' && !args['defaultSlot']">${defaultTemplate || ""}</template>
|
|
292
|
-
<template v-else-if="slot === 'default' && args['defaultSlot']">{{ args['defaultSlot'] }}</template>
|
|
293
|
-
<template v-else-if="args[slot + 'Slot']">{{ args[slot + 'Slot'] }}</template>
|
|
294
|
-
</template>
|
|
295
|
-
`;
|
|
296
|
-
}
|