@studiocms/ui 0.3.2 → 0.4.1
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/components/Accordion/Accordion.astro +23 -0
- package/dist/components/Accordion/Item.astro +21 -0
- package/dist/components/Accordion/accordion.css +64 -0
- package/dist/components/Accordion/accordion.d.ts +1 -0
- package/dist/components/Accordion/accordion.js +70 -0
- package/dist/components/Badge/Badge.astro +49 -0
- package/dist/components/Badge/badge.css +111 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.astro +31 -0
- package/dist/components/Breadcrumbs/breadcrumbs.css +15 -0
- package/dist/components/Button/Button.astro +75 -0
- package/dist/components/Button/button.css +292 -0
- package/{src/components → dist/components/Card}/Card.astro +1 -48
- package/dist/components/Card/card.css +38 -0
- package/dist/components/Center/Center.astro +7 -0
- package/dist/components/Center/center.css +8 -0
- package/dist/components/Checkbox/Checkbox.astro +95 -0
- package/dist/components/Checkbox/checkbox.css +119 -0
- package/dist/components/Checkbox/checkbox.d.ts +2 -0
- package/dist/components/Checkbox/checkbox.js +20 -0
- package/{src/components → dist/components/Divider}/Divider.astro +2 -25
- package/dist/components/Divider/divider.css +21 -0
- package/dist/components/Dropdown/Dropdown.astro +116 -0
- package/dist/components/Dropdown/dropdown.css +180 -0
- package/dist/components/Dropdown/dropdown.d.ts +48 -0
- package/dist/components/Dropdown/dropdown.js +201 -0
- package/dist/components/Footer/Footer.astro +58 -0
- package/dist/components/Footer/footer.css +68 -0
- package/dist/components/Group/Group.astro +7 -0
- package/dist/components/Group/group.css +19 -0
- package/{src/utils → dist/components/Icon}/Icon.astro +1 -1
- package/{src/utils/iconType.ts → dist/components/Icon/iconType.d.ts} +0 -1
- package/dist/components/Icon/iconType.js +0 -0
- package/{src/components → dist/components/Input}/Input.astro +2 -48
- package/dist/components/Input/input.css +38 -0
- package/{src → dist}/components/Modal/Modal.astro +4 -122
- package/dist/components/Modal/modal.css +100 -0
- package/dist/components/Modal/modal.d.ts +48 -0
- package/dist/components/Modal/modal.js +129 -0
- package/dist/components/Progress/Progress.astro +21 -0
- package/dist/components/Progress/helper.d.ts +13 -0
- package/dist/components/Progress/helper.js +32 -0
- package/dist/components/Progress/progress.css +29 -0
- package/dist/components/Progress/progress.d.ts +1 -0
- package/dist/components/Progress/progress.js +10 -0
- package/dist/components/RadioGroup/RadioGroup.astro +124 -0
- package/dist/components/RadioGroup/radiogroup.css +96 -0
- package/dist/components/RadioGroup/radiogroup.d.ts +1 -0
- package/dist/components/RadioGroup/radiogroup.js +48 -0
- package/{src/components → dist/components/Row}/Row.astro +1 -24
- package/dist/components/Row/row.css +18 -0
- package/dist/components/SearchSelect/SearchSelect.astro +135 -0
- package/dist/components/SearchSelect/searchselect.css +95 -0
- package/dist/components/SearchSelect/searchselect.d.ts +6 -0
- package/dist/components/SearchSelect/searchselect.js +166 -0
- package/dist/components/Select/Select.astro +147 -0
- package/dist/components/Select/select.css +110 -0
- package/dist/components/Select/select.d.ts +1 -0
- package/dist/components/Select/select.js +143 -0
- package/dist/components/Sidebar/helpers.d.ts +76 -0
- package/dist/components/Sidebar/helpers.js +160 -0
- package/{src → dist}/components/Tabs/TabItem.astro +3 -3
- package/dist/components/Tabs/Tabs.astro +150 -0
- package/dist/components/Tabs/tabs.css +121 -0
- package/dist/components/Tabs/tabs.d.ts +1 -0
- package/dist/components/Tabs/tabs.js +82 -0
- package/{src/components → dist/components/Textarea}/Textarea.astro +2 -61
- package/dist/components/Textarea/textarea.css +49 -0
- package/dist/components/ThemeToggle/ThemeToggle.astro +21 -0
- package/dist/components/ThemeToggle/themetoggle.css +17 -0
- package/dist/components/ThemeToggle/themetoggle.d.ts +1 -0
- package/dist/components/ThemeToggle/themetoggle.js +4 -0
- package/dist/components/Toast/Toaster.astro +69 -0
- package/dist/components/Toast/toast.d.ts +8 -0
- package/dist/components/Toast/toast.js +9 -0
- package/dist/components/Toast/toaster.css +168 -0
- package/dist/components/Toast/toaster.d.ts +1 -0
- package/dist/components/Toast/toaster.js +160 -0
- package/dist/components/Toggle/Toggle.astro +84 -0
- package/dist/components/Toggle/toggle.css +93 -0
- package/dist/components/Toggle/toggle.d.ts +2 -0
- package/dist/components/Toggle/toggle.js +20 -0
- package/{src/components → dist/components/User}/User.astro +3 -43
- package/dist/components/User/user.css +35 -0
- package/dist/css/colors.css +95 -0
- package/dist/css/global.css +3 -0
- package/dist/css/radii.css +6 -0
- package/dist/css/resets.css +46 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +379 -0
- package/dist/toolbar/ColorPicker.d.ts +7 -0
- package/dist/toolbar/ColorPicker.js +85 -0
- package/dist/toolbar/icon.d.ts +1 -0
- package/dist/toolbar/icon.js +4 -0
- package/dist/toolbar/index.d.ts +2 -0
- package/dist/toolbar/index.js +292 -0
- package/dist/types/index.d.ts +11 -0
- package/dist/types/index.js +0 -0
- package/dist/utils/ThemeHelper.d.ts +49 -0
- package/dist/utils/ThemeHelper.js +113 -0
- package/{src/utils/colors.ts → dist/utils/colors.d.ts} +1 -1
- package/dist/utils/colors.js +0 -0
- package/dist/utils/generateID.d.ts +2 -0
- package/dist/utils/generateID.js +6 -0
- package/dist/utils/headers.d.ts +43 -0
- package/dist/utils/headers.js +129 -0
- package/dist/utils/iconStrings.d.ts +4 -0
- package/dist/utils/iconStrings.js +13 -0
- package/dist/utils/integration-utils.d.ts +130 -0
- package/dist/utils/integration-utils.js +161 -0
- package/package.json +26 -10
- package/src/components/BaseHead.astro +0 -22
- package/src/components/Button.astro +0 -372
- package/src/components/Center.astro +0 -16
- package/src/components/Checkbox.astro +0 -250
- package/src/components/Dropdown/Dropdown.astro +0 -314
- package/src/components/Dropdown/dropdown.ts +0 -258
- package/src/components/Dropdown/index.ts +0 -2
- package/src/components/Footer.astro +0 -137
- package/src/components/Modal/index.ts +0 -2
- package/src/components/Modal/modal.ts +0 -163
- package/src/components/RadioGroup.astro +0 -299
- package/src/components/SearchSelect.astro +0 -486
- package/src/components/Select.astro +0 -467
- package/src/components/Sidebar/helpers.ts +0 -179
- package/src/components/Sidebar/index.ts +0 -3
- package/src/components/Tabs/Tabs.astro +0 -393
- package/src/components/Tabs/index.ts +0 -2
- package/src/components/ThemeToggle.astro +0 -46
- package/src/components/Toast/Toaster.astro +0 -470
- package/src/components/Toast/index.ts +0 -2
- package/src/components/Toast/toast.ts +0 -16
- package/src/components/Toggle.astro +0 -214
- package/src/components/index.ts +0 -27
- package/src/components.ts +0 -26
- package/src/css/colors.css +0 -106
- package/src/css/global.css +0 -2
- package/src/css/resets.css +0 -54
- package/src/env.d.ts +0 -15
- package/src/integration.ts +0 -31
- package/src/layouts/RootLayout.astro +0 -33
- package/src/layouts/index.ts +0 -2
- package/src/layouts.ts +0 -1
- package/src/types/index.ts +0 -11
- package/src/utils/ThemeHelper.ts +0 -145
- package/src/utils/create-resolver.ts +0 -30
- package/src/utils/generateID.ts +0 -5
- package/src/utils/headers.ts +0 -190
- package/src/utils/iconStrings.ts +0 -29
- package/src/utils/index.ts +0 -1
- package/src/utils/virtual-module-plugin-builder.ts +0 -37
- /package/{src → dist}/components/Sidebar/Double.astro +0 -0
- /package/{src → dist}/components/Sidebar/Single.astro +0 -0
- /package/{src → dist}/icons/Checkmark.astro +0 -0
- /package/{src → dist}/icons/ChevronUpDown.astro +0 -0
- /package/{src → dist}/icons/User.astro +0 -0
- /package/{src → dist}/icons/X-Mark.astro +0 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const iconStrings = {
|
|
2
|
+
"check-circle": '<svg xmlns="http://www.w3.org/2000/svg" class="%class%" width="%width%" height="%height%" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M9 12.75 11.25 15 15 9.75M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z" /></svg>',
|
|
3
|
+
"exclamation-circle": '<svg xmlns="http://www.w3.org/2000/svg" class="%class%" width="%width%" height="%height%" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M12 9v3.75m9-.75a9 9 0 1 1-18 0 9 9 0 0 1 18 0Zm-9 3.75h.008v.008H12v-.008Z" /></svg>',
|
|
4
|
+
"information-circle": '<svg xmlns="http://www.w3.org/2000/svg" class="%class%" width="%width%" height="%height%" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="m11.25 11.25.041-.02a.75.75 0 0 1 1.063.852l-.708 2.836a.75.75 0 0 0 1.063.853l.041-.021M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Zm-9-3.75h.008v.008H12V8.25Z" /></svg>',
|
|
5
|
+
"x-mark": '<svg xmlns="http://www.w3.org/2000/svg" class="%class%" width="%width%" height="%height%" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M6 18 18 6M6 6l12 12" /></svg>',
|
|
6
|
+
"exclamation-triangle": '<svg xmlns="http://www.w3.org/2000/svg" class="%class%" width="%width%" height="%height%" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126ZM12 15.75h.007v.008H12v-.008Z" /></svg>'
|
|
7
|
+
};
|
|
8
|
+
function getIconString(icon, classes, width, height) {
|
|
9
|
+
return iconStrings[icon].replace("%class%", classes).replace("%width%", width.toString()).replace("%height%", height.toString());
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
getIconString
|
|
13
|
+
};
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import type { HookParameters } from 'astro';
|
|
2
|
+
import type { PluginOption } from 'vite';
|
|
3
|
+
export type Hooks = Required<Astro.IntegrationHooks>;
|
|
4
|
+
/**
|
|
5
|
+
* Allows resolving paths relatively to the integration folder easily. Call it like this:
|
|
6
|
+
*
|
|
7
|
+
* @param {string} _base - The location you want to create relative references from. `import.meta.url` is usually what you'll want.
|
|
8
|
+
*
|
|
9
|
+
* @see https://astro-integration-kit.netlify.app/core/create-resolver/
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* const { resolve } = createResolver(import.meta.url);
|
|
14
|
+
* const pluginPath = resolve("./plugin.ts");
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* This way, you do not have to add your plugin to your package.json `exports`.
|
|
18
|
+
*/
|
|
19
|
+
export declare const createResolver: (_base: string) => {
|
|
20
|
+
resolve: (...path: Array<string>) => string;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* A utility to be used on an Astro hook.
|
|
24
|
+
*
|
|
25
|
+
* @see defineUtility
|
|
26
|
+
*/
|
|
27
|
+
export type HookUtility<THook extends keyof Hooks, TArgs extends Array<any>, TReturn> = (params: HookParameters<THook>, ...args: TArgs) => TReturn;
|
|
28
|
+
/**
|
|
29
|
+
* Allows defining a type-safe function requiring all the params of a given hook.
|
|
30
|
+
* It uses currying to make TypeScript happy.
|
|
31
|
+
*
|
|
32
|
+
* @param {string} _hook
|
|
33
|
+
*
|
|
34
|
+
* @see https://astro-integration-kit.netlify.app/core/define-utility/
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```ts
|
|
38
|
+
* const test = defineUtility("astro:config:setup")((params, foo: boolean) => {
|
|
39
|
+
* return "bar";
|
|
40
|
+
* });
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export declare const defineUtility: <THook extends keyof Hooks>(_hook: THook) => <TArgs extends Array<any>, T>(fn: HookUtility<THook, TArgs, T>) => HookUtility<THook, TArgs, T>;
|
|
44
|
+
/**
|
|
45
|
+
* Checks for the existence of a Vite plugin inside the Astro config.
|
|
46
|
+
*
|
|
47
|
+
* @param {import("astro").HookParameters<"astro:config:setup">} params
|
|
48
|
+
* @param {Params} options
|
|
49
|
+
* @param {string | import("vite").PluginOption} options.plugin
|
|
50
|
+
*
|
|
51
|
+
* @see https://astro-integration-kit.netlify.app/utilities/has-vite-plugin/
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```ts
|
|
55
|
+
* hasVitePlugin(params, {
|
|
56
|
+
* plugin: "vite-plugin-my-integration",
|
|
57
|
+
* })
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
export declare const hasVitePlugin: HookUtility<"astro:config:setup", [{
|
|
61
|
+
plugin: string | PluginOption;
|
|
62
|
+
}], boolean>;
|
|
63
|
+
/**
|
|
64
|
+
* Adds a [vite plugin](https://vitejs.dev/guide/using-plugins) to the
|
|
65
|
+
* Astro config.
|
|
66
|
+
*
|
|
67
|
+
* @param {import("astro").HookParameters<"astro:config:setup">} params
|
|
68
|
+
* @param {object} options
|
|
69
|
+
* @param {import("vite").PluginOption} options.plugin
|
|
70
|
+
* @param {boolean} [options.warnDuplicated=true]
|
|
71
|
+
*
|
|
72
|
+
* @see https://astro-integration-kit.netlify.app/utilities/add-vite-plugin/
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```ts
|
|
76
|
+
* addVitePlugin(params, {
|
|
77
|
+
* plugin,
|
|
78
|
+
* warnDuplicated: true,
|
|
79
|
+
* })
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
export declare const addVitePlugin: HookUtility<"astro:config:setup", [{
|
|
83
|
+
plugin: PluginOption;
|
|
84
|
+
warnDuplicated?: boolean;
|
|
85
|
+
}], void>;
|
|
86
|
+
type VirtualImport = {
|
|
87
|
+
id: string;
|
|
88
|
+
content: string;
|
|
89
|
+
context?: 'server' | 'client' | undefined;
|
|
90
|
+
};
|
|
91
|
+
type Imports = Record<string, string> | Array<VirtualImport>;
|
|
92
|
+
/**
|
|
93
|
+
* Creates a Vite virtual module and updates the Astro config.
|
|
94
|
+
* Virtual imports are useful for passing things like config options, or data computed within the integration.
|
|
95
|
+
*
|
|
96
|
+
* @param {import("astro").HookParameters<"astro:config:setup">} params
|
|
97
|
+
* @param {object} options
|
|
98
|
+
* @param {string} options.name
|
|
99
|
+
* @param {Imports} options.imports
|
|
100
|
+
*
|
|
101
|
+
* @see https://astro-integration-kit.netlify.app/utilities/add-virtual-imports/
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ```ts
|
|
105
|
+
* // my-integration/index.ts
|
|
106
|
+
* import { addVirtualImports } from "astro-integration-kit";
|
|
107
|
+
*
|
|
108
|
+
* addVirtualImports(params, {
|
|
109
|
+
* name: 'my-integration',
|
|
110
|
+
* imports: {
|
|
111
|
+
* 'virtual:my-integration/config': `export default ${ JSON.stringify({foo: "bar"}) }`,
|
|
112
|
+
* },
|
|
113
|
+
* });
|
|
114
|
+
* ```
|
|
115
|
+
*
|
|
116
|
+
* This is then readable anywhere else in your integration:
|
|
117
|
+
*
|
|
118
|
+
* ```ts
|
|
119
|
+
* // myIntegration/src/component/layout.astro
|
|
120
|
+
* import config from "virtual:my-integration/config";
|
|
121
|
+
*
|
|
122
|
+
* console.log(config.foo) // "bar"
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
125
|
+
export declare const addVirtualImports: HookUtility<"astro:config:setup", [{
|
|
126
|
+
name: string;
|
|
127
|
+
imports: Imports;
|
|
128
|
+
__enableCorePowerDoNotUseOrYouWillBeFired?: boolean;
|
|
129
|
+
}], void>;
|
|
130
|
+
export {};
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { fileURLToPath } from "node:url";
|
|
2
|
+
import { AstroError } from "astro/errors";
|
|
3
|
+
import { dirname, resolve } from "pathe";
|
|
4
|
+
const createResolver = (_base) => {
|
|
5
|
+
let base = _base;
|
|
6
|
+
if (base.startsWith("file://")) {
|
|
7
|
+
base = dirname(fileURLToPath(base));
|
|
8
|
+
}
|
|
9
|
+
return {
|
|
10
|
+
resolve: (...path) => resolve(base, ...path)
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
const defineUtility = (_hook) => (
|
|
14
|
+
/**
|
|
15
|
+
* The function itself
|
|
16
|
+
* @param {Function} fn;
|
|
17
|
+
*/
|
|
18
|
+
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
19
|
+
(fn) => fn
|
|
20
|
+
);
|
|
21
|
+
function getPluginNames(plugins) {
|
|
22
|
+
const names = [];
|
|
23
|
+
if (plugins) {
|
|
24
|
+
for (const plugin of plugins) {
|
|
25
|
+
if (!plugin) continue;
|
|
26
|
+
if (Array.isArray(plugin)) {
|
|
27
|
+
names.push(...getPluginNames(plugin));
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
if (plugin instanceof Promise) {
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
names.push(plugin.name);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return names;
|
|
37
|
+
}
|
|
38
|
+
const hasVitePlugin = defineUtility("astro:config:setup")(
|
|
39
|
+
({ config }, {
|
|
40
|
+
plugin
|
|
41
|
+
}) => {
|
|
42
|
+
if (!plugin || plugin instanceof Promise) return false;
|
|
43
|
+
const currentPlugins = new Set(getPluginNames(config?.vite?.plugins));
|
|
44
|
+
const plugins = /* @__PURE__ */ new Set();
|
|
45
|
+
if (typeof plugin === "string") {
|
|
46
|
+
plugins.add(plugin);
|
|
47
|
+
}
|
|
48
|
+
if (typeof plugin === "object") {
|
|
49
|
+
if (Array.isArray(plugin)) {
|
|
50
|
+
const names = new Set(
|
|
51
|
+
getPluginNames(plugin)
|
|
52
|
+
);
|
|
53
|
+
for (const name of names) plugins.add(name);
|
|
54
|
+
} else {
|
|
55
|
+
plugins.add(plugin.name);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return [...plugins].some((name) => currentPlugins.has(name));
|
|
59
|
+
}
|
|
60
|
+
);
|
|
61
|
+
const addVitePlugin = defineUtility("astro:config:setup")(
|
|
62
|
+
(params, {
|
|
63
|
+
plugin,
|
|
64
|
+
warnDuplicated = true
|
|
65
|
+
}) => {
|
|
66
|
+
const { updateConfig, logger } = params;
|
|
67
|
+
if (warnDuplicated && hasVitePlugin(params, { plugin })) {
|
|
68
|
+
logger.warn(
|
|
69
|
+
`The Vite plugin "${plugin.name}" is already present in your Vite configuration, this plugin may not behave correctly.`
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
updateConfig({
|
|
73
|
+
vite: {
|
|
74
|
+
plugins: [plugin]
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
);
|
|
79
|
+
const incrementPluginName = (name) => {
|
|
80
|
+
let count = 1;
|
|
81
|
+
return `${name.replace(/-(\d+)$/, (_, c) => {
|
|
82
|
+
count = Number.parseInt(c) + 1;
|
|
83
|
+
return "";
|
|
84
|
+
})}-${count}`;
|
|
85
|
+
};
|
|
86
|
+
const resolveVirtualModuleId = (id) => {
|
|
87
|
+
return `\0${id}`;
|
|
88
|
+
};
|
|
89
|
+
const createVirtualModule = (name, _imports, bypassCoreValidation) => {
|
|
90
|
+
const imports = Array.isArray(_imports) ? _imports : Object.entries(_imports).map(([id, content]) => ({
|
|
91
|
+
id,
|
|
92
|
+
content,
|
|
93
|
+
context: void 0
|
|
94
|
+
}));
|
|
95
|
+
const duplicatedImports = {};
|
|
96
|
+
for (const { id, context } of imports) {
|
|
97
|
+
duplicatedImports[id] ??= [];
|
|
98
|
+
duplicatedImports[id]?.push(...context === void 0 ? ["server", "client"] : [context]);
|
|
99
|
+
}
|
|
100
|
+
for (const [id, contexts] of Object.entries(duplicatedImports)) {
|
|
101
|
+
if (contexts.length !== [...new Set(contexts)].length) {
|
|
102
|
+
throw new AstroError(
|
|
103
|
+
`Virtual import with id "${id}" has been registered several times with conflicting contexts.`
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
const resolutionMap = Object.fromEntries(
|
|
108
|
+
imports.map(({ id }) => {
|
|
109
|
+
if (!bypassCoreValidation && id.startsWith("astro:")) {
|
|
110
|
+
throw new AstroError(
|
|
111
|
+
`Virtual import name prefix can't be "astro:" (for "${id}") because it's reserved for Astro core.`
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
return [resolveVirtualModuleId(id), id];
|
|
115
|
+
})
|
|
116
|
+
);
|
|
117
|
+
return {
|
|
118
|
+
name,
|
|
119
|
+
resolveId(id) {
|
|
120
|
+
if (imports.find((_import) => _import.id === id)) {
|
|
121
|
+
return resolveVirtualModuleId(id);
|
|
122
|
+
}
|
|
123
|
+
return;
|
|
124
|
+
},
|
|
125
|
+
load(id, options) {
|
|
126
|
+
const resolution = resolutionMap[id];
|
|
127
|
+
if (resolution) {
|
|
128
|
+
const context = options?.ssr ? "server" : "client";
|
|
129
|
+
const data = imports.find(
|
|
130
|
+
(_import) => _import.id === resolution && (_import.context === void 0 || _import.context === context)
|
|
131
|
+
);
|
|
132
|
+
if (data) {
|
|
133
|
+
return data.content;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
};
|
|
140
|
+
const addVirtualImports = defineUtility("astro:config:setup")(
|
|
141
|
+
(params, {
|
|
142
|
+
name,
|
|
143
|
+
imports,
|
|
144
|
+
__enableCorePowerDoNotUseOrYouWillBeFired = false
|
|
145
|
+
}) => {
|
|
146
|
+
let pluginName = `vite-plugin-${name}`;
|
|
147
|
+
while (hasVitePlugin(params, { plugin: pluginName }))
|
|
148
|
+
pluginName = incrementPluginName(pluginName);
|
|
149
|
+
addVitePlugin(params, {
|
|
150
|
+
warnDuplicated: false,
|
|
151
|
+
plugin: createVirtualModule(pluginName, imports, __enableCorePowerDoNotUseOrYouWillBeFired)
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
);
|
|
155
|
+
export {
|
|
156
|
+
addVirtualImports,
|
|
157
|
+
addVitePlugin,
|
|
158
|
+
createResolver,
|
|
159
|
+
defineUtility,
|
|
160
|
+
hasVitePlugin
|
|
161
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@studiocms/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "The UI library for StudioCMS. Includes the layouts & components we use to build StudioCMS.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -26,31 +26,47 @@
|
|
|
26
26
|
],
|
|
27
27
|
"homepage": "https://ui.studiocms.dev",
|
|
28
28
|
"publishConfig": {
|
|
29
|
-
"access": "public"
|
|
29
|
+
"access": "public",
|
|
30
|
+
"provenance": true
|
|
30
31
|
},
|
|
31
32
|
"sideEffects": false,
|
|
32
33
|
"files": [
|
|
33
|
-
"
|
|
34
|
+
"dist"
|
|
34
35
|
],
|
|
35
36
|
"license": "MIT",
|
|
36
37
|
"type": "module",
|
|
37
38
|
"exports": {
|
|
38
|
-
".":
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
"./
|
|
43
|
-
|
|
39
|
+
".": {
|
|
40
|
+
"types": "./dist/index.d.ts",
|
|
41
|
+
"default": "./dist/index.js"
|
|
42
|
+
},
|
|
43
|
+
"./toolbar": {
|
|
44
|
+
"types": "./dist/toolbar/index.d.ts",
|
|
45
|
+
"default": "./dist/toolbar/index.js"
|
|
46
|
+
},
|
|
47
|
+
"./components/*": "./dist/components/*",
|
|
48
|
+
"./css/*": "./dist/css/*",
|
|
49
|
+
"./utils/*": "./dist/utils/*",
|
|
50
|
+
"./types": {
|
|
51
|
+
"types": "./dist/types/index.d.ts",
|
|
52
|
+
"default": "./dist/types/index.js"
|
|
53
|
+
}
|
|
44
54
|
},
|
|
45
55
|
"dependencies": {
|
|
46
56
|
"@iconify-json/heroicons": "^1.2.1",
|
|
47
57
|
"@iconify/utils": "^2.1.33",
|
|
58
|
+
"astro-transition-event-polyfill": "^1.1.0",
|
|
48
59
|
"pathe": "^1.1.2"
|
|
49
60
|
},
|
|
50
61
|
"peerDependencies": {
|
|
51
|
-
"astro": "^4.5 || ^5.0.0-beta.0"
|
|
62
|
+
"astro": "^4.5 || ^5.0.0-beta.0",
|
|
63
|
+
"vite": "^5.0.0 || ^6.0.0"
|
|
52
64
|
},
|
|
53
65
|
"devDependencies": {
|
|
54
66
|
"typescript": "^5.7.2"
|
|
67
|
+
},
|
|
68
|
+
"scripts": {
|
|
69
|
+
"build": "build-scripts build 'src/**/*.{ts,css}' --build-tsconfig",
|
|
70
|
+
"dev": "build-scripts dev 'src/**/*.{ts,css}' --build-tsconfig"
|
|
55
71
|
}
|
|
56
72
|
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
import { type HeadConfig, createHead, headDefaults } from '../utils/headers';
|
|
3
|
-
|
|
4
|
-
export interface Props {
|
|
5
|
-
title: string;
|
|
6
|
-
description: string;
|
|
7
|
-
headers?: HeadConfig | undefined;
|
|
8
|
-
image?: string | undefined;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const { title, description, image, headers: userHeaders } = Astro.props;
|
|
12
|
-
|
|
13
|
-
const canonicalURL = Astro.site ? new URL(Astro.url.pathname, Astro.site) : undefined;
|
|
14
|
-
|
|
15
|
-
// This should probably be removed from the UI lib at some point
|
|
16
|
-
const defaultHeaders = headDefaults(title, description, Astro, image, canonicalURL);
|
|
17
|
-
|
|
18
|
-
const head = createHead(defaultHeaders, userHeaders || []);
|
|
19
|
-
---
|
|
20
|
-
{head.map(({ tag: Tag, attrs, content }) => (
|
|
21
|
-
<Tag {...attrs} set:html={content} />
|
|
22
|
-
))}
|