numori-ui 0.1.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/LICENSE +651 -0
- package/README.md +466 -0
- package/dist/components/Alert.js +137 -0
- package/dist/components/Alert.js.map +1 -0
- package/dist/components/Avatar.js +133 -0
- package/dist/components/Avatar.js.map +1 -0
- package/dist/components/Badge.js +93 -0
- package/dist/components/Badge.js.map +1 -0
- package/dist/components/Button.js +428 -0
- package/dist/components/Button.js.map +1 -0
- package/dist/components/ButtonsGroup.js +153 -0
- package/dist/components/ButtonsGroup.js.map +1 -0
- package/dist/components/Checkbox.js +93 -0
- package/dist/components/Checkbox.js.map +1 -0
- package/dist/components/Divider.js +79 -0
- package/dist/components/Divider.js.map +1 -0
- package/dist/components/Dropdown.js +166 -0
- package/dist/components/Dropdown.js.map +1 -0
- package/dist/components/DropdownItem.js +106 -0
- package/dist/components/DropdownItem.js.map +1 -0
- package/dist/components/DropdownRow.js +41 -0
- package/dist/components/DropdownRow.js.map +1 -0
- package/dist/components/DropdownSubmenu.js +142 -0
- package/dist/components/DropdownSubmenu.js.map +1 -0
- package/dist/components/FileInput.js +122 -0
- package/dist/components/FileInput.js.map +1 -0
- package/dist/components/FormField.js +112 -0
- package/dist/components/FormField.js.map +1 -0
- package/dist/components/Input.js +603 -0
- package/dist/components/Input.js.map +1 -0
- package/dist/components/Kbd.js +35 -0
- package/dist/components/Kbd.js.map +1 -0
- package/dist/components/ListMenu.js +143 -0
- package/dist/components/ListMenu.js.map +1 -0
- package/dist/components/ListMenuItem.js +189 -0
- package/dist/components/ListMenuItem.js.map +1 -0
- package/dist/components/Modal.js +206 -0
- package/dist/components/Modal.js.map +1 -0
- package/dist/components/Numpad.js +123 -0
- package/dist/components/Numpad.js.map +1 -0
- package/dist/components/Popup.js +170 -0
- package/dist/components/Popup.js.map +1 -0
- package/dist/components/ProgressBar.js +118 -0
- package/dist/components/ProgressBar.js.map +1 -0
- package/dist/components/Prompt.js +201 -0
- package/dist/components/Prompt.js.map +1 -0
- package/dist/components/Radio.js +81 -0
- package/dist/components/Radio.js.map +1 -0
- package/dist/components/Select.js +441 -0
- package/dist/components/Select.js.map +1 -0
- package/dist/components/Slider.js +116 -0
- package/dist/components/Slider.js.map +1 -0
- package/dist/components/Stepper.js +65 -0
- package/dist/components/Stepper.js.map +1 -0
- package/dist/components/Toggle.js +133 -0
- package/dist/components/Toggle.js.map +1 -0
- package/dist/components/Tooltip.js +120 -0
- package/dist/components/Tooltip.js.map +1 -0
- package/dist/components/index.js +81 -0
- package/dist/components/index.js.map +1 -0
- package/dist/composables/onClickOutside.js +51 -0
- package/dist/composables/onClickOutside.js.map +1 -0
- package/dist/composables/useBackButton.js +98 -0
- package/dist/composables/useBackButton.js.map +1 -0
- package/dist/composables/useEventListener.js +63 -0
- package/dist/composables/useEventListener.js.map +1 -0
- package/dist/icons/Icon.js +120 -0
- package/dist/icons/Icon.js.map +1 -0
- package/dist/icons/mdi.js +69 -0
- package/dist/icons/mdi.js.map +1 -0
- package/dist/icons/registry.js +63 -0
- package/dist/icons/registry.js.map +1 -0
- package/dist/icons/resolver.js +49 -0
- package/dist/icons/resolver.js.map +1 -0
- package/dist/index.d.ts +108 -0
- package/dist/index.js +157 -0
- package/dist/index.js.map +1 -0
- package/dist/manifest.js +89 -0
- package/dist/manifest.js.map +1 -0
- package/dist/numori-ui.css +184 -0
- package/dist/nuxt.d.ts +35 -0
- package/dist/nuxt.mjs +243 -0
- package/dist/nuxt.mjs.map +1 -0
- package/dist/vite.d.ts +29 -0
- package/dist/vite.mjs +187 -0
- package/dist/vite.mjs.map +1 -0
- package/package.json +138 -0
- package/src/components/Alert.vue +127 -0
- package/src/components/Avatar.vue +100 -0
- package/src/components/Badge.vue +77 -0
- package/src/components/Button.vue +419 -0
- package/src/components/ButtonsGroup.vue +140 -0
- package/src/components/Checkbox.vue +81 -0
- package/src/components/Divider.vue +64 -0
- package/src/components/Dropdown.vue +150 -0
- package/src/components/DropdownItem.vue +78 -0
- package/src/components/DropdownRow.vue +37 -0
- package/src/components/DropdownSubmenu.vue +127 -0
- package/src/components/FileInput.vue +107 -0
- package/src/components/FormField.vue +86 -0
- package/src/components/Input.vue +619 -0
- package/src/components/Kbd.vue +30 -0
- package/src/components/ListMenu.vue +127 -0
- package/src/components/ListMenuItem.vue +171 -0
- package/src/components/Modal.vue +209 -0
- package/src/components/Numpad.vue +118 -0
- package/src/components/Popup.vue +156 -0
- package/src/components/ProgressBar.vue +107 -0
- package/src/components/Prompt.vue +161 -0
- package/src/components/Radio.vue +50 -0
- package/src/components/Select.vue +470 -0
- package/src/components/Slider.vue +93 -0
- package/src/components/Stepper.vue +53 -0
- package/src/components/Toggle.vue +125 -0
- package/src/components/Tooltip.vue +113 -0
- package/src/components/index.js +109 -0
- package/src/composables/onClickOutside.js +61 -0
- package/src/composables/useBackButton.js +98 -0
- package/src/composables/useEventListener.js +65 -0
- package/src/icons/Icon.vue +139 -0
- package/src/icons/mdi.js +67 -0
- package/src/icons/registry.js +64 -0
- package/src/icons/resolver.js +48 -0
- package/src/index.js +167 -0
- package/src/manifest.js +86 -0
- package/src/nuxt.js +315 -0
- package/src/style.css +20 -0
- package/src/tailwind.css +18 -0
- package/src/theme.css +172 -0
- package/src/vite.js +235 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { computed, ref } from "vue";
|
|
2
|
+
//#region src/composables/useBackButton.js
|
|
3
|
+
/**
|
|
4
|
+
* useBackButton — a LIFO stack of "go back" handlers that overlays register
|
|
5
|
+
* themselves with while they are open.
|
|
6
|
+
*
|
|
7
|
+
* Numori UI's overlays (modals, prompts) should close when the user triggers a
|
|
8
|
+
* platform back gesture — the Android hardware button under Capacitor, a
|
|
9
|
+
* browser popstate, or anything else the host decides. The library must not
|
|
10
|
+
* depend on Capacitor to do that, so it only maintains the stack and exposes
|
|
11
|
+
* `invoke()`. **The host application is responsible for calling `invoke()`**
|
|
12
|
+
* from whatever back signal it actually has. Until it does, the stack simply
|
|
13
|
+
* sits idle and overlays behave normally.
|
|
14
|
+
*
|
|
15
|
+
* Handlers run most-recently-registered first, so a prompt opened on top of a
|
|
16
|
+
* modal consumes the event before the modal underneath sees it. A handler
|
|
17
|
+
* returns `true` to consume the event, or `false` to let it fall through.
|
|
18
|
+
*
|
|
19
|
+
* The stack is module-level (shared across every consumer) because back
|
|
20
|
+
* navigation is inherently a single global concern. Registration is a no-op
|
|
21
|
+
* outside the browser, which keeps server rendering free of cross-request
|
|
22
|
+
* leakage.
|
|
23
|
+
*
|
|
24
|
+
* @example Wiring it up in a Capacitor host
|
|
25
|
+
* import { App } from '@capacitor/app'
|
|
26
|
+
* import { useBackButton } from 'numori-ui'
|
|
27
|
+
*
|
|
28
|
+
* const { invoke } = useBackButton()
|
|
29
|
+
* App.addListener('backButton', ({ canGoBack }) => {
|
|
30
|
+
* if (invoke()) return // an overlay handled it
|
|
31
|
+
* if (canGoBack) history.back()
|
|
32
|
+
* else App.exitApp()
|
|
33
|
+
* })
|
|
34
|
+
*
|
|
35
|
+
* @example Wiring it up in a browser host
|
|
36
|
+
* const { invoke, hasHandlers } = useBackButton()
|
|
37
|
+
* window.addEventListener('popstate', () => {
|
|
38
|
+
* if (hasHandlers.value) invoke()
|
|
39
|
+
* })
|
|
40
|
+
*/
|
|
41
|
+
/** @type {import('vue').Ref<Array<{ id: number, handler: () => boolean, priority: number }>>} */
|
|
42
|
+
var handlers = ref([]);
|
|
43
|
+
var nextId = 0;
|
|
44
|
+
/**
|
|
45
|
+
* Evaluated per call rather than once at module load. Module-load evaluation
|
|
46
|
+
* would bake in whatever environment first imported the file, which is wrong
|
|
47
|
+
* for SSR (the same module instance serves the server render and, in tests, a
|
|
48
|
+
* simulated browser).
|
|
49
|
+
*/
|
|
50
|
+
var isBrowser = () => typeof window !== "undefined";
|
|
51
|
+
var useBackButton = () => {
|
|
52
|
+
/**
|
|
53
|
+
* Register a back handler.
|
|
54
|
+
* @param {() => boolean} handler Return true if the event was consumed.
|
|
55
|
+
* @param {number} [priority=0] Higher priority runs first among peers.
|
|
56
|
+
* @returns {number} id — Pass to `unregister` on close/unmount.
|
|
57
|
+
*/
|
|
58
|
+
const register = (handler, priority = 0) => {
|
|
59
|
+
if (!isBrowser()) return -1;
|
|
60
|
+
const id = nextId++;
|
|
61
|
+
handlers.value.push({
|
|
62
|
+
id,
|
|
63
|
+
handler,
|
|
64
|
+
priority
|
|
65
|
+
});
|
|
66
|
+
return id;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Unregister a previously registered handler.
|
|
70
|
+
* @param {number} id
|
|
71
|
+
*/
|
|
72
|
+
const unregister = (id) => {
|
|
73
|
+
if (id === -1) return;
|
|
74
|
+
const idx = handlers.value.findIndex((h) => h.id === id);
|
|
75
|
+
if (idx !== -1) handlers.value.splice(idx, 1);
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Invoke the topmost handler that consumes the event.
|
|
79
|
+
* Call this from the host's back-navigation signal.
|
|
80
|
+
* @returns {boolean} true if a handler consumed the event.
|
|
81
|
+
*/
|
|
82
|
+
const invoke = () => {
|
|
83
|
+
if (handlers.value.length === 0) return false;
|
|
84
|
+
const sorted = [...handlers.value].sort((a, b) => b.priority - a.priority || b.id - a.id);
|
|
85
|
+
for (const entry of sorted) if (entry.handler()) return true;
|
|
86
|
+
return false;
|
|
87
|
+
};
|
|
88
|
+
return {
|
|
89
|
+
register,
|
|
90
|
+
unregister,
|
|
91
|
+
invoke,
|
|
92
|
+
hasHandlers: computed(() => handlers.value.length > 0)
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
//#endregion
|
|
96
|
+
export { useBackButton };
|
|
97
|
+
|
|
98
|
+
//# sourceMappingURL=useBackButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBackButton.js","names":[],"sources":["../../src/composables/useBackButton.js"],"sourcesContent":["import { computed, ref } from 'vue'\n\n/**\n * useBackButton — a LIFO stack of \"go back\" handlers that overlays register\n * themselves with while they are open.\n *\n * Numori UI's overlays (modals, prompts) should close when the user triggers a\n * platform back gesture — the Android hardware button under Capacitor, a\n * browser popstate, or anything else the host decides. The library must not\n * depend on Capacitor to do that, so it only maintains the stack and exposes\n * `invoke()`. **The host application is responsible for calling `invoke()`**\n * from whatever back signal it actually has. Until it does, the stack simply\n * sits idle and overlays behave normally.\n *\n * Handlers run most-recently-registered first, so a prompt opened on top of a\n * modal consumes the event before the modal underneath sees it. A handler\n * returns `true` to consume the event, or `false` to let it fall through.\n *\n * The stack is module-level (shared across every consumer) because back\n * navigation is inherently a single global concern. Registration is a no-op\n * outside the browser, which keeps server rendering free of cross-request\n * leakage.\n *\n * @example Wiring it up in a Capacitor host\n * import { App } from '@capacitor/app'\n * import { useBackButton } from 'numori-ui'\n *\n * const { invoke } = useBackButton()\n * App.addListener('backButton', ({ canGoBack }) => {\n * if (invoke()) return // an overlay handled it\n * if (canGoBack) history.back()\n * else App.exitApp()\n * })\n *\n * @example Wiring it up in a browser host\n * const { invoke, hasHandlers } = useBackButton()\n * window.addEventListener('popstate', () => {\n * if (hasHandlers.value) invoke()\n * })\n */\n\n/** @type {import('vue').Ref<Array<{ id: number, handler: () => boolean, priority: number }>>} */\nconst handlers = ref([])\nlet nextId = 0\n\n/**\n * Evaluated per call rather than once at module load. Module-load evaluation\n * would bake in whatever environment first imported the file, which is wrong\n * for SSR (the same module instance serves the server render and, in tests, a\n * simulated browser).\n */\nconst isBrowser = () => typeof window !== 'undefined'\n\nexport const useBackButton = () => {\n /**\n * Register a back handler.\n * @param {() => boolean} handler Return true if the event was consumed.\n * @param {number} [priority=0] Higher priority runs first among peers.\n * @returns {number} id — Pass to `unregister` on close/unmount.\n */\n const register = (handler, priority = 0) => {\n if (!isBrowser()) return -1\n const id = nextId++\n handlers.value.push({ id, handler, priority })\n return id\n }\n\n /**\n * Unregister a previously registered handler.\n * @param {number} id\n */\n const unregister = (id) => {\n if (id === -1) return\n const idx = handlers.value.findIndex((h) => h.id === id)\n if (idx !== -1) handlers.value.splice(idx, 1)\n }\n\n /**\n * Invoke the topmost handler that consumes the event.\n * Call this from the host's back-navigation signal.\n * @returns {boolean} true if a handler consumed the event.\n */\n const invoke = () => {\n if (handlers.value.length === 0) return false\n // Priority descending, then id descending so the most recently opened\n // overlay of equal priority gets first refusal.\n const sorted = [...handlers.value].sort((a, b) => b.priority - a.priority || b.id - a.id)\n for (const entry of sorted) {\n if (entry.handler()) return true\n }\n return false\n }\n\n /** Whether any overlay currently wants to intercept back navigation. */\n const hasHandlers = computed(() => handlers.value.length > 0)\n\n return { register, unregister, invoke, hasHandlers }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,IAAM,WAAW,IAAI,CAAC,CAAC;AACvB,IAAI,SAAS;;;;;;;AAQb,IAAM,kBAAkB,OAAO,WAAW;AAE1C,IAAa,sBAAsB;;;;;;;CAOjC,MAAM,YAAY,SAAS,WAAW,MAAM;EAC1C,IAAI,CAAC,UAAU,GAAG,OAAO;EACzB,MAAM,KAAK;EACX,SAAS,MAAM,KAAK;GAAE;GAAI;GAAS;EAAS,CAAC;EAC7C,OAAO;CACT;;;;;CAMA,MAAM,cAAc,OAAO;EACzB,IAAI,OAAO,IAAI;EACf,MAAM,MAAM,SAAS,MAAM,WAAW,MAAM,EAAE,OAAO,EAAE;EACvD,IAAI,QAAQ,IAAI,SAAS,MAAM,OAAO,KAAK,CAAC;CAC9C;;;;;;CAOA,MAAM,eAAe;EACnB,IAAI,SAAS,MAAM,WAAW,GAAG,OAAO;EAGxC,MAAM,SAAS,CAAC,GAAG,SAAS,KAAK,CAAC,CAAC,MAAM,GAAG,MAAM,EAAE,WAAW,EAAE,YAAY,EAAE,KAAK,EAAE,EAAE;EACxF,KAAK,MAAM,SAAS,QAClB,IAAI,MAAM,QAAQ,GAAG,OAAO;EAE9B,OAAO;CACT;CAKA,OAAO;EAAE;EAAU;EAAY;EAAQ,aAFnB,eAAe,SAAS,MAAM,SAAS,CAEV;CAAE;AACrD"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { getCurrentScope, onScopeDispose, toValue, watch } from "vue";
|
|
2
|
+
//#region src/composables/useEventListener.js
|
|
3
|
+
/**
|
|
4
|
+
* useEventListener — attaches a DOM event listener that cleans itself up when
|
|
5
|
+
* the owning component (or effect scope) is torn down.
|
|
6
|
+
*
|
|
7
|
+
* A dependency-free stand-in for VueUse's helper of the same name, covering
|
|
8
|
+
* the subset Numori UI needs. Numori Notes gets VueUse auto-imported from
|
|
9
|
+
* `@vueuse/nuxt`; a library should not force that on its consumers for two
|
|
10
|
+
* small utilities, so this ships in-package instead.
|
|
11
|
+
*
|
|
12
|
+
* The target may be a plain value, a ref, or a getter, so listeners follow an
|
|
13
|
+
* element as it is mounted, swapped or unmounted. A nullish target is a no-op,
|
|
14
|
+
* which is what keeps this safe to call during setup under SSR — pass a getter
|
|
15
|
+
* such as `() => globalThis.document` and it simply does nothing on the server,
|
|
16
|
+
* then binds on the client.
|
|
17
|
+
*
|
|
18
|
+
* @param {EventTarget | import('vue').Ref<EventTarget | null | undefined> | (() => EventTarget | null | undefined) | null | undefined} target
|
|
19
|
+
* Element or event target to bind to. May be a ref or a getter.
|
|
20
|
+
* @param {string} event Event name, e.g. 'keydown'.
|
|
21
|
+
* @param {(event: Event) => void} handler Listener callback.
|
|
22
|
+
* @param {boolean | AddEventListenerOptions} [options] Native listener options.
|
|
23
|
+
* @returns {() => void} stop — Removes the listener early.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* useEventListener(globalThis.document, 'keydown', (e) => {
|
|
27
|
+
* if (e.key === 'Escape') close()
|
|
28
|
+
* })
|
|
29
|
+
*
|
|
30
|
+
* @example Conditional binding via a getter
|
|
31
|
+
* useEventListener(
|
|
32
|
+
* () => (props.capture ? globalThis.window : null),
|
|
33
|
+
* 'keydown',
|
|
34
|
+
* onKeydown,
|
|
35
|
+
* )
|
|
36
|
+
*/
|
|
37
|
+
function useEventListener(target, event, handler, options) {
|
|
38
|
+
let detach = null;
|
|
39
|
+
const remove = () => {
|
|
40
|
+
detach?.();
|
|
41
|
+
detach = null;
|
|
42
|
+
};
|
|
43
|
+
const attach = (el) => {
|
|
44
|
+
remove();
|
|
45
|
+
if (!el || typeof el.addEventListener !== "function") return;
|
|
46
|
+
el.addEventListener(event, handler, options);
|
|
47
|
+
detach = () => el.removeEventListener(event, handler, options);
|
|
48
|
+
};
|
|
49
|
+
const stopWatch = watch(() => toValue(target), attach, {
|
|
50
|
+
immediate: true,
|
|
51
|
+
flush: "post"
|
|
52
|
+
});
|
|
53
|
+
const stop = () => {
|
|
54
|
+
stopWatch();
|
|
55
|
+
remove();
|
|
56
|
+
};
|
|
57
|
+
if (getCurrentScope()) onScopeDispose(stop);
|
|
58
|
+
return stop;
|
|
59
|
+
}
|
|
60
|
+
//#endregion
|
|
61
|
+
export { useEventListener };
|
|
62
|
+
|
|
63
|
+
//# sourceMappingURL=useEventListener.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useEventListener.js","names":[],"sources":["../../src/composables/useEventListener.js"],"sourcesContent":["import { getCurrentScope, onScopeDispose, watch, toValue } from 'vue'\n\n/**\n * useEventListener — attaches a DOM event listener that cleans itself up when\n * the owning component (or effect scope) is torn down.\n *\n * A dependency-free stand-in for VueUse's helper of the same name, covering\n * the subset Numori UI needs. Numori Notes gets VueUse auto-imported from\n * `@vueuse/nuxt`; a library should not force that on its consumers for two\n * small utilities, so this ships in-package instead.\n *\n * The target may be a plain value, a ref, or a getter, so listeners follow an\n * element as it is mounted, swapped or unmounted. A nullish target is a no-op,\n * which is what keeps this safe to call during setup under SSR — pass a getter\n * such as `() => globalThis.document` and it simply does nothing on the server,\n * then binds on the client.\n *\n * @param {EventTarget | import('vue').Ref<EventTarget | null | undefined> | (() => EventTarget | null | undefined) | null | undefined} target\n * Element or event target to bind to. May be a ref or a getter.\n * @param {string} event Event name, e.g. 'keydown'.\n * @param {(event: Event) => void} handler Listener callback.\n * @param {boolean | AddEventListenerOptions} [options] Native listener options.\n * @returns {() => void} stop — Removes the listener early.\n *\n * @example\n * useEventListener(globalThis.document, 'keydown', (e) => {\n * if (e.key === 'Escape') close()\n * })\n *\n * @example Conditional binding via a getter\n * useEventListener(\n * () => (props.capture ? globalThis.window : null),\n * 'keydown',\n * onKeydown,\n * )\n */\nexport function useEventListener(target, event, handler, options) {\n let detach = null\n\n const remove = () => {\n detach?.()\n detach = null\n }\n\n const attach = (el) => {\n remove()\n if (!el || typeof el.addEventListener !== 'function') return\n el.addEventListener(event, handler, options)\n detach = () => el.removeEventListener(event, handler, options)\n }\n\n // Watched rather than bound once, so a ref or getter target can change: the\n // listener moves with the element, and a getter that returns null on the\n // server starts working after hydration.\n const stopWatch = watch(() => toValue(target), attach, { immediate: true, flush: 'post' })\n\n const stop = () => {\n stopWatch()\n remove()\n }\n\n if (getCurrentScope()) onScopeDispose(stop)\n\n return stop\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,SAAgB,iBAAiB,QAAQ,OAAO,SAAS,SAAS;CAChE,IAAI,SAAS;CAEb,MAAM,eAAe;EACnB,SAAS;EACT,SAAS;CACX;CAEA,MAAM,UAAU,OAAO;EACrB,OAAO;EACP,IAAI,CAAC,MAAM,OAAO,GAAG,qBAAqB,YAAY;EACtD,GAAG,iBAAiB,OAAO,SAAS,OAAO;EAC3C,eAAe,GAAG,oBAAoB,OAAO,SAAS,OAAO;CAC/D;CAKA,MAAM,YAAY,YAAY,QAAQ,MAAM,GAAG,QAAQ;EAAE,WAAW;EAAM,OAAO;CAAO,CAAC;CAEzF,MAAM,aAAa;EACjB,UAAU;EACV,OAAO;CACT;CAEA,IAAI,gBAAgB,GAAG,eAAe,IAAI;CAE1C,OAAO;AACT"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { MDI_VIEW_BOX } from "./mdi.js";
|
|
2
|
+
import { resolveIconPath } from "./registry.js";
|
|
3
|
+
import { useIconComponent } from "./resolver.js";
|
|
4
|
+
import { computed, defineComponent, h } from "vue";
|
|
5
|
+
//#region src/icons/Icon.vue
|
|
6
|
+
/**
|
|
7
|
+
* UiIcon — renders an icon by name, either from the bundled Material Design
|
|
8
|
+
* Icons subset or through a host-supplied icon component.
|
|
9
|
+
*
|
|
10
|
+
* This is the seam that lets Numori UI stay framework-agnostic. Numori Notes
|
|
11
|
+
* used `<Icon>` from `@nuxt/icon`, which only exists inside Nuxt; this
|
|
12
|
+
* component gives the same ergonomics with no framework coupling:
|
|
13
|
+
*
|
|
14
|
+
* - **Default** — draws inline SVG from the MDI paths bundled in `mdi.js`.
|
|
15
|
+
* Zero dependencies, zero network requests, SSR-safe.
|
|
16
|
+
* - **Overridden** — if the host provided a component (via the plugin's
|
|
17
|
+
* `icons.component` option or `provideIconComponent`), every icon is
|
|
18
|
+
* delegated to it, so an app that already ships an icon system does not end
|
|
19
|
+
* up with two.
|
|
20
|
+
*
|
|
21
|
+
* Only the icons the library itself needs are bundled. To draw others without
|
|
22
|
+
* replacing the whole renderer, add them with `registerIcons()`.
|
|
23
|
+
*
|
|
24
|
+
* Sizing and colour come from classes, exactly as they did before: the class you
|
|
25
|
+
* pass lands on the rendered element, and the SVG fills with `currentColor`, so
|
|
26
|
+
* `text-*` utilities colour icons the same way they colour text.
|
|
27
|
+
*
|
|
28
|
+
* ---
|
|
29
|
+
*
|
|
30
|
+
* Why a render function instead of a `<template>`:
|
|
31
|
+
*
|
|
32
|
+
* `viewBox` is case-sensitive, and Vue's SSR runtime lowercases the keys of a
|
|
33
|
+
* merged prop bag — `ssrRenderAttrs({ viewBox })` emits `viewbox="…"`. Because
|
|
34
|
+
* this `<svg>` also needs a dynamic `class`, a template always goes through that
|
|
35
|
+
* path, and no amount of writing `viewBox` in the template survives it. Browsers
|
|
36
|
+
* paper over it (the HTML parser's foreign-content attribute adjustment maps
|
|
37
|
+
* `viewbox` back to `viewBox`), but the emitted markup is still invalid SVG and
|
|
38
|
+
* breaks anything that parses it as XML or post-processes the HTML.
|
|
39
|
+
*
|
|
40
|
+
* Building the vnode directly keeps the prop object intact, so the attribute is
|
|
41
|
+
* serialised with its real casing on both the server and the client. This is the
|
|
42
|
+
* only component in the library that emits raw SVG, so it is the only one that
|
|
43
|
+
* has to care.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* <UiIcon name="mdi:check" class="w-4 h-4" />
|
|
47
|
+
*
|
|
48
|
+
* @example Inherits the parent's text colour
|
|
49
|
+
* <span class="text-primary-600"><UiIcon name="mdi:alert-circle" class="w-5 h-5" /></span>
|
|
50
|
+
*/
|
|
51
|
+
var _sfc_main = defineComponent({
|
|
52
|
+
name: "UiIcon",
|
|
53
|
+
inheritAttrs: false,
|
|
54
|
+
props: {
|
|
55
|
+
/**
|
|
56
|
+
* Icon name. The bundled set uses the `mdi:` prefix, e.g. `'mdi:check'`.
|
|
57
|
+
* A bare name (`'check'`) is also accepted and treated as MDI.
|
|
58
|
+
*
|
|
59
|
+
* Optional rather than required on purpose. Several components pass an
|
|
60
|
+
* optional icon prop straight through (`<UiIcon :name="icon" />`), so
|
|
61
|
+
* requiring it would emit a Vue warning every time a caller legitimately
|
|
62
|
+
* omitted the icon. An empty or missing name renders the placeholder
|
|
63
|
+
* branch, which reserves the same box without drawing anything.
|
|
64
|
+
*/
|
|
65
|
+
name: {
|
|
66
|
+
type: String,
|
|
67
|
+
default: ""
|
|
68
|
+
} },
|
|
69
|
+
setup(props, { attrs }) {
|
|
70
|
+
const hostComponent = useIconComponent();
|
|
71
|
+
/**
|
|
72
|
+
* Icons are sized by the caller, so the incoming `class` is kept verbatim.
|
|
73
|
+
* A default square is added only when the caller supplied no dimensions,
|
|
74
|
+
* which stops an un-sized icon collapsing to zero height.
|
|
75
|
+
*/
|
|
76
|
+
const sizeClass = computed(() => {
|
|
77
|
+
const external = attrs.class || "";
|
|
78
|
+
return [
|
|
79
|
+
/(^|\s)(w-|h-|size-)/.test(String(external)) ? "" : "w-4 h-4",
|
|
80
|
+
"inline-block shrink-0",
|
|
81
|
+
external
|
|
82
|
+
].filter(Boolean);
|
|
83
|
+
});
|
|
84
|
+
/**
|
|
85
|
+
* Resolved through the registry rather than the generated map directly, so
|
|
86
|
+
* icons added at runtime with `registerIcons()` are found too.
|
|
87
|
+
*/
|
|
88
|
+
const path = computed(() => props.name ? resolveIconPath(props.name) : null);
|
|
89
|
+
/** Forwarded attributes minus `class`, which sizeClass already absorbed. */
|
|
90
|
+
const restAttrs = computed(() => {
|
|
91
|
+
const { class: _class, ...rest } = attrs;
|
|
92
|
+
return rest;
|
|
93
|
+
});
|
|
94
|
+
return () => {
|
|
95
|
+
if (hostComponent) return h(hostComponent, {
|
|
96
|
+
...restAttrs.value,
|
|
97
|
+
name: props.name,
|
|
98
|
+
class: sizeClass.value
|
|
99
|
+
});
|
|
100
|
+
if (path.value) return h("svg", {
|
|
101
|
+
...restAttrs.value,
|
|
102
|
+
class: sizeClass.value,
|
|
103
|
+
viewBox: MDI_VIEW_BOX,
|
|
104
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
105
|
+
fill: "currentColor",
|
|
106
|
+
"aria-hidden": "true",
|
|
107
|
+
focusable: "false"
|
|
108
|
+
}, [h("path", { d: path.value })]);
|
|
109
|
+
return h("span", {
|
|
110
|
+
...restAttrs.value,
|
|
111
|
+
class: sizeClass.value,
|
|
112
|
+
"aria-hidden": "true"
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
//#endregion
|
|
118
|
+
export { _sfc_main as default };
|
|
119
|
+
|
|
120
|
+
//# sourceMappingURL=Icon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Icon.js","names":[],"sources":["../../src/icons/Icon.vue"],"sourcesContent":["<script>\n/**\n * UiIcon — renders an icon by name, either from the bundled Material Design\n * Icons subset or through a host-supplied icon component.\n *\n * This is the seam that lets Numori UI stay framework-agnostic. Numori Notes\n * used `<Icon>` from `@nuxt/icon`, which only exists inside Nuxt; this\n * component gives the same ergonomics with no framework coupling:\n *\n * - **Default** — draws inline SVG from the MDI paths bundled in `mdi.js`.\n * Zero dependencies, zero network requests, SSR-safe.\n * - **Overridden** — if the host provided a component (via the plugin's\n * `icons.component` option or `provideIconComponent`), every icon is\n * delegated to it, so an app that already ships an icon system does not end\n * up with two.\n *\n * Only the icons the library itself needs are bundled. To draw others without\n * replacing the whole renderer, add them with `registerIcons()`.\n *\n * Sizing and colour come from classes, exactly as they did before: the class you\n * pass lands on the rendered element, and the SVG fills with `currentColor`, so\n * `text-*` utilities colour icons the same way they colour text.\n *\n * ---\n *\n * Why a render function instead of a `<template>`:\n *\n * `viewBox` is case-sensitive, and Vue's SSR runtime lowercases the keys of a\n * merged prop bag — `ssrRenderAttrs({ viewBox })` emits `viewbox=\"…\"`. Because\n * this `<svg>` also needs a dynamic `class`, a template always goes through that\n * path, and no amount of writing `viewBox` in the template survives it. Browsers\n * paper over it (the HTML parser's foreign-content attribute adjustment maps\n * `viewbox` back to `viewBox`), but the emitted markup is still invalid SVG and\n * breaks anything that parses it as XML or post-processes the HTML.\n *\n * Building the vnode directly keeps the prop object intact, so the attribute is\n * serialised with its real casing on both the server and the client. This is the\n * only component in the library that emits raw SVG, so it is the only one that\n * has to care.\n *\n * @example\n * <UiIcon name=\"mdi:check\" class=\"w-4 h-4\" />\n *\n * @example Inherits the parent's text colour\n * <span class=\"text-primary-600\"><UiIcon name=\"mdi:alert-circle\" class=\"w-5 h-5\" /></span>\n */\nimport { computed, defineComponent, h } from 'vue'\nimport { MDI_VIEW_BOX } from './mdi.js'\nimport { resolveIconPath } from './registry.js'\nimport { useIconComponent } from './resolver.js'\n\nexport default defineComponent({\n name: 'UiIcon',\n\n // Attributes are placed deliberately: `class` is merged into the sizing\n // logic below, and everything else is forwarded to whichever element wins.\n inheritAttrs: false,\n\n props: {\n /**\n * Icon name. The bundled set uses the `mdi:` prefix, e.g. `'mdi:check'`.\n * A bare name (`'check'`) is also accepted and treated as MDI.\n *\n * Optional rather than required on purpose. Several components pass an\n * optional icon prop straight through (`<UiIcon :name=\"icon\" />`), so\n * requiring it would emit a Vue warning every time a caller legitimately\n * omitted the icon. An empty or missing name renders the placeholder\n * branch, which reserves the same box without drawing anything.\n */\n name: { type: String, default: '' },\n },\n\n setup(props, { attrs }) {\n // Read at setup time: injection is not available inside a render function.\n const hostComponent = useIconComponent()\n\n /**\n * Icons are sized by the caller, so the incoming `class` is kept verbatim.\n * A default square is added only when the caller supplied no dimensions,\n * which stops an un-sized icon collapsing to zero height.\n */\n const sizeClass = computed(() => {\n const external = attrs.class || ''\n const hasSize = /(^|\\s)(w-|h-|size-)/.test(String(external))\n return [hasSize ? '' : 'w-4 h-4', 'inline-block shrink-0', external].filter(Boolean)\n })\n\n /**\n * Resolved through the registry rather than the generated map directly, so\n * icons added at runtime with `registerIcons()` are found too.\n */\n const path = computed(() => (props.name ? resolveIconPath(props.name) : null))\n\n /** Forwarded attributes minus `class`, which sizeClass already absorbed. */\n const restAttrs = computed(() => {\n const { class: _class, ...rest } = attrs\n return rest\n })\n\n return () => {\n // 1. Host-supplied renderer wins, so the app keeps one icon pipeline.\n // A string is allowed and resolves as a globally registered component,\n // which is how the Nuxt module forwards e.g. @nuxt/icon's <Icon>.\n if (hostComponent) {\n return h(hostComponent, {\n ...restAttrs.value,\n name: props.name,\n class: sizeClass.value,\n })\n }\n\n // 2. Bundled inline SVG. `currentColor` makes colour inherit from text.\n if (path.value) {\n return h(\n 'svg',\n {\n ...restAttrs.value,\n class: sizeClass.value,\n viewBox: MDI_VIEW_BOX,\n xmlns: 'http://www.w3.org/2000/svg',\n fill: 'currentColor',\n 'aria-hidden': 'true',\n focusable: 'false',\n },\n [h('path', { d: path.value })],\n )\n }\n\n // 3. Unknown name: hold the same box so layout does not shift, and stay\n // invisible rather than rendering a broken glyph.\n return h('span', {\n ...restAttrs.value,\n class: sizeClass.value,\n 'aria-hidden': 'true',\n })\n }\n },\n})\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmDA,IAAK,YAAa,gBAAa;CAC7B,MAAM;CAIN,cAAc;CAEd,OAAO;;;;;;;;;;;AAWL,MAAM;EAAE,MAAM;EAAQ,SAAS;CAAG,EACpC;CAEA,MAAM,OAAO,EAAE,SAAS;EAEtB,MAAM,gBAAgB,iBAAiB;;;;;;EAOvC,MAAM,YAAY,eAAe;GAC/B,MAAM,WAAW,MAAM,SAAS;GAEhC,OAAO;IADS,sBAAsB,KAAK,OAAO,QAAQ,CAC5C,IAAI,KAAK;IAAW;IAAyB;GAAQ,CAAC,CAAC,OAAO,OAAO;EACrF,CAAC;;;;;EAMD,MAAM,OAAO,eAAgB,MAAM,OAAO,gBAAgB,MAAM,IAAI,IAAI,IAAK;;EAG7E,MAAM,YAAY,eAAe;GAC/B,MAAM,EAAE,OAAO,QAAQ,GAAG,SAAS;GACnC,OAAO;EACT,CAAC;EAED,aAAa;GAIX,IAAI,eACF,OAAO,EAAE,eAAe;IACtB,GAAG,UAAU;IACb,MAAM,MAAM;IACZ,OAAO,UAAU;GACnB,CAAC;GAIH,IAAI,KAAK,OACP,OAAO,EACL,OACA;IACE,GAAG,UAAU;IACb,OAAO,UAAU;IACjB,SAAS;IACT,OAAO;IACP,MAAM;IACN,eAAe;IACf,WAAW;GACb,GACA,CAAC,EAAE,QAAQ,EAAE,GAAG,KAAK,MAAM,CAAC,CAAC,CAC/B;GAKF,OAAO,EAAE,QAAQ;IACf,GAAG,UAAU;IACb,OAAO,UAAU;IACjB,eAAe;GACjB,CAAC;EACH;CACF;AACF,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
//#region src/icons/mdi.js
|
|
2
|
+
/**
|
|
3
|
+
* GENERATED FILE — do not edit by hand.
|
|
4
|
+
* Regenerate with: npm run icons
|
|
5
|
+
*
|
|
6
|
+
* Inline path data for the Material Design Icons used by Numori UI, keyed by
|
|
7
|
+
* icon name without the `mdi:` prefix. All paths are drawn on a 24x24 grid
|
|
8
|
+
* and filled with `currentColor`.
|
|
9
|
+
*
|
|
10
|
+
* Material Design Icons — https://pictogrammers.com/library/mdi/
|
|
11
|
+
* Copyright (c) Austin Andrews and contributors, licensed under Apache-2.0:
|
|
12
|
+
* https://github.com/Templarian/MaterialDesign/blob/master/LICENSE
|
|
13
|
+
* Icon data sourced from @iconify-json/mdi.
|
|
14
|
+
*/
|
|
15
|
+
/** Shared viewBox for every icon in this set. */
|
|
16
|
+
var MDI_VIEW_BOX = "0 0 24 24";
|
|
17
|
+
/** @type {Record<string, string>} */
|
|
18
|
+
var mdiPaths = {
|
|
19
|
+
"account": "M12 4a4 4 0 0 1 4 4a4 4 0 0 1-4 4a4 4 0 0 1-4-4a4 4 0 0 1 4-4m0 10c4.42 0 8 1.79 8 4v2H4v-2c0-2.21 3.58-4 8-4",
|
|
20
|
+
"account-group": "M12 5.5A3.5 3.5 0 0 1 15.5 9a3.5 3.5 0 0 1-3.5 3.5A3.5 3.5 0 0 1 8.5 9A3.5 3.5 0 0 1 12 5.5M5 8c.56 0 1.08.15 1.53.42c-.15 1.43.27 2.85 1.13 3.96C7.16 13.34 6.16 14 5 14a3 3 0 0 1-3-3a3 3 0 0 1 3-3m14 0a3 3 0 0 1 3 3a3 3 0 0 1-3 3c-1.16 0-2.16-.66-2.66-1.62a5.54 5.54 0 0 0 1.13-3.96c.45-.27.97-.42 1.53-.42M5.5 18.25c0-2.07 2.91-3.75 6.5-3.75s6.5 1.68 6.5 3.75V20h-13zM0 20v-1.5c0-1.39 1.89-2.56 4.45-2.9c-.59.68-.95 1.62-.95 2.65V20zm24 0h-3.5v-1.75c0-1.03-.36-1.97-.95-2.65c2.56.34 4.45 1.51 4.45 2.9z",
|
|
21
|
+
"alert-circle": "M13 13h-2V7h2m0 10h-2v-2h2M12 2A10 10 0 0 0 2 12a10 10 0 0 0 10 10a10 10 0 0 0 10-10A10 10 0 0 0 12 2",
|
|
22
|
+
"alert-outline": "M12 2L1 21h22M12 6l7.53 13H4.47M11 10v4h2v-4m-2 6v2h2v-2",
|
|
23
|
+
"backspace-outline": "M19 15.59L17.59 17L14 13.41L10.41 17L9 15.59L12.59 12L9 8.41L10.41 7L14 10.59L17.59 7L19 8.41L15.41 12zM22 3a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H7c-.69 0-1.23-.36-1.59-.89L0 12l5.41-8.12C5.77 3.35 6.31 3 7 3zm0 2H7l-4.72 7L7 19h15z",
|
|
24
|
+
"check": "M21 7L9 19l-5.5-5.5l1.41-1.41L9 16.17L19.59 5.59z",
|
|
25
|
+
"check-circle": "M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10s10-4.5 10-10S17.5 2 12 2m-2 15l-5-5l1.41-1.41L10 14.17l7.59-7.59L19 8z",
|
|
26
|
+
"chevron-down": "M7.41 8.58L12 13.17l4.59-4.59L18 10l-6 6l-6-6z",
|
|
27
|
+
"chevron-right": "M8.59 16.58L13.17 12L8.59 7.41L10 6l6 6l-6 6z",
|
|
28
|
+
"chevron-up": "M7.41 15.41L12 10.83l4.59 4.58L18 14l-6-6l-6 6z",
|
|
29
|
+
"close": "M19 6.41L17.59 5L12 10.59L6.41 5L5 6.41L10.59 12L5 17.59L6.41 19L12 13.41L17.59 19L19 17.59L13.41 12z",
|
|
30
|
+
"close-circle": "M12 2c5.53 0 10 4.47 10 10s-4.47 10-10 10S2 17.53 2 12S6.47 2 12 2m3.59 5L12 10.59L8.41 7L7 8.41L10.59 12L7 15.59L8.41 17L12 13.41L15.59 17L17 15.59L13.41 12L17 8.41z",
|
|
31
|
+
"delete": "M19 4h-3.5l-1-1h-5l-1 1H5v2h14M6 19a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V7H6z",
|
|
32
|
+
"dots-vertical": "M12 16a2 2 0 0 1 2 2a2 2 0 0 1-2 2a2 2 0 0 1-2-2a2 2 0 0 1 2-2m0-6a2 2 0 0 1 2 2a2 2 0 0 1-2 2a2 2 0 0 1-2-2a2 2 0 0 1 2-2m0-6a2 2 0 0 1 2 2a2 2 0 0 1-2 2a2 2 0 0 1-2-2a2 2 0 0 1 2-2",
|
|
33
|
+
"email": "m20 8l-8 5l-8-5V6l8 5l8-5m0-2H4c-1.11 0-2 .89-2 2v12a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2",
|
|
34
|
+
"eraser": "m16.24 3.56l4.95 4.94c.78.79.78 2.05 0 2.84L12 20.53a4.01 4.01 0 0 1-5.66 0L2.81 17c-.78-.79-.78-2.05 0-2.84l10.6-10.6c.79-.78 2.05-.78 2.83 0M4.22 15.58l3.54 3.53c.78.79 2.04.79 2.83 0l3.53-3.53l-4.95-4.95z",
|
|
35
|
+
"eye-off-outline": "M2 5.27L3.28 4L20 20.72L18.73 22l-3.08-3.08c-1.15.38-2.37.58-3.65.58c-5 0-9.27-3.11-11-7.5c.69-1.76 1.79-3.31 3.19-4.54zM12 9a3 3 0 0 1 3 3a3 3 0 0 1-.17 1L11 9.17A3 3 0 0 1 12 9m0-4.5c5 0 9.27 3.11 11 7.5a11.8 11.8 0 0 1-4 5.19l-1.42-1.43A9.86 9.86 0 0 0 20.82 12A9.82 9.82 0 0 0 12 6.5c-1.09 0-2.16.18-3.16.5L7.3 5.47c1.44-.62 3.03-.97 4.7-.97M3.18 12A9.82 9.82 0 0 0 12 17.5c.69 0 1.37-.07 2-.21L11.72 15A3.064 3.064 0 0 1 9 12.28L5.6 8.87c-.99.85-1.82 1.91-2.42 3.13",
|
|
36
|
+
"eye-outline": "M12 9a3 3 0 0 1 3 3a3 3 0 0 1-3 3a3 3 0 0 1-3-3a3 3 0 0 1 3-3m0-4.5c5 0 9.27 3.11 11 7.5c-1.73 4.39-6 7.5-11 7.5S2.73 16.39 1 12c1.73-4.39 6-7.5 11-7.5M3.18 12a9.821 9.821 0 0 0 17.64 0a9.821 9.821 0 0 0-17.64 0",
|
|
37
|
+
"format-bold": "M13.5 15.5H10v-3h3.5A1.5 1.5 0 0 1 15 14a1.5 1.5 0 0 1-1.5 1.5m-3.5-9h3A1.5 1.5 0 0 1 14.5 8A1.5 1.5 0 0 1 13 9.5h-3m5.6 1.29c.97-.68 1.65-1.79 1.65-2.79c0-2.26-1.75-4-4-4H7v14h7.04c2.1 0 3.71-1.7 3.71-3.79c0-1.52-.86-2.82-2.15-3.42",
|
|
38
|
+
"format-italic": "M10 4v3h2.21l-3.42 8H6v3h8v-3h-2.21l3.42-8H18V4z",
|
|
39
|
+
"format-text": "m18.5 4l1.16 4.35l-.96.26c-.45-.87-.91-1.74-1.44-2.18C16.73 6 16.11 6 15.5 6H13v10.5c0 .5 0 1 .33 1.25c.34.25 1 .25 1.67.25v1H9v-1c.67 0 1.33 0 1.67-.25c.33-.25.33-.75.33-1.25V6H8.5c-.61 0-1.23 0-1.76.43c-.53.44-.99 1.31-1.44 2.18l-.96-.26L5.5 4z",
|
|
40
|
+
"information": "M13 9h-2V7h2m0 10h-2v-6h2m-1-9A10 10 0 0 0 2 12a10 10 0 0 0 10 10a10 10 0 0 0 10-10A10 10 0 0 0 12 2",
|
|
41
|
+
"loading": "M12 4V2A10 10 0 0 0 2 12h2a8 8 0 0 1 8-8",
|
|
42
|
+
"lock": "M12 17a2 2 0 0 0 2-2a2 2 0 0 0-2-2a2 2 0 0 0-2 2a2 2 0 0 0 2 2m6-9a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V10a2 2 0 0 1 2-2h1V6a5 5 0 0 1 5-5a5 5 0 0 1 5 5v2zm-6-5a3 3 0 0 0-3 3v2h6V6a3 3 0 0 0-3-3",
|
|
43
|
+
"logout": "m17 7l-1.41 1.41L18.17 11H8v2h10.17l-2.58 2.58L17 17l5-5M4 5h8V3H4c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h8v-2H4z",
|
|
44
|
+
"minus": "M19 13H5v-2h14z",
|
|
45
|
+
"pen": "M20.71 7.04c-.34.34-.67.67-.68 1c-.03.32.31.65.63.96c.48.5.95.95.93 1.44s-.53 1-1.04 1.5l-4.13 4.14L15 14.66l4.25-4.24l-.96-.96l-1.42 1.41l-3.75-3.75l3.84-3.83c.39-.39 1.04-.39 1.41 0l2.34 2.34c.39.37.39 1.02 0 1.41M3 17.25l9.56-9.57l3.75 3.75L6.75 21H3z",
|
|
46
|
+
"pencil": "M20.71 7.04c.39-.39.39-1.04 0-1.41l-2.34-2.34c-.37-.39-1.02-.39-1.41 0l-1.84 1.83l3.75 3.75M3 17.25V21h3.75L17.81 9.93l-3.75-3.75z",
|
|
47
|
+
"plus": "M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6z",
|
|
48
|
+
"share": "m21 12l-7-7v4C7 10 4 15 3 20c2.5-3.5 6-5.1 11-5.1V19z",
|
|
49
|
+
"translate": "m12.87 15.07l-2.54-2.51l.03-.03A17.5 17.5 0 0 0 14.07 6H17V4h-7V2H8v2H1v2h11.17C11.5 7.92 10.44 9.75 9 11.35C8.07 10.32 7.3 9.19 6.69 8h-2c.73 1.63 1.73 3.17 2.98 4.56l-5.09 5.02L4 19l5-5l3.11 3.11zM18.5 10h-2L12 22h2l1.12-3h4.75L21 22h2zm-2.62 7l1.62-4.33L19.12 17z",
|
|
50
|
+
"trash-can": "M9 3v1H4v2h1v13a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V6h1V4h-5V3zm0 5h2v9H9zm4 0h2v9h-2z",
|
|
51
|
+
"trash-can-outline": "M9 3v1H4v2h1v13a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V6h1V4h-5V3zM7 6h10v13H7zm2 2v9h2V8zm4 0v9h2V8z",
|
|
52
|
+
"view-grid": "M3 11h8V3H3m0 18h8v-8H3m10 8h8v-8h-8m0-10v8h8V3",
|
|
53
|
+
"view-list": "M9 5v4h12V5M9 19h12v-4H9m0-1h12v-4H9M4 9h4V5H4m0 14h4v-4H4m0-1h4v-4H4z",
|
|
54
|
+
"wrap": "M21 5H3v2h18zM3 19h7v-2H3zm0-6h15c1 0 2 .43 2 2s-1 2-2 2h-2v-2l-4 3l4 3v-2h2c2.95 0 4-1.27 4-4c0-2.72-1-4-4-4H3z"
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Icon names available in the bundled subset.
|
|
58
|
+
*
|
|
59
|
+
* Annotated pure so bundlers can drop it. Without the annotation this
|
|
60
|
+
* top-level `Object.keys` call is treated as a possible side effect, which
|
|
61
|
+
* keeps `mdiPaths` reachable and forces every icon into any bundle that
|
|
62
|
+
* touches this package — even one importing only `UiKbd`, which draws no
|
|
63
|
+
* icons.
|
|
64
|
+
*/
|
|
65
|
+
var mdiIconNames = /*#__PURE__*/ Object.keys(mdiPaths);
|
|
66
|
+
//#endregion
|
|
67
|
+
export { MDI_VIEW_BOX, mdiIconNames, mdiPaths };
|
|
68
|
+
|
|
69
|
+
//# sourceMappingURL=mdi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mdi.js","names":[],"sources":["../../src/icons/mdi.js"],"sourcesContent":["/**\n * GENERATED FILE — do not edit by hand.\n * Regenerate with: npm run icons\n *\n * Inline path data for the Material Design Icons used by Numori UI, keyed by\n * icon name without the `mdi:` prefix. All paths are drawn on a 24x24 grid\n * and filled with `currentColor`.\n *\n * Material Design Icons — https://pictogrammers.com/library/mdi/\n * Copyright (c) Austin Andrews and contributors, licensed under Apache-2.0:\n * https://github.com/Templarian/MaterialDesign/blob/master/LICENSE\n * Icon data sourced from @iconify-json/mdi.\n */\n\n/** Shared viewBox for every icon in this set. */\nexport const MDI_VIEW_BOX = '0 0 24 24'\n\n/** @type {Record<string, string>} */\nexport const mdiPaths = {\n 'account': \"M12 4a4 4 0 0 1 4 4a4 4 0 0 1-4 4a4 4 0 0 1-4-4a4 4 0 0 1 4-4m0 10c4.42 0 8 1.79 8 4v2H4v-2c0-2.21 3.58-4 8-4\",\n 'account-group': \"M12 5.5A3.5 3.5 0 0 1 15.5 9a3.5 3.5 0 0 1-3.5 3.5A3.5 3.5 0 0 1 8.5 9A3.5 3.5 0 0 1 12 5.5M5 8c.56 0 1.08.15 1.53.42c-.15 1.43.27 2.85 1.13 3.96C7.16 13.34 6.16 14 5 14a3 3 0 0 1-3-3a3 3 0 0 1 3-3m14 0a3 3 0 0 1 3 3a3 3 0 0 1-3 3c-1.16 0-2.16-.66-2.66-1.62a5.54 5.54 0 0 0 1.13-3.96c.45-.27.97-.42 1.53-.42M5.5 18.25c0-2.07 2.91-3.75 6.5-3.75s6.5 1.68 6.5 3.75V20h-13zM0 20v-1.5c0-1.39 1.89-2.56 4.45-2.9c-.59.68-.95 1.62-.95 2.65V20zm24 0h-3.5v-1.75c0-1.03-.36-1.97-.95-2.65c2.56.34 4.45 1.51 4.45 2.9z\",\n 'alert-circle': \"M13 13h-2V7h2m0 10h-2v-2h2M12 2A10 10 0 0 0 2 12a10 10 0 0 0 10 10a10 10 0 0 0 10-10A10 10 0 0 0 12 2\",\n 'alert-outline': \"M12 2L1 21h22M12 6l7.53 13H4.47M11 10v4h2v-4m-2 6v2h2v-2\",\n 'backspace-outline': \"M19 15.59L17.59 17L14 13.41L10.41 17L9 15.59L12.59 12L9 8.41L10.41 7L14 10.59L17.59 7L19 8.41L15.41 12zM22 3a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H7c-.69 0-1.23-.36-1.59-.89L0 12l5.41-8.12C5.77 3.35 6.31 3 7 3zm0 2H7l-4.72 7L7 19h15z\",\n 'check': \"M21 7L9 19l-5.5-5.5l1.41-1.41L9 16.17L19.59 5.59z\",\n 'check-circle': \"M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10s10-4.5 10-10S17.5 2 12 2m-2 15l-5-5l1.41-1.41L10 14.17l7.59-7.59L19 8z\",\n 'chevron-down': \"M7.41 8.58L12 13.17l4.59-4.59L18 10l-6 6l-6-6z\",\n 'chevron-right': \"M8.59 16.58L13.17 12L8.59 7.41L10 6l6 6l-6 6z\",\n 'chevron-up': \"M7.41 15.41L12 10.83l4.59 4.58L18 14l-6-6l-6 6z\",\n 'close': \"M19 6.41L17.59 5L12 10.59L6.41 5L5 6.41L10.59 12L5 17.59L6.41 19L12 13.41L17.59 19L19 17.59L13.41 12z\",\n 'close-circle': \"M12 2c5.53 0 10 4.47 10 10s-4.47 10-10 10S2 17.53 2 12S6.47 2 12 2m3.59 5L12 10.59L8.41 7L7 8.41L10.59 12L7 15.59L8.41 17L12 13.41L15.59 17L17 15.59L13.41 12L17 8.41z\",\n 'delete': \"M19 4h-3.5l-1-1h-5l-1 1H5v2h14M6 19a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V7H6z\",\n 'dots-vertical': \"M12 16a2 2 0 0 1 2 2a2 2 0 0 1-2 2a2 2 0 0 1-2-2a2 2 0 0 1 2-2m0-6a2 2 0 0 1 2 2a2 2 0 0 1-2 2a2 2 0 0 1-2-2a2 2 0 0 1 2-2m0-6a2 2 0 0 1 2 2a2 2 0 0 1-2 2a2 2 0 0 1-2-2a2 2 0 0 1 2-2\",\n 'email': \"m20 8l-8 5l-8-5V6l8 5l8-5m0-2H4c-1.11 0-2 .89-2 2v12a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2\",\n 'eraser': \"m16.24 3.56l4.95 4.94c.78.79.78 2.05 0 2.84L12 20.53a4.01 4.01 0 0 1-5.66 0L2.81 17c-.78-.79-.78-2.05 0-2.84l10.6-10.6c.79-.78 2.05-.78 2.83 0M4.22 15.58l3.54 3.53c.78.79 2.04.79 2.83 0l3.53-3.53l-4.95-4.95z\",\n 'eye-off-outline': \"M2 5.27L3.28 4L20 20.72L18.73 22l-3.08-3.08c-1.15.38-2.37.58-3.65.58c-5 0-9.27-3.11-11-7.5c.69-1.76 1.79-3.31 3.19-4.54zM12 9a3 3 0 0 1 3 3a3 3 0 0 1-.17 1L11 9.17A3 3 0 0 1 12 9m0-4.5c5 0 9.27 3.11 11 7.5a11.8 11.8 0 0 1-4 5.19l-1.42-1.43A9.86 9.86 0 0 0 20.82 12A9.82 9.82 0 0 0 12 6.5c-1.09 0-2.16.18-3.16.5L7.3 5.47c1.44-.62 3.03-.97 4.7-.97M3.18 12A9.82 9.82 0 0 0 12 17.5c.69 0 1.37-.07 2-.21L11.72 15A3.064 3.064 0 0 1 9 12.28L5.6 8.87c-.99.85-1.82 1.91-2.42 3.13\",\n 'eye-outline': \"M12 9a3 3 0 0 1 3 3a3 3 0 0 1-3 3a3 3 0 0 1-3-3a3 3 0 0 1 3-3m0-4.5c5 0 9.27 3.11 11 7.5c-1.73 4.39-6 7.5-11 7.5S2.73 16.39 1 12c1.73-4.39 6-7.5 11-7.5M3.18 12a9.821 9.821 0 0 0 17.64 0a9.821 9.821 0 0 0-17.64 0\",\n 'format-bold': \"M13.5 15.5H10v-3h3.5A1.5 1.5 0 0 1 15 14a1.5 1.5 0 0 1-1.5 1.5m-3.5-9h3A1.5 1.5 0 0 1 14.5 8A1.5 1.5 0 0 1 13 9.5h-3m5.6 1.29c.97-.68 1.65-1.79 1.65-2.79c0-2.26-1.75-4-4-4H7v14h7.04c2.1 0 3.71-1.7 3.71-3.79c0-1.52-.86-2.82-2.15-3.42\",\n 'format-italic': \"M10 4v3h2.21l-3.42 8H6v3h8v-3h-2.21l3.42-8H18V4z\",\n 'format-text': \"m18.5 4l1.16 4.35l-.96.26c-.45-.87-.91-1.74-1.44-2.18C16.73 6 16.11 6 15.5 6H13v10.5c0 .5 0 1 .33 1.25c.34.25 1 .25 1.67.25v1H9v-1c.67 0 1.33 0 1.67-.25c.33-.25.33-.75.33-1.25V6H8.5c-.61 0-1.23 0-1.76.43c-.53.44-.99 1.31-1.44 2.18l-.96-.26L5.5 4z\",\n 'information': \"M13 9h-2V7h2m0 10h-2v-6h2m-1-9A10 10 0 0 0 2 12a10 10 0 0 0 10 10a10 10 0 0 0 10-10A10 10 0 0 0 12 2\",\n 'loading': \"M12 4V2A10 10 0 0 0 2 12h2a8 8 0 0 1 8-8\",\n 'lock': \"M12 17a2 2 0 0 0 2-2a2 2 0 0 0-2-2a2 2 0 0 0-2 2a2 2 0 0 0 2 2m6-9a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V10a2 2 0 0 1 2-2h1V6a5 5 0 0 1 5-5a5 5 0 0 1 5 5v2zm-6-5a3 3 0 0 0-3 3v2h6V6a3 3 0 0 0-3-3\",\n 'logout': \"m17 7l-1.41 1.41L18.17 11H8v2h10.17l-2.58 2.58L17 17l5-5M4 5h8V3H4c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h8v-2H4z\",\n 'minus': \"M19 13H5v-2h14z\",\n 'pen': \"M20.71 7.04c-.34.34-.67.67-.68 1c-.03.32.31.65.63.96c.48.5.95.95.93 1.44s-.53 1-1.04 1.5l-4.13 4.14L15 14.66l4.25-4.24l-.96-.96l-1.42 1.41l-3.75-3.75l3.84-3.83c.39-.39 1.04-.39 1.41 0l2.34 2.34c.39.37.39 1.02 0 1.41M3 17.25l9.56-9.57l3.75 3.75L6.75 21H3z\",\n 'pencil': \"M20.71 7.04c.39-.39.39-1.04 0-1.41l-2.34-2.34c-.37-.39-1.02-.39-1.41 0l-1.84 1.83l3.75 3.75M3 17.25V21h3.75L17.81 9.93l-3.75-3.75z\",\n 'plus': \"M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6z\",\n 'share': \"m21 12l-7-7v4C7 10 4 15 3 20c2.5-3.5 6-5.1 11-5.1V19z\",\n 'translate': \"m12.87 15.07l-2.54-2.51l.03-.03A17.5 17.5 0 0 0 14.07 6H17V4h-7V2H8v2H1v2h11.17C11.5 7.92 10.44 9.75 9 11.35C8.07 10.32 7.3 9.19 6.69 8h-2c.73 1.63 1.73 3.17 2.98 4.56l-5.09 5.02L4 19l5-5l3.11 3.11zM18.5 10h-2L12 22h2l1.12-3h4.75L21 22h2zm-2.62 7l1.62-4.33L19.12 17z\",\n 'trash-can': \"M9 3v1H4v2h1v13a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V6h1V4h-5V3zm0 5h2v9H9zm4 0h2v9h-2z\",\n 'trash-can-outline': \"M9 3v1H4v2h1v13a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V6h1V4h-5V3zM7 6h10v13H7zm2 2v9h2V8zm4 0v9h2V8z\",\n 'view-grid': \"M3 11h8V3H3m0 18h8v-8H3m10 8h8v-8h-8m0-10v8h8V3\",\n 'view-list': \"M9 5v4h12V5M9 19h12v-4H9m0-1h12v-4H9M4 9h4V5H4m0 14h4v-4H4m0-1h4v-4H4z\",\n 'wrap': \"M21 5H3v2h18zM3 19h7v-2H3zm0-6h15c1 0 2 .43 2 2s-1 2-2 2h-2v-2l-4 3l4 3v-2h2c2.95 0 4-1.27 4-4c0-2.72-1-4-4-4H3z\",\n}\n\n/**\n * Icon names available in the bundled subset.\n *\n * Annotated pure so bundlers can drop it. Without the annotation this\n * top-level `Object.keys` call is treated as a possible side effect, which\n * keeps `mdiPaths` reachable and forces every icon into any bundle that\n * touches this package — even one importing only `UiKbd`, which draws no\n * icons.\n */\nexport const mdiIconNames = /*#__PURE__*/ Object.keys(mdiPaths)\n"],"mappings":";;;;;;;;;;;;;;;AAeA,IAAa,eAAe;;AAG5B,IAAa,WAAW;CACtB,WAAW;CACX,iBAAiB;CACjB,gBAAgB;CAChB,iBAAiB;CACjB,qBAAqB;CACrB,SAAS;CACT,gBAAgB;CAChB,gBAAgB;CAChB,iBAAiB;CACjB,cAAc;CACd,SAAS;CACT,gBAAgB;CAChB,UAAU;CACV,iBAAiB;CACjB,SAAS;CACT,UAAU;CACV,mBAAmB;CACnB,eAAe;CACf,eAAe;CACf,iBAAiB;CACjB,eAAe;CACf,eAAe;CACf,WAAW;CACX,QAAQ;CACR,UAAU;CACV,SAAS;CACT,OAAO;CACP,UAAU;CACV,QAAQ;CACR,SAAS;CACT,aAAa;CACb,aAAa;CACb,qBAAqB;CACrB,aAAa;CACb,aAAa;CACb,QAAQ;AACV;;;;;;;;;;AAWA,IAAa,eAA6B,qBAAO,KAAK,QAAQ"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { mdiPaths } from "./mdi.js";
|
|
2
|
+
import { shallowRef } from "vue";
|
|
3
|
+
//#region src/icons/registry.js
|
|
4
|
+
/**
|
|
5
|
+
* Runtime icon registry.
|
|
6
|
+
*
|
|
7
|
+
* Numori UI bundles only the Material Design Icons its own components need,
|
|
8
|
+
* which keeps the package small but means an app drawing `<UiIcon>` with some
|
|
9
|
+
* other icon would find nothing. Two escape hatches exist:
|
|
10
|
+
*
|
|
11
|
+
* 1. `registerIcons()` — add path data for extra icons, so `<UiIcon>` can draw
|
|
12
|
+
* them alongside the bundled set. Good for a handful of additions.
|
|
13
|
+
* 2. A host icon component (see `resolver.js`) — hands rendering over entirely.
|
|
14
|
+
* Better when the app already has a full icon pipeline.
|
|
15
|
+
*
|
|
16
|
+
* The registry is a `shallowRef` holding an immutable object rather than a
|
|
17
|
+
* plain mutable one, so registering icons after mount invalidates the
|
|
18
|
+
* `computed` in `Icon.vue` and already-rendered icons appear.
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* The `/*#__PURE__*\/` annotation matters for tree-shaking. This is a top-level
|
|
22
|
+
* function call, which a bundler must assume has side effects and therefore
|
|
23
|
+
* cannot remove — and because its argument spreads `mdiPaths`, keeping it alive
|
|
24
|
+
* also keeps every bundled icon path alive. That put the whole icon set into any
|
|
25
|
+
* bundle importing any component, even `UiKbd`, which draws no icons at all.
|
|
26
|
+
*
|
|
27
|
+
* Marking it pure lets the bundler drop the registry when nothing references it,
|
|
28
|
+
* and `mdiPaths` then falls away with it.
|
|
29
|
+
*
|
|
30
|
+
* @type {import('vue').ShallowRef<Record<string, string>>}
|
|
31
|
+
*/
|
|
32
|
+
var iconRegistry = /*#__PURE__*/ shallowRef({ ...mdiPaths });
|
|
33
|
+
/**
|
|
34
|
+
* Add icons to the registry, or override bundled ones.
|
|
35
|
+
*
|
|
36
|
+
* Keys may be bare (`'rocket'`) or prefixed (`'mdi:rocket'`) — the prefix is
|
|
37
|
+
* stripped, matching how `<UiIcon>` looks names up. Values are the `d`
|
|
38
|
+
* attribute of a path drawn on a 24x24 grid.
|
|
39
|
+
*
|
|
40
|
+
* @param {Record<string, string>} icons Map of icon name to SVG path data.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* import { registerIcons } from 'numori-ui'
|
|
44
|
+
* registerIcons({ rocket: 'M12 2c...' })
|
|
45
|
+
* // <UiIcon name="mdi:rocket" class="w-5 h-5" />
|
|
46
|
+
*/
|
|
47
|
+
function registerIcons(icons) {
|
|
48
|
+
const next = { ...iconRegistry.value };
|
|
49
|
+
for (const [name, path] of Object.entries(icons)) next[name.replace(/^[a-z0-9]+:/i, "")] = path;
|
|
50
|
+
iconRegistry.value = next;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Look up path data for an icon name.
|
|
54
|
+
* @param {string} name Icon name, with or without a set prefix.
|
|
55
|
+
* @returns {string | null}
|
|
56
|
+
*/
|
|
57
|
+
function resolveIconPath(name) {
|
|
58
|
+
return iconRegistry.value[String(name).replace(/^[a-z0-9]+:/i, "")] || null;
|
|
59
|
+
}
|
|
60
|
+
//#endregion
|
|
61
|
+
export { iconRegistry, registerIcons, resolveIconPath };
|
|
62
|
+
|
|
63
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","names":[],"sources":["../../src/icons/registry.js"],"sourcesContent":["import { shallowRef } from 'vue'\nimport { mdiPaths } from './mdi.js'\n\n/**\n * Runtime icon registry.\n *\n * Numori UI bundles only the Material Design Icons its own components need,\n * which keeps the package small but means an app drawing `<UiIcon>` with some\n * other icon would find nothing. Two escape hatches exist:\n *\n * 1. `registerIcons()` — add path data for extra icons, so `<UiIcon>` can draw\n * them alongside the bundled set. Good for a handful of additions.\n * 2. A host icon component (see `resolver.js`) — hands rendering over entirely.\n * Better when the app already has a full icon pipeline.\n *\n * The registry is a `shallowRef` holding an immutable object rather than a\n * plain mutable one, so registering icons after mount invalidates the\n * `computed` in `Icon.vue` and already-rendered icons appear.\n */\n\n/**\n * The `/*#__PURE__*\\/` annotation matters for tree-shaking. This is a top-level\n * function call, which a bundler must assume has side effects and therefore\n * cannot remove — and because its argument spreads `mdiPaths`, keeping it alive\n * also keeps every bundled icon path alive. That put the whole icon set into any\n * bundle importing any component, even `UiKbd`, which draws no icons at all.\n *\n * Marking it pure lets the bundler drop the registry when nothing references it,\n * and `mdiPaths` then falls away with it.\n *\n * @type {import('vue').ShallowRef<Record<string, string>>}\n */\nexport const iconRegistry = /*#__PURE__*/ shallowRef({ ...mdiPaths })\n\n/**\n * Add icons to the registry, or override bundled ones.\n *\n * Keys may be bare (`'rocket'`) or prefixed (`'mdi:rocket'`) — the prefix is\n * stripped, matching how `<UiIcon>` looks names up. Values are the `d`\n * attribute of a path drawn on a 24x24 grid.\n *\n * @param {Record<string, string>} icons Map of icon name to SVG path data.\n *\n * @example\n * import { registerIcons } from 'numori-ui'\n * registerIcons({ rocket: 'M12 2c...' })\n * // <UiIcon name=\"mdi:rocket\" class=\"w-5 h-5\" />\n */\nexport function registerIcons(icons) {\n const next = { ...iconRegistry.value }\n for (const [name, path] of Object.entries(icons)) {\n next[name.replace(/^[a-z0-9]+:/i, '')] = path\n }\n iconRegistry.value = next\n}\n\n/**\n * Look up path data for an icon name.\n * @param {string} name Icon name, with or without a set prefix.\n * @returns {string | null}\n */\nexport function resolveIconPath(name) {\n return iconRegistry.value[String(name).replace(/^[a-z0-9]+:/i, '')] || null\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,IAAa,eAA6B,yBAAW,EAAE,GAAG,SAAS,CAAC;;;;;;;;;;;;;;;AAgBpE,SAAgB,cAAc,OAAO;CACnC,MAAM,OAAO,EAAE,GAAG,aAAa,MAAM;CACrC,KAAK,MAAM,CAAC,MAAM,SAAS,OAAO,QAAQ,KAAK,GAC7C,KAAK,KAAK,QAAQ,gBAAgB,EAAE,KAAK;CAE3C,aAAa,QAAQ;AACvB;;;;;;AAOA,SAAgB,gBAAgB,MAAM;CACpC,OAAO,aAAa,MAAM,OAAO,IAAI,CAAC,CAAC,QAAQ,gBAAgB,EAAE,MAAM;AACzE"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { inject, provide } from "vue";
|
|
2
|
+
//#region src/icons/resolver.js
|
|
3
|
+
/**
|
|
4
|
+
* Icon resolution for Numori UI.
|
|
5
|
+
*
|
|
6
|
+
* The components render icons through `<UiIcon name="mdi:check" />`. By default
|
|
7
|
+
* that resolves against the small set of Material Design Icons bundled with the
|
|
8
|
+
* package (see `mdi.js`), drawn as inline SVG — no icon runtime, no network
|
|
9
|
+
* request, works under SSR and inside a Capacitor `file://` shell.
|
|
10
|
+
*
|
|
11
|
+
* Hosts that already have an icon system (Nuxt's `<Icon>` from `@nuxt/icon`,
|
|
12
|
+
* `unplugin-icons`, a sprite sheet, ...) can take over rendering entirely by
|
|
13
|
+
* providing their own component, so the app ships one icon pipeline instead of
|
|
14
|
+
* two. Anything Numori UI asks for is then requested from the host by name.
|
|
15
|
+
*/
|
|
16
|
+
/** Injection key for a host-supplied icon component. */
|
|
17
|
+
var ICON_COMPONENT_KEY = Symbol("numori-ui:icon-component");
|
|
18
|
+
/**
|
|
19
|
+
* Provide a custom icon component for every Numori UI icon below this point in
|
|
20
|
+
* the tree. Call from a parent component's setup, or use the `icons.component`
|
|
21
|
+
* option on the Vue plugin / Nuxt module to apply it app-wide.
|
|
22
|
+
*
|
|
23
|
+
* The component receives a single `name` prop (e.g. `'mdi:check'`) plus any
|
|
24
|
+
* `class` the calling component applied for sizing and colour, so it must
|
|
25
|
+
* accept and forward `class` to its root element.
|
|
26
|
+
*
|
|
27
|
+
* @param {import('vue').Component | string} component
|
|
28
|
+
* Component (or globally registered component name) to render icons with.
|
|
29
|
+
*
|
|
30
|
+
* @example Delegate to @nuxt/icon inside a Nuxt app
|
|
31
|
+
* // plugins/numori-ui-icons.js
|
|
32
|
+
* import { provideIconComponent } from 'numori-ui'
|
|
33
|
+
* // in a parent component's setup():
|
|
34
|
+
* provideIconComponent(resolveComponent('Icon'))
|
|
35
|
+
*/
|
|
36
|
+
function provideIconComponent(component) {
|
|
37
|
+
provide(ICON_COMPONENT_KEY, component);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Read the host-supplied icon component, if any.
|
|
41
|
+
* @returns {import('vue').Component | string | null}
|
|
42
|
+
*/
|
|
43
|
+
function useIconComponent() {
|
|
44
|
+
return inject(ICON_COMPONENT_KEY, null);
|
|
45
|
+
}
|
|
46
|
+
//#endregion
|
|
47
|
+
export { ICON_COMPONENT_KEY, provideIconComponent, useIconComponent };
|
|
48
|
+
|
|
49
|
+
//# sourceMappingURL=resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolver.js","names":[],"sources":["../../src/icons/resolver.js"],"sourcesContent":["import { inject, provide } from 'vue'\n\n/**\n * Icon resolution for Numori UI.\n *\n * The components render icons through `<UiIcon name=\"mdi:check\" />`. By default\n * that resolves against the small set of Material Design Icons bundled with the\n * package (see `mdi.js`), drawn as inline SVG — no icon runtime, no network\n * request, works under SSR and inside a Capacitor `file://` shell.\n *\n * Hosts that already have an icon system (Nuxt's `<Icon>` from `@nuxt/icon`,\n * `unplugin-icons`, a sprite sheet, ...) can take over rendering entirely by\n * providing their own component, so the app ships one icon pipeline instead of\n * two. Anything Numori UI asks for is then requested from the host by name.\n */\n\n/** Injection key for a host-supplied icon component. */\nexport const ICON_COMPONENT_KEY = Symbol('numori-ui:icon-component')\n\n/**\n * Provide a custom icon component for every Numori UI icon below this point in\n * the tree. Call from a parent component's setup, or use the `icons.component`\n * option on the Vue plugin / Nuxt module to apply it app-wide.\n *\n * The component receives a single `name` prop (e.g. `'mdi:check'`) plus any\n * `class` the calling component applied for sizing and colour, so it must\n * accept and forward `class` to its root element.\n *\n * @param {import('vue').Component | string} component\n * Component (or globally registered component name) to render icons with.\n *\n * @example Delegate to @nuxt/icon inside a Nuxt app\n * // plugins/numori-ui-icons.js\n * import { provideIconComponent } from 'numori-ui'\n * // in a parent component's setup():\n * provideIconComponent(resolveComponent('Icon'))\n */\nexport function provideIconComponent(component) {\n provide(ICON_COMPONENT_KEY, component)\n}\n\n/**\n * Read the host-supplied icon component, if any.\n * @returns {import('vue').Component | string | null}\n */\nexport function useIconComponent() {\n return inject(ICON_COMPONENT_KEY, null)\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAiBA,IAAa,qBAAqB,OAAO,0BAA0B;;;;;;;;;;;;;;;;;;;AAoBnE,SAAgB,qBAAqB,WAAW;CAC9C,QAAQ,oBAAoB,SAAS;AACvC;;;;;AAMA,SAAgB,mBAAmB;CACjC,OAAO,OAAO,oBAAoB,IAAI;AACxC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import type { Component, Plugin } from 'vue'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Numori UI component. Props are documented with JSDoc on the components
|
|
5
|
+
* themselves; this declaration exists so TypeScript consumers can import and
|
|
6
|
+
* render them without error.
|
|
7
|
+
*/
|
|
8
|
+
type UiComponent = Component
|
|
9
|
+
|
|
10
|
+
export declare const UiAlert: UiComponent
|
|
11
|
+
export declare const UiAvatar: UiComponent
|
|
12
|
+
export declare const UiBadge: UiComponent
|
|
13
|
+
export declare const UiButton: UiComponent
|
|
14
|
+
export declare const UiButtonsGroup: UiComponent
|
|
15
|
+
export declare const UiCheckbox: UiComponent
|
|
16
|
+
export declare const UiDivider: UiComponent
|
|
17
|
+
export declare const UiDropdown: UiComponent
|
|
18
|
+
export declare const UiDropdownItem: UiComponent
|
|
19
|
+
export declare const UiDropdownRow: UiComponent
|
|
20
|
+
export declare const UiDropdownSubmenu: UiComponent
|
|
21
|
+
export declare const UiFileInput: UiComponent
|
|
22
|
+
export declare const UiFormField: UiComponent
|
|
23
|
+
export declare const UiInput: UiComponent
|
|
24
|
+
export declare const UiKbd: UiComponent
|
|
25
|
+
export declare const UiListMenu: UiComponent
|
|
26
|
+
export declare const UiListMenuItem: UiComponent
|
|
27
|
+
export declare const UiModal: UiComponent
|
|
28
|
+
export declare const UiNumpad: UiComponent
|
|
29
|
+
export declare const UiPopup: UiComponent
|
|
30
|
+
export declare const UiProgressBar: UiComponent
|
|
31
|
+
export declare const UiPrompt: UiComponent
|
|
32
|
+
export declare const UiRadio: UiComponent
|
|
33
|
+
export declare const UiSelect: UiComponent
|
|
34
|
+
export declare const UiSlider: UiComponent
|
|
35
|
+
export declare const UiStepper: UiComponent
|
|
36
|
+
export declare const UiToggle: UiComponent
|
|
37
|
+
export declare const UiTooltip: UiComponent
|
|
38
|
+
export declare const UiIcon: UiComponent
|
|
39
|
+
|
|
40
|
+
export declare const components: Record<string, UiComponent>
|
|
41
|
+
|
|
42
|
+
export interface NumoriUIOptions {
|
|
43
|
+
/** Prefix for registered tags. Default `'Ui'`. */
|
|
44
|
+
prefix?: string
|
|
45
|
+
/** Register only these base names. */
|
|
46
|
+
include?: string[]
|
|
47
|
+
/** Skip these base names. */
|
|
48
|
+
exclude?: string[]
|
|
49
|
+
icons?: {
|
|
50
|
+
/** Render all icons with this component instead of the bundled SVGs. */
|
|
51
|
+
component?: Component | string
|
|
52
|
+
/** Extra icon path data, keyed by name. */
|
|
53
|
+
extra?: Record<string, string>
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export declare const NumoriUI: Plugin<[NumoriUIOptions?]>
|
|
58
|
+
export default NumoriUI
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Build a plugin that registers only the components passed in, so unused ones
|
|
62
|
+
* are tree-shaken. Keys become the registered tag names verbatim.
|
|
63
|
+
*
|
|
64
|
+
* Prefer this over `NumoriUI` when bundle size matters: `app.use(NumoriUI)`
|
|
65
|
+
* references all 29 components and so bundles all of them.
|
|
66
|
+
*/
|
|
67
|
+
export declare function createNumoriUI(
|
|
68
|
+
components: Record<string, Component>,
|
|
69
|
+
options?: { icons?: NumoriUIOptions['icons'] },
|
|
70
|
+
): Plugin
|
|
71
|
+
|
|
72
|
+
export declare const DEFAULT_PREFIX: string
|
|
73
|
+
export declare const COMPONENT_NAMES: string[]
|
|
74
|
+
export declare function componentEntries(): Array<{ name: string; file: string }>
|
|
75
|
+
export declare function prefixed(name: string, prefix?: string): string
|
|
76
|
+
|
|
77
|
+
/** Add icons to the runtime registry, or override bundled ones. */
|
|
78
|
+
export declare function registerIcons(icons: Record<string, string>): void
|
|
79
|
+
export declare const iconRegistry: { value: Record<string, string> }
|
|
80
|
+
export declare function resolveIconPath(name: string): string | null
|
|
81
|
+
|
|
82
|
+
export declare const ICON_COMPONENT_KEY: symbol
|
|
83
|
+
export declare function provideIconComponent(component: Component | string): void
|
|
84
|
+
export declare function useIconComponent(): Component | string | null
|
|
85
|
+
|
|
86
|
+
export declare const MDI_VIEW_BOX: string
|
|
87
|
+
export declare const mdiPaths: Record<string, string>
|
|
88
|
+
export declare const mdiIconNames: string[]
|
|
89
|
+
|
|
90
|
+
export declare function useBackButton(): {
|
|
91
|
+
register: (handler: () => boolean, priority?: number) => number
|
|
92
|
+
unregister: (id: number) => void
|
|
93
|
+
invoke: () => boolean
|
|
94
|
+
hasHandlers: { value: boolean }
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export declare function onClickOutside(
|
|
98
|
+
target: unknown,
|
|
99
|
+
handler: (event: Event) => void,
|
|
100
|
+
options?: { ignore?: unknown[] },
|
|
101
|
+
): () => void
|
|
102
|
+
|
|
103
|
+
export declare function useEventListener(
|
|
104
|
+
target: unknown,
|
|
105
|
+
event: string,
|
|
106
|
+
handler: (event: Event) => void,
|
|
107
|
+
options?: boolean | AddEventListenerOptions,
|
|
108
|
+
): () => void
|