numori-ui 0.5.0 → 0.7.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/CHANGELOG.md +85 -0
- package/README.md +11 -3
- package/dist/components/Avatar.js +71 -19
- package/dist/components/Avatar.js.map +1 -1
- package/dist/components/ChipsInput.js +423 -0
- package/dist/components/ChipsInput.js.map +1 -0
- package/dist/components/Drawer.js +236 -0
- package/dist/components/Drawer.js.map +1 -0
- package/dist/components/Dropdown.js +4 -2
- package/dist/components/Dropdown.js.map +1 -1
- package/dist/components/Modal.js +61 -4
- package/dist/components/Modal.js.map +1 -1
- package/dist/components/Prompt.js +11 -6
- package/dist/components/Prompt.js.map +1 -1
- package/dist/components/Select.js +1 -1
- package/dist/components/Select.js.map +1 -1
- package/dist/components/Skeleton.js +122 -0
- package/dist/components/Skeleton.js.map +1 -0
- package/dist/components/SplitPane.js +264 -0
- package/dist/components/SplitPane.js.map +1 -0
- package/dist/components/Toast.js +62 -16
- package/dist/components/Toast.js.map +1 -1
- package/dist/components/Tree.js +417 -0
- package/dist/components/Tree.js.map +1 -0
- package/dist/components/VirtualList.js +292 -0
- package/dist/components/VirtualList.js.map +1 -0
- package/dist/components/index.js +93 -82
- package/dist/components/index.js.map +1 -1
- package/dist/icons/mdi.js +3 -0
- package/dist/icons/mdi.js.map +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.js +49 -43
- package/dist/index.js.map +1 -1
- package/dist/internal/focusTrap.js +163 -0
- package/dist/internal/focusTrap.js.map +1 -0
- package/dist/manifest.js +7 -1
- package/dist/manifest.js.map +1 -1
- package/package.json +2 -2
- package/src/components/Avatar.vue +69 -18
- package/src/components/ChipsInput.vue +387 -0
- package/src/components/Drawer.vue +213 -0
- package/src/components/Dropdown.vue +4 -1
- package/src/components/Modal.vue +51 -3
- package/src/components/Prompt.vue +14 -3
- package/src/components/Select.vue +1 -1
- package/src/components/Skeleton.vue +91 -0
- package/src/components/SplitPane.vue +264 -0
- package/src/components/Toast.vue +57 -13
- package/src/components/Tree.vue +428 -0
- package/src/components/VirtualList.vue +250 -0
- package/src/components/index.js +18 -1
- package/src/icons/mdi.js +3 -0
- package/src/internal/focusTrap.js +185 -0
- package/src/manifest.js +6 -0
package/dist/index.d.ts
CHANGED
|
@@ -16,10 +16,12 @@ export declare const UiBreadcrumb: UiComponent
|
|
|
16
16
|
export declare const UiButton: UiComponent
|
|
17
17
|
export declare const UiCard: UiComponent
|
|
18
18
|
export declare const UiCheckbox: UiComponent
|
|
19
|
+
export declare const UiChipsInput: UiComponent
|
|
19
20
|
export declare const UiCodeBlock: UiComponent
|
|
20
21
|
export declare const UiCopyField: UiComponent
|
|
21
22
|
export declare const UiDescriptionList: UiComponent
|
|
22
23
|
export declare const UiDivider: UiComponent
|
|
24
|
+
export declare const UiDrawer: UiComponent
|
|
23
25
|
export declare const UiDropdown: UiComponent
|
|
24
26
|
export declare const UiDropdownItem: UiComponent
|
|
25
27
|
export declare const UiDropdownRow: UiComponent
|
|
@@ -46,8 +48,10 @@ export declare const UiSelect: UiComponent
|
|
|
46
48
|
export declare const UiSidebar: UiComponent
|
|
47
49
|
export declare const UiSidebarGroup: UiComponent
|
|
48
50
|
export declare const UiSidebarItem: UiComponent
|
|
51
|
+
export declare const UiSkeleton: UiComponent
|
|
49
52
|
export declare const UiSlider: UiComponent
|
|
50
53
|
export declare const UiSpinner: UiComponent
|
|
54
|
+
export declare const UiSplitPane: UiComponent
|
|
51
55
|
export declare const UiStatCard: UiComponent
|
|
52
56
|
export declare const UiStepper: UiComponent
|
|
53
57
|
export declare const UiTable: UiComponent
|
|
@@ -56,6 +60,8 @@ export declare const UiThemeToggle: UiComponent
|
|
|
56
60
|
export declare const UiToast: UiComponent
|
|
57
61
|
export declare const UiToggle: UiComponent
|
|
58
62
|
export declare const UiTooltip: UiComponent
|
|
63
|
+
export declare const UiTree: UiComponent
|
|
64
|
+
export declare const UiVirtualList: UiComponent
|
|
59
65
|
export declare const UiIcon: UiComponent
|
|
60
66
|
|
|
61
67
|
export declare const components: Record<string, UiComponent>
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MDI_VIEW_BOX, mdiIconNames, mdiPaths } from "./icons/mdi.js";
|
|
2
2
|
import { iconRegistry, registerIcons, resolveIconPath } from "./icons/registry.js";
|
|
3
3
|
import { ICON_COMPONENT_KEY, provideIconComponent, useIconComponent } from "./icons/resolver.js";
|
|
4
|
-
import _sfc_main$
|
|
4
|
+
import _sfc_main$22 from "./icons/Icon.js";
|
|
5
5
|
import _sfc_main from "./components/Alert.js";
|
|
6
6
|
import _sfc_main$1 from "./components/AppShell.js";
|
|
7
7
|
import _sfc_main$2 from "./components/Avatar.js";
|
|
@@ -11,49 +11,55 @@ import _sfc_main$5 from "./components/Breadcrumb.js";
|
|
|
11
11
|
import _sfc_main$6 from "./components/Button.js";
|
|
12
12
|
import _sfc_main$7 from "./components/Card.js";
|
|
13
13
|
import _sfc_main$8 from "./components/Checkbox.js";
|
|
14
|
-
import _sfc_main$9 from "./components/
|
|
15
|
-
import _sfc_main$10 from "./components/
|
|
16
|
-
import _sfc_main$11 from "./components/
|
|
17
|
-
import _sfc_main$12 from "./components/
|
|
14
|
+
import _sfc_main$9 from "./components/ChipsInput.js";
|
|
15
|
+
import _sfc_main$10 from "./components/CodeBlock.js";
|
|
16
|
+
import _sfc_main$11 from "./components/CopyField.js";
|
|
17
|
+
import _sfc_main$12 from "./components/DescriptionList.js";
|
|
18
|
+
import _sfc_main$13 from "./components/Divider.js";
|
|
19
|
+
import { useBackButton } from "./composables/useBackButton.js";
|
|
20
|
+
import _sfc_main$14 from "./components/Drawer.js";
|
|
18
21
|
import { useEventListener } from "./composables/useEventListener.js";
|
|
19
22
|
import { onClickOutside } from "./composables/onClickOutside.js";
|
|
20
|
-
import _sfc_main$
|
|
21
|
-
import _sfc_main$
|
|
22
|
-
import _sfc_main$
|
|
23
|
-
import _sfc_main$
|
|
24
|
-
import _sfc_main$
|
|
25
|
-
import _sfc_main$
|
|
26
|
-
import _sfc_main$
|
|
27
|
-
import _sfc_main$
|
|
28
|
-
import _sfc_main$
|
|
29
|
-
import _sfc_main$
|
|
30
|
-
import _sfc_main$
|
|
31
|
-
import _sfc_main$
|
|
32
|
-
import
|
|
33
|
-
import _sfc_main$
|
|
34
|
-
import _sfc_main$
|
|
35
|
-
import _sfc_main$
|
|
36
|
-
import _sfc_main$
|
|
37
|
-
import _sfc_main$
|
|
38
|
-
import _sfc_main$
|
|
39
|
-
import _sfc_main$
|
|
40
|
-
import _sfc_main$
|
|
41
|
-
import _sfc_main$
|
|
42
|
-
import _sfc_main$
|
|
43
|
-
import _sfc_main$
|
|
44
|
-
import _sfc_main$
|
|
45
|
-
import _sfc_main$
|
|
46
|
-
import _sfc_main$
|
|
47
|
-
import _sfc_main$
|
|
48
|
-
import _sfc_main$
|
|
49
|
-
import _sfc_main$
|
|
50
|
-
import _sfc_main$
|
|
51
|
-
import _sfc_main$
|
|
52
|
-
import _sfc_main$
|
|
53
|
-
import _sfc_main$
|
|
54
|
-
import _sfc_main$
|
|
55
|
-
import _sfc_main$
|
|
56
|
-
import _sfc_main$
|
|
23
|
+
import _sfc_main$15 from "./components/Dropdown.js";
|
|
24
|
+
import _sfc_main$16 from "./components/DropdownItem.js";
|
|
25
|
+
import _sfc_main$17 from "./components/DropdownRow.js";
|
|
26
|
+
import _sfc_main$18 from "./components/DropdownSubmenu.js";
|
|
27
|
+
import _sfc_main$19 from "./components/EmptyState.js";
|
|
28
|
+
import _sfc_main$20 from "./components/FileInput.js";
|
|
29
|
+
import _sfc_main$21 from "./components/FormField.js";
|
|
30
|
+
import _sfc_main$23 from "./components/IconTile.js";
|
|
31
|
+
import _sfc_main$24 from "./components/Input.js";
|
|
32
|
+
import _sfc_main$25 from "./components/Kbd.js";
|
|
33
|
+
import _sfc_main$26 from "./components/ListMenu.js";
|
|
34
|
+
import _sfc_main$27 from "./components/ListMenuItem.js";
|
|
35
|
+
import _sfc_main$28 from "./components/Modal.js";
|
|
36
|
+
import _sfc_main$29 from "./components/Numpad.js";
|
|
37
|
+
import _sfc_main$30 from "./components/PageHeader.js";
|
|
38
|
+
import _sfc_main$31 from "./components/Pagination.js";
|
|
39
|
+
import _sfc_main$32 from "./components/Popup.js";
|
|
40
|
+
import _sfc_main$33 from "./components/ProgressBar.js";
|
|
41
|
+
import _sfc_main$34 from "./components/Prompt.js";
|
|
42
|
+
import _sfc_main$35 from "./components/Radio.js";
|
|
43
|
+
import _sfc_main$36 from "./components/SectionHeading.js";
|
|
44
|
+
import _sfc_main$37 from "./components/Segmented.js";
|
|
45
|
+
import _sfc_main$38 from "./components/Select.js";
|
|
46
|
+
import _sfc_main$39 from "./components/Sidebar.js";
|
|
47
|
+
import _sfc_main$40 from "./components/SidebarGroup.js";
|
|
48
|
+
import _sfc_main$41 from "./components/SidebarItem.js";
|
|
49
|
+
import _sfc_main$42 from "./components/Skeleton.js";
|
|
50
|
+
import _sfc_main$43 from "./components/Slider.js";
|
|
51
|
+
import _sfc_main$44 from "./components/Spinner.js";
|
|
52
|
+
import _sfc_main$45 from "./components/SplitPane.js";
|
|
53
|
+
import _sfc_main$46 from "./components/StatCard.js";
|
|
54
|
+
import _sfc_main$47 from "./components/Stepper.js";
|
|
55
|
+
import _sfc_main$48 from "./components/Table.js";
|
|
56
|
+
import _sfc_main$49 from "./components/Tabs.js";
|
|
57
|
+
import _sfc_main$50 from "./components/ThemeToggle.js";
|
|
58
|
+
import _sfc_main$51 from "./components/Toast.js";
|
|
59
|
+
import _sfc_main$52 from "./components/Toggle.js";
|
|
60
|
+
import _sfc_main$53 from "./components/Tooltip.js";
|
|
61
|
+
import _sfc_main$54 from "./components/Tree.js";
|
|
62
|
+
import _sfc_main$55 from "./components/VirtualList.js";
|
|
57
63
|
import { components } from "./components/index.js";
|
|
58
64
|
import { COMPONENT_NAMES, DEFAULT_PREFIX, componentEntries, prefixed } from "./manifest.js";
|
|
59
65
|
//#region src/index.js
|
|
@@ -173,6 +179,6 @@ function createNumoriUI(components = {}, options = {}) {
|
|
|
173
179
|
} };
|
|
174
180
|
}
|
|
175
181
|
//#endregion
|
|
176
|
-
export { COMPONENT_NAMES, DEFAULT_PREFIX, ICON_COMPONENT_KEY, MDI_VIEW_BOX, NumoriUI, NumoriUI as default, _sfc_main as UiAlert, _sfc_main$1 as UiAppShell, _sfc_main$2 as UiAvatar, _sfc_main$3 as UiBadge, _sfc_main$4 as UiBanner, _sfc_main$5 as UiBreadcrumb, _sfc_main$6 as UiButton, _sfc_main$7 as UiCard, _sfc_main$8 as UiCheckbox, _sfc_main$9 as
|
|
182
|
+
export { COMPONENT_NAMES, DEFAULT_PREFIX, ICON_COMPONENT_KEY, MDI_VIEW_BOX, NumoriUI, NumoriUI as default, _sfc_main as UiAlert, _sfc_main$1 as UiAppShell, _sfc_main$2 as UiAvatar, _sfc_main$3 as UiBadge, _sfc_main$4 as UiBanner, _sfc_main$5 as UiBreadcrumb, _sfc_main$6 as UiButton, _sfc_main$7 as UiCard, _sfc_main$8 as UiCheckbox, _sfc_main$9 as UiChipsInput, _sfc_main$10 as UiCodeBlock, _sfc_main$11 as UiCopyField, _sfc_main$12 as UiDescriptionList, _sfc_main$13 as UiDivider, _sfc_main$14 as UiDrawer, _sfc_main$15 as UiDropdown, _sfc_main$16 as UiDropdownItem, _sfc_main$17 as UiDropdownRow, _sfc_main$18 as UiDropdownSubmenu, _sfc_main$19 as UiEmptyState, _sfc_main$20 as UiFileInput, _sfc_main$21 as UiFormField, _sfc_main$22 as UiIcon, _sfc_main$23 as UiIconTile, _sfc_main$24 as UiInput, _sfc_main$25 as UiKbd, _sfc_main$26 as UiListMenu, _sfc_main$27 as UiListMenuItem, _sfc_main$28 as UiModal, _sfc_main$29 as UiNumpad, _sfc_main$30 as UiPageHeader, _sfc_main$31 as UiPagination, _sfc_main$32 as UiPopup, _sfc_main$33 as UiProgressBar, _sfc_main$34 as UiPrompt, _sfc_main$35 as UiRadio, _sfc_main$36 as UiSectionHeading, _sfc_main$37 as UiSegmented, _sfc_main$38 as UiSelect, _sfc_main$39 as UiSidebar, _sfc_main$40 as UiSidebarGroup, _sfc_main$41 as UiSidebarItem, _sfc_main$42 as UiSkeleton, _sfc_main$43 as UiSlider, _sfc_main$44 as UiSpinner, _sfc_main$45 as UiSplitPane, _sfc_main$46 as UiStatCard, _sfc_main$47 as UiStepper, _sfc_main$48 as UiTable, _sfc_main$49 as UiTabs, _sfc_main$50 as UiThemeToggle, _sfc_main$51 as UiToast, _sfc_main$52 as UiToggle, _sfc_main$53 as UiTooltip, _sfc_main$54 as UiTree, _sfc_main$55 as UiVirtualList, componentEntries, components, createNumoriUI, iconRegistry, mdiIconNames, mdiPaths, onClickOutside, prefixed, provideIconComponent, registerIcons, resolveIconPath, useBackButton, useEventListener, useIconComponent };
|
|
177
183
|
|
|
178
184
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/index.js"],"sourcesContent":["/**\n * Numori UI — the Numori design system as a standalone Vue 3 component library.\n *\n * This is the framework-agnostic entry point. It works in any Vue 3 app with\n * no build-tool integration at all:\n *\n * import { createApp } from 'vue'\n * import NumoriUI from 'numori-ui'\n * import './app.css' // @import \"tailwindcss\"; @import \"numori-ui/css\";\n *\n * createApp(App).use(NumoriUI).mount('#app')\n *\n * For a nicer developer experience there are two build-tool integrations that\n * register the components for you, so templates need no imports:\n *\n * - `numori-ui/nuxt` — a Nuxt module\n * - `numori-ui/vite` — a Vite plugin\n *\n * Styling is Tailwind CSS v4 and is deliberately NOT bundled as compiled CSS.\n * The components are plain utility classes, so they inherit the host app's\n * Tailwind build: one pass, one stylesheet, no duplication, and every token is\n * overridable. All the host has to do is import `numori-ui/css`, which supplies\n * the design tokens and tells Tailwind to scan this package for classes.\n */\n\nimport { components } from './components/index.js'\nimport { DEFAULT_PREFIX, prefixed } from './manifest.js'\nimport { ICON_COMPONENT_KEY } from './icons/resolver.js'\nimport { registerIcons } from './icons/registry.js'\n\nexport * from './components/index.js'\n\nexport { DEFAULT_PREFIX, COMPONENT_NAMES, componentEntries, prefixed } from './manifest.js'\nexport { registerIcons, iconRegistry, resolveIconPath } from './icons/registry.js'\nexport { provideIconComponent, useIconComponent, ICON_COMPONENT_KEY } from './icons/resolver.js'\nexport { MDI_VIEW_BOX, mdiPaths, mdiIconNames } from './icons/mdi.js'\nexport { useBackButton } from './composables/useBackButton.js'\nexport { onClickOutside } from './composables/onClickOutside.js'\nexport { useEventListener } from './composables/useEventListener.js'\n\n/**\n * Vue plugin that globally registers every Numori UI component.\n *\n * @type {import('vue').Plugin}\n *\n * @param {import('vue').App} app\n * @param {object} [options]\n * @param {string} [options.prefix='Ui']\n * Prefix for registered tags. `'Ui'` gives `<UiButton>`. Must be non-empty —\n * see the note in `install` for why.\n * @param {string[]} [options.include]\n * Register only these base names (e.g. `['Button', 'Modal']`). Note this\n * affects *global registration* only — it is not tree-shaking. To actually\n * drop unused components from the bundle, skip the plugin and import the\n * components you use directly.\n * @param {string[]} [options.exclude]\n * Skip these base names. Useful when the host has its own `<UiButton>`.\n * @param {object} [options.icons]\n * @param {import('vue').Component|string} [options.icons.component]\n * Render all icons with this component instead of the bundled inline SVGs.\n * Receives a `name` prop and must forward `class` to its root element.\n * @param {Record<string,string>} [options.icons.extra]\n * Extra icon path data to add to the bundled set, keyed by name.\n *\n * @example Default registration\n * app.use(NumoriUI)\n *\n * @example Custom prefix\n * app.use(NumoriUI, { prefix: 'N' }) // <NButton>\n *\n * @example Delegate icons to an existing icon component\n * app.use(NumoriUI, { icons: { component: MyIcon } })\n */\nexport const NumoriUI = {\n install(app, options = {}) {\n const { prefix = DEFAULT_PREFIX, include, exclude = [], icons = {} } = options\n\n // An empty prefix is rejected rather than merely discouraged. `Button`\n // renders its root as `<component :is=\"tag\">` with `tag` defaulting to\n // `'button'`, and Vue's dynamic-component lookup capitalises before\n // matching — so a globally registered `Button` would resolve `'button'`\n // back to itself and recurse until the stack blows. The failure is a bare\n // \"Maximum call stack size exceeded\" with no hint of the cause, so it is\n // much kinder to refuse up front.\n if (typeof prefix !== 'string' || prefix.length === 0) {\n throw new Error(\n '[numori-ui] `prefix` must be a non-empty string. Registering components under their ' +\n 'bare names would make <Button> resolve its own native `button` root element, ' +\n 'recursing infinitely. Use a prefix such as \"Ui\" or \"N\".',\n )\n }\n\n if (icons.extra) registerIcons(icons.extra)\n // app-level provide, so it reaches every component including those\n // teleported out of the tree (modals, select panels).\n if (icons.component) app.provide(ICON_COMPONENT_KEY, icons.component)\n\n for (const [name, component] of Object.entries(components)) {\n if (include && !include.includes(name)) continue\n if (exclude.includes(name)) continue\n app.component(prefixed(name, prefix), component)\n }\n },\n}\n\nexport default NumoriUI\n\n/**\n * Build a Vue plugin that globally registers only the components you hand it.\n *\n * `NumoriUI` is convenient but it is not tree-shakeable: to register everything\n * it has to reference everything, so `app.use(NumoriUI)` puts all 29 components\n * in your bundle (~82 kB) whether you render them or not. The `include` option\n * does not change that — it controls registration, not bundling.\n *\n * This factory is the way to get both. You import the components you want, so\n * the bundler sees exactly that set and drops the rest, and you still get global\n * tags instead of importing them into every file.\n *\n * Keys become the registered tag names verbatim, so no prefix option is needed\n * and there is no naming magic — rename in the object literal if you want a\n * different tag.\n *\n * @param {Record<string, import('vue').Component>} components\n * Map of tag name to component, e.g. `{ UiButton, UiModal }`.\n * @param {object} [options]\n * @param {object} [options.icons] Same shape as the `NumoriUI` plugin's option.\n * @returns {import('vue').Plugin}\n *\n * @example Global tags, but only two components bundled\n * import { createNumoriUI, UiButton, UiModal } from 'numori-ui'\n *\n * app.use(createNumoriUI({ UiButton, UiModal }))\n *\n * @example Registering under different tag names\n * app.use(createNumoriUI({ NButton: UiButton, NModal: UiModal }))\n */\nexport function createNumoriUI(components = {}, options = {}) {\n const { icons = {} } = options\n\n // `UiButton` renders its root as `<component :is=\"tag\">`, and Vue capitalises\n // when resolving a dynamic component. Registering it under a name that\n // case-insensitively matches one of those tags would make it resolve itself\n // and recurse until the stack overflows, reported only as \"Maximum call stack\n // size exceeded\". Cheap to catch here, miserable to debug later.\n const DYNAMIC_TAGS = ['button', 'a', 'div', 'span', 'label', 'li']\n for (const name of Object.keys(components)) {\n if (DYNAMIC_TAGS.includes(name.toLowerCase())) {\n throw new Error(\n `[numori-ui] Cannot register a component as \"${name}\": it collides with the native <${name.toLowerCase()}> ` +\n 'element that UiButton can render as its root, which would recurse infinitely. ' +\n `Use a prefixed name such as \"Ui${name}\".`,\n )\n }\n }\n\n return {\n install(app) {\n if (icons.extra) registerIcons(icons.extra)\n if (icons.component) app.provide(ICON_COMPONENT_KEY, icons.component)\n\n for (const [name, component] of Object.entries(components)) {\n app.component(name, component)\n }\n },\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.js"],"sourcesContent":["/**\n * Numori UI — the Numori design system as a standalone Vue 3 component library.\n *\n * This is the framework-agnostic entry point. It works in any Vue 3 app with\n * no build-tool integration at all:\n *\n * import { createApp } from 'vue'\n * import NumoriUI from 'numori-ui'\n * import './app.css' // @import \"tailwindcss\"; @import \"numori-ui/css\";\n *\n * createApp(App).use(NumoriUI).mount('#app')\n *\n * For a nicer developer experience there are two build-tool integrations that\n * register the components for you, so templates need no imports:\n *\n * - `numori-ui/nuxt` — a Nuxt module\n * - `numori-ui/vite` — a Vite plugin\n *\n * Styling is Tailwind CSS v4 and is deliberately NOT bundled as compiled CSS.\n * The components are plain utility classes, so they inherit the host app's\n * Tailwind build: one pass, one stylesheet, no duplication, and every token is\n * overridable. All the host has to do is import `numori-ui/css`, which supplies\n * the design tokens and tells Tailwind to scan this package for classes.\n */\n\nimport { components } from './components/index.js'\nimport { DEFAULT_PREFIX, prefixed } from './manifest.js'\nimport { ICON_COMPONENT_KEY } from './icons/resolver.js'\nimport { registerIcons } from './icons/registry.js'\n\nexport * from './components/index.js'\n\nexport { DEFAULT_PREFIX, COMPONENT_NAMES, componentEntries, prefixed } from './manifest.js'\nexport { registerIcons, iconRegistry, resolveIconPath } from './icons/registry.js'\nexport { provideIconComponent, useIconComponent, ICON_COMPONENT_KEY } from './icons/resolver.js'\nexport { MDI_VIEW_BOX, mdiPaths, mdiIconNames } from './icons/mdi.js'\nexport { useBackButton } from './composables/useBackButton.js'\nexport { onClickOutside } from './composables/onClickOutside.js'\nexport { useEventListener } from './composables/useEventListener.js'\n\n/**\n * Vue plugin that globally registers every Numori UI component.\n *\n * @type {import('vue').Plugin}\n *\n * @param {import('vue').App} app\n * @param {object} [options]\n * @param {string} [options.prefix='Ui']\n * Prefix for registered tags. `'Ui'` gives `<UiButton>`. Must be non-empty —\n * see the note in `install` for why.\n * @param {string[]} [options.include]\n * Register only these base names (e.g. `['Button', 'Modal']`). Note this\n * affects *global registration* only — it is not tree-shaking. To actually\n * drop unused components from the bundle, skip the plugin and import the\n * components you use directly.\n * @param {string[]} [options.exclude]\n * Skip these base names. Useful when the host has its own `<UiButton>`.\n * @param {object} [options.icons]\n * @param {import('vue').Component|string} [options.icons.component]\n * Render all icons with this component instead of the bundled inline SVGs.\n * Receives a `name` prop and must forward `class` to its root element.\n * @param {Record<string,string>} [options.icons.extra]\n * Extra icon path data to add to the bundled set, keyed by name.\n *\n * @example Default registration\n * app.use(NumoriUI)\n *\n * @example Custom prefix\n * app.use(NumoriUI, { prefix: 'N' }) // <NButton>\n *\n * @example Delegate icons to an existing icon component\n * app.use(NumoriUI, { icons: { component: MyIcon } })\n */\nexport const NumoriUI = {\n install(app, options = {}) {\n const { prefix = DEFAULT_PREFIX, include, exclude = [], icons = {} } = options\n\n // An empty prefix is rejected rather than merely discouraged. `Button`\n // renders its root as `<component :is=\"tag\">` with `tag` defaulting to\n // `'button'`, and Vue's dynamic-component lookup capitalises before\n // matching — so a globally registered `Button` would resolve `'button'`\n // back to itself and recurse until the stack blows. The failure is a bare\n // \"Maximum call stack size exceeded\" with no hint of the cause, so it is\n // much kinder to refuse up front.\n if (typeof prefix !== 'string' || prefix.length === 0) {\n throw new Error(\n '[numori-ui] `prefix` must be a non-empty string. Registering components under their ' +\n 'bare names would make <Button> resolve its own native `button` root element, ' +\n 'recursing infinitely. Use a prefix such as \"Ui\" or \"N\".',\n )\n }\n\n if (icons.extra) registerIcons(icons.extra)\n // app-level provide, so it reaches every component including those\n // teleported out of the tree (modals, select panels).\n if (icons.component) app.provide(ICON_COMPONENT_KEY, icons.component)\n\n for (const [name, component] of Object.entries(components)) {\n if (include && !include.includes(name)) continue\n if (exclude.includes(name)) continue\n app.component(prefixed(name, prefix), component)\n }\n },\n}\n\nexport default NumoriUI\n\n/**\n * Build a Vue plugin that globally registers only the components you hand it.\n *\n * `NumoriUI` is convenient but it is not tree-shakeable: to register everything\n * it has to reference everything, so `app.use(NumoriUI)` puts all 29 components\n * in your bundle (~82 kB) whether you render them or not. The `include` option\n * does not change that — it controls registration, not bundling.\n *\n * This factory is the way to get both. You import the components you want, so\n * the bundler sees exactly that set and drops the rest, and you still get global\n * tags instead of importing them into every file.\n *\n * Keys become the registered tag names verbatim, so no prefix option is needed\n * and there is no naming magic — rename in the object literal if you want a\n * different tag.\n *\n * @param {Record<string, import('vue').Component>} components\n * Map of tag name to component, e.g. `{ UiButton, UiModal }`.\n * @param {object} [options]\n * @param {object} [options.icons] Same shape as the `NumoriUI` plugin's option.\n * @returns {import('vue').Plugin}\n *\n * @example Global tags, but only two components bundled\n * import { createNumoriUI, UiButton, UiModal } from 'numori-ui'\n *\n * app.use(createNumoriUI({ UiButton, UiModal }))\n *\n * @example Registering under different tag names\n * app.use(createNumoriUI({ NButton: UiButton, NModal: UiModal }))\n */\nexport function createNumoriUI(components = {}, options = {}) {\n const { icons = {} } = options\n\n // `UiButton` renders its root as `<component :is=\"tag\">`, and Vue capitalises\n // when resolving a dynamic component. Registering it under a name that\n // case-insensitively matches one of those tags would make it resolve itself\n // and recurse until the stack overflows, reported only as \"Maximum call stack\n // size exceeded\". Cheap to catch here, miserable to debug later.\n const DYNAMIC_TAGS = ['button', 'a', 'div', 'span', 'label', 'li']\n for (const name of Object.keys(components)) {\n if (DYNAMIC_TAGS.includes(name.toLowerCase())) {\n throw new Error(\n `[numori-ui] Cannot register a component as \"${name}\": it collides with the native <${name.toLowerCase()}> ` +\n 'element that UiButton can render as its root, which would recurse infinitely. ' +\n `Use a prefixed name such as \"Ui${name}\".`,\n )\n }\n }\n\n return {\n install(app) {\n if (icons.extra) registerIcons(icons.extra)\n if (icons.component) app.provide(ICON_COMPONENT_KEY, icons.component)\n\n for (const [name, component] of Object.entries(components)) {\n app.component(name, component)\n }\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyEA,IAAa,WAAW,EACtB,QAAQ,KAAK,UAAU,CAAC,GAAG;CACzB,MAAM,EAAE,SAAA,MAAyB,SAAS,UAAU,CAAC,GAAG,QAAQ,CAAC,MAAM;CASvE,IAAI,OAAO,WAAW,YAAY,OAAO,WAAW,GAClD,MAAM,IAAI,MACR,8NAGF;CAGF,IAAI,MAAM,OAAO,cAAc,MAAM,KAAK;CAG1C,IAAI,MAAM,WAAW,IAAI,QAAQ,oBAAoB,MAAM,SAAS;CAEpE,KAAK,MAAM,CAAC,MAAM,cAAc,OAAO,QAAQ,UAAU,GAAG;EAC1D,IAAI,WAAW,CAAC,QAAQ,SAAS,IAAI,GAAG;EACxC,IAAI,QAAQ,SAAS,IAAI,GAAG;EAC5B,IAAI,UAAU,SAAS,MAAM,MAAM,GAAG,SAAS;CACjD;AACF,EACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,SAAgB,eAAe,aAAa,CAAC,GAAG,UAAU,CAAC,GAAG;CAC5D,MAAM,EAAE,QAAQ,CAAC,MAAM;CAOvB,MAAM,eAAe;EAAC;EAAU;EAAK;EAAO;EAAQ;EAAS;CAAI;CACjE,KAAK,MAAM,QAAQ,OAAO,KAAK,UAAU,GACvC,IAAI,aAAa,SAAS,KAAK,YAAY,CAAC,GAC1C,MAAM,IAAI,MACR,+CAA+C,KAAK,kCAAkC,KAAK,YAAY,EAAE,iHAErE,KAAK,GAC3C;CAIJ,OAAO,EACL,QAAQ,KAAK;EACX,IAAI,MAAM,OAAO,cAAc,MAAM,KAAK;EAC1C,IAAI,MAAM,WAAW,IAAI,QAAQ,oBAAoB,MAAM,SAAS;EAEpE,KAAK,MAAM,CAAC,MAAM,cAAc,OAAO,QAAQ,UAAU,GACvD,IAAI,UAAU,MAAM,SAAS;CAEjC,EACF;AACF"}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { nextTick, onBeforeUnmount, watch } from "vue";
|
|
2
|
+
//#region src/internal/focusTrap.js
|
|
3
|
+
/**
|
|
4
|
+
* Focus management for modal surfaces (`UiModal`, and anything built on it).
|
|
5
|
+
*
|
|
6
|
+
* A modal dialog has three keyboard obligations under the WAI-ARIA dialog
|
|
7
|
+
* pattern, and all three are easy to get subtly wrong:
|
|
8
|
+
*
|
|
9
|
+
* 1. **Move focus in** when it opens — otherwise a keyboard user is left on
|
|
10
|
+
* the button behind the backdrop, and a screen reader never announces the
|
|
11
|
+
* dialog.
|
|
12
|
+
* 2. **Keep focus in** while it is open — Tab from the last control wraps to
|
|
13
|
+
* the first, Shift+Tab from the first wraps to the last.
|
|
14
|
+
* 3. **Put focus back** when it closes, on whatever opened it.
|
|
15
|
+
*
|
|
16
|
+
* Escape also closes the dialog, unless the caller says otherwise.
|
|
17
|
+
*
|
|
18
|
+
* Dialogs can stack (a confirmation over a settings modal), and only the top
|
|
19
|
+
* one may react to Tab or Escape — so every trap registers on a module-level
|
|
20
|
+
* stack and a single listener dispatches to whichever is on top.
|
|
21
|
+
*
|
|
22
|
+
* That listener is on `window`, not `document`, deliberately: `window` is the
|
|
23
|
+
* last stop of a bubbling keydown, so a control inside the dialog that closes
|
|
24
|
+
* itself on Escape (an open `UiDropdown`, `UiSelect`'s search field) runs first
|
|
25
|
+
* and calls `preventDefault()`, and the dialog then leaves the key alone. One
|
|
26
|
+
* Escape closes one thing.
|
|
27
|
+
*
|
|
28
|
+
* Initial focus is only moved if nothing inside the container already has it.
|
|
29
|
+
* That lets a wrapper such as `UiPrompt` focus its confirm button without the
|
|
30
|
+
* trap then stealing focus back to the first control.
|
|
31
|
+
*
|
|
32
|
+
* SSR-safe: nothing touches `document` until the trap activates, which only
|
|
33
|
+
* happens in the browser.
|
|
34
|
+
*/
|
|
35
|
+
var FOCUSABLE = [
|
|
36
|
+
"a[href]",
|
|
37
|
+
"area[href]",
|
|
38
|
+
"button:not([disabled])",
|
|
39
|
+
"input:not([disabled]):not([type=\"hidden\"])",
|
|
40
|
+
"select:not([disabled])",
|
|
41
|
+
"textarea:not([disabled])",
|
|
42
|
+
"iframe",
|
|
43
|
+
"audio[controls]",
|
|
44
|
+
"video[controls]",
|
|
45
|
+
"[contenteditable]:not([contenteditable=\"false\"])",
|
|
46
|
+
"[tabindex]:not([tabindex=\"-1\"])"
|
|
47
|
+
].join(",");
|
|
48
|
+
/**
|
|
49
|
+
* Tabbable descendants of `container`, in DOM order, skipping anything hidden.
|
|
50
|
+
*
|
|
51
|
+
* @param {HTMLElement} container
|
|
52
|
+
* @returns {HTMLElement[]}
|
|
53
|
+
*/
|
|
54
|
+
function tabbableIn(container) {
|
|
55
|
+
if (!container) return [];
|
|
56
|
+
return [...container.querySelectorAll(FOCUSABLE)].filter((el) => !el.closest("[inert]") && el.getClientRects().length > 0);
|
|
57
|
+
}
|
|
58
|
+
/** @type {Array<{ container: () => HTMLElement | null, onEscape: (() => void) | null }>} */
|
|
59
|
+
var stack = [];
|
|
60
|
+
var listening = false;
|
|
61
|
+
function onWindowKeydown(event) {
|
|
62
|
+
const top = stack[stack.length - 1];
|
|
63
|
+
if (!top) return;
|
|
64
|
+
const container = top.container();
|
|
65
|
+
if (!container) return;
|
|
66
|
+
if (event.key === "Escape") {
|
|
67
|
+
if (event.defaultPrevented || !top.onEscape) return;
|
|
68
|
+
event.preventDefault();
|
|
69
|
+
top.onEscape();
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
if (event.key !== "Tab") return;
|
|
73
|
+
const items = tabbableIn(container);
|
|
74
|
+
if (items.length === 0) {
|
|
75
|
+
event.preventDefault();
|
|
76
|
+
container.focus();
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const first = items[0];
|
|
80
|
+
const last = items[items.length - 1];
|
|
81
|
+
const active = document.activeElement;
|
|
82
|
+
const inside = container.contains(active);
|
|
83
|
+
if (event.shiftKey && (active === first || !inside)) {
|
|
84
|
+
event.preventDefault();
|
|
85
|
+
last.focus();
|
|
86
|
+
} else if (!event.shiftKey && (active === last || !inside)) {
|
|
87
|
+
event.preventDefault();
|
|
88
|
+
first.focus();
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function push(entry) {
|
|
92
|
+
stack.push(entry);
|
|
93
|
+
if (!listening) {
|
|
94
|
+
window.addEventListener("keydown", onWindowKeydown);
|
|
95
|
+
listening = true;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function remove(entry) {
|
|
99
|
+
const index = stack.indexOf(entry);
|
|
100
|
+
if (index !== -1) stack.splice(index, 1);
|
|
101
|
+
if (stack.length === 0 && listening) {
|
|
102
|
+
window.removeEventListener("keydown", onWindowKeydown);
|
|
103
|
+
listening = false;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Trap focus inside an element while `active()` is true.
|
|
108
|
+
*
|
|
109
|
+
* @param {() => HTMLElement | null | undefined} container Getter for the
|
|
110
|
+
* element focus is confined to. It must itself be focusable
|
|
111
|
+
* (`tabindex="-1"`) so there is somewhere to land when it has no controls.
|
|
112
|
+
* @param {object} options
|
|
113
|
+
* @param {() => boolean} options.active Whether the trap is engaged.
|
|
114
|
+
* @param {(() => boolean) | boolean} [options.escape] Whether Escape closes.
|
|
115
|
+
* @param {() => void} [options.onEscape] Called when Escape should close.
|
|
116
|
+
*/
|
|
117
|
+
function useFocusTrap(container, { active, escape = true, onEscape }) {
|
|
118
|
+
const entry = {
|
|
119
|
+
container: () => container() ?? null,
|
|
120
|
+
onEscape: null
|
|
121
|
+
};
|
|
122
|
+
let returnTo = null;
|
|
123
|
+
let engaged = false;
|
|
124
|
+
let lastEl = null;
|
|
125
|
+
const engage = () => {
|
|
126
|
+
if (engaged || typeof document === "undefined") return;
|
|
127
|
+
engaged = true;
|
|
128
|
+
returnTo = document.activeElement;
|
|
129
|
+
entry.onEscape = () => {
|
|
130
|
+
if (typeof escape === "function" ? escape() : escape) onEscape?.();
|
|
131
|
+
};
|
|
132
|
+
push(entry);
|
|
133
|
+
nextTick(() => {
|
|
134
|
+
const el = entry.container();
|
|
135
|
+
if (el) lastEl = el;
|
|
136
|
+
if (!el || el.contains(document.activeElement)) return;
|
|
137
|
+
const [first] = tabbableIn(el);
|
|
138
|
+
(first ?? el).focus({ preventScroll: true });
|
|
139
|
+
});
|
|
140
|
+
};
|
|
141
|
+
const release = () => {
|
|
142
|
+
if (!engaged) return;
|
|
143
|
+
engaged = false;
|
|
144
|
+
remove(entry);
|
|
145
|
+
const target = returnTo;
|
|
146
|
+
const closing = entry.container() ?? lastEl;
|
|
147
|
+
returnTo = null;
|
|
148
|
+
lastEl = null;
|
|
149
|
+
if (target && typeof target.focus === "function" && document.contains(target)) {
|
|
150
|
+
const current = document.activeElement;
|
|
151
|
+
if (!current || current === document.body || closing?.contains(current)) target.focus({ preventScroll: true });
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
watch(active, (on) => on ? engage() : release(), {
|
|
155
|
+
immediate: true,
|
|
156
|
+
flush: "post"
|
|
157
|
+
});
|
|
158
|
+
onBeforeUnmount(release);
|
|
159
|
+
}
|
|
160
|
+
//#endregion
|
|
161
|
+
export { tabbableIn, useFocusTrap };
|
|
162
|
+
|
|
163
|
+
//# sourceMappingURL=focusTrap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"focusTrap.js","names":[],"sources":["../../src/internal/focusTrap.js"],"sourcesContent":["/**\n * Focus management for modal surfaces (`UiModal`, and anything built on it).\n *\n * A modal dialog has three keyboard obligations under the WAI-ARIA dialog\n * pattern, and all three are easy to get subtly wrong:\n *\n * 1. **Move focus in** when it opens — otherwise a keyboard user is left on\n * the button behind the backdrop, and a screen reader never announces the\n * dialog.\n * 2. **Keep focus in** while it is open — Tab from the last control wraps to\n * the first, Shift+Tab from the first wraps to the last.\n * 3. **Put focus back** when it closes, on whatever opened it.\n *\n * Escape also closes the dialog, unless the caller says otherwise.\n *\n * Dialogs can stack (a confirmation over a settings modal), and only the top\n * one may react to Tab or Escape — so every trap registers on a module-level\n * stack and a single listener dispatches to whichever is on top.\n *\n * That listener is on `window`, not `document`, deliberately: `window` is the\n * last stop of a bubbling keydown, so a control inside the dialog that closes\n * itself on Escape (an open `UiDropdown`, `UiSelect`'s search field) runs first\n * and calls `preventDefault()`, and the dialog then leaves the key alone. One\n * Escape closes one thing.\n *\n * Initial focus is only moved if nothing inside the container already has it.\n * That lets a wrapper such as `UiPrompt` focus its confirm button without the\n * trap then stealing focus back to the first control.\n *\n * SSR-safe: nothing touches `document` until the trap activates, which only\n * happens in the browser.\n */\nimport { nextTick, onBeforeUnmount, watch } from 'vue'\n\n// ── Focusable elements ───────────────────────────────────────────────\n\nconst FOCUSABLE = [\n 'a[href]',\n 'area[href]',\n 'button:not([disabled])',\n 'input:not([disabled]):not([type=\"hidden\"])',\n 'select:not([disabled])',\n 'textarea:not([disabled])',\n 'iframe',\n 'audio[controls]',\n 'video[controls]',\n '[contenteditable]:not([contenteditable=\"false\"])',\n '[tabindex]:not([tabindex=\"-1\"])',\n].join(',')\n\n/**\n * Tabbable descendants of `container`, in DOM order, skipping anything hidden.\n *\n * @param {HTMLElement} container\n * @returns {HTMLElement[]}\n */\nexport function tabbableIn(container) {\n if (!container) return []\n return [...container.querySelectorAll(FOCUSABLE)].filter(\n (el) => !el.closest('[inert]') && el.getClientRects().length > 0,\n )\n}\n\n// ── The stack of active traps ────────────────────────────────────────\n\n/** @type {Array<{ container: () => HTMLElement | null, onEscape: (() => void) | null }>} */\nconst stack = []\nlet listening = false\n\nfunction onWindowKeydown(event) {\n const top = stack[stack.length - 1]\n if (!top) return\n const container = top.container()\n if (!container) return\n\n if (event.key === 'Escape') {\n // A control inside the dialog (an open select, a search field) may have\n // handled Escape already; respect that rather than closing over it.\n if (event.defaultPrevented || !top.onEscape) return\n event.preventDefault()\n top.onEscape()\n return\n }\n\n if (event.key !== 'Tab') return\n const items = tabbableIn(container)\n if (items.length === 0) {\n event.preventDefault()\n container.focus()\n return\n }\n const first = items[0]\n const last = items[items.length - 1]\n const active = document.activeElement\n const inside = container.contains(active)\n if (event.shiftKey && (active === first || !inside)) {\n event.preventDefault()\n last.focus()\n } else if (!event.shiftKey && (active === last || !inside)) {\n event.preventDefault()\n first.focus()\n }\n}\n\nfunction push(entry) {\n stack.push(entry)\n if (!listening) {\n window.addEventListener('keydown', onWindowKeydown)\n listening = true\n }\n}\n\nfunction remove(entry) {\n const index = stack.indexOf(entry)\n if (index !== -1) stack.splice(index, 1)\n if (stack.length === 0 && listening) {\n window.removeEventListener('keydown', onWindowKeydown)\n listening = false\n }\n}\n\n// ── Composable ───────────────────────────────────────────────────────\n\n/**\n * Trap focus inside an element while `active()` is true.\n *\n * @param {() => HTMLElement | null | undefined} container Getter for the\n * element focus is confined to. It must itself be focusable\n * (`tabindex=\"-1\"`) so there is somewhere to land when it has no controls.\n * @param {object} options\n * @param {() => boolean} options.active Whether the trap is engaged.\n * @param {(() => boolean) | boolean} [options.escape] Whether Escape closes.\n * @param {() => void} [options.onEscape] Called when Escape should close.\n */\nexport function useFocusTrap(container, { active, escape = true, onEscape }) {\n const entry = {\n container: () => container() ?? null,\n onEscape: null,\n }\n let returnTo = null\n let engaged = false\n // The element as it was while open. A template ref is cleared the moment its\n // owner starts leaving, but a Transition keeps the element (and the focus\n // inside it) on screen for the length of the leave animation.\n let lastEl = null\n\n const engage = () => {\n if (engaged || typeof document === 'undefined') return\n engaged = true\n returnTo = document.activeElement\n entry.onEscape = () => {\n const allowed = typeof escape === 'function' ? escape() : escape\n if (allowed) onEscape?.()\n }\n push(entry)\n nextTick(() => {\n const el = entry.container()\n if (el) lastEl = el\n if (!el || el.contains(document.activeElement)) return\n const [first] = tabbableIn(el)\n ;(first ?? el).focus({ preventScroll: true })\n })\n }\n\n const release = () => {\n if (!engaged) return\n engaged = false\n remove(entry)\n const target = returnTo\n const closing = entry.container() ?? lastEl\n returnTo = null\n lastEl = null\n // Only restore if focus is still lost inside the closing surface or on the\n // body — never yank it away from somewhere the user has since moved to.\n if (target && typeof target.focus === 'function' && document.contains(target)) {\n const current = document.activeElement\n if (!current || current === document.body || closing?.contains(current)) {\n target.focus({ preventScroll: true })\n }\n }\n }\n\n watch(active, (on) => (on ? engage() : release()), { immediate: true, flush: 'post' })\n onBeforeUnmount(release)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,IAAM,YAAY;CAChB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC,CAAC,KAAK,GAAG;;;;;;;AAQV,SAAgB,WAAW,WAAW;CACpC,IAAI,CAAC,WAAW,OAAO,CAAC;CACxB,OAAO,CAAC,GAAG,UAAU,iBAAiB,SAAS,CAAC,CAAC,CAAC,QAC/C,OAAO,CAAC,GAAG,QAAQ,SAAS,KAAK,GAAG,eAAe,CAAC,CAAC,SAAS,CACjE;AACF;;AAKA,IAAM,QAAQ,CAAC;AACf,IAAI,YAAY;AAEhB,SAAS,gBAAgB,OAAO;CAC9B,MAAM,MAAM,MAAM,MAAM,SAAS;CACjC,IAAI,CAAC,KAAK;CACV,MAAM,YAAY,IAAI,UAAU;CAChC,IAAI,CAAC,WAAW;CAEhB,IAAI,MAAM,QAAQ,UAAU;EAG1B,IAAI,MAAM,oBAAoB,CAAC,IAAI,UAAU;EAC7C,MAAM,eAAe;EACrB,IAAI,SAAS;EACb;CACF;CAEA,IAAI,MAAM,QAAQ,OAAO;CACzB,MAAM,QAAQ,WAAW,SAAS;CAClC,IAAI,MAAM,WAAW,GAAG;EACtB,MAAM,eAAe;EACrB,UAAU,MAAM;EAChB;CACF;CACA,MAAM,QAAQ,MAAM;CACpB,MAAM,OAAO,MAAM,MAAM,SAAS;CAClC,MAAM,SAAS,SAAS;CACxB,MAAM,SAAS,UAAU,SAAS,MAAM;CACxC,IAAI,MAAM,aAAa,WAAW,SAAS,CAAC,SAAS;EACnD,MAAM,eAAe;EACrB,KAAK,MAAM;CACb,OAAO,IAAI,CAAC,MAAM,aAAa,WAAW,QAAQ,CAAC,SAAS;EAC1D,MAAM,eAAe;EACrB,MAAM,MAAM;CACd;AACF;AAEA,SAAS,KAAK,OAAO;CACnB,MAAM,KAAK,KAAK;CAChB,IAAI,CAAC,WAAW;EACd,OAAO,iBAAiB,WAAW,eAAe;EAClD,YAAY;CACd;AACF;AAEA,SAAS,OAAO,OAAO;CACrB,MAAM,QAAQ,MAAM,QAAQ,KAAK;CACjC,IAAI,UAAU,IAAI,MAAM,OAAO,OAAO,CAAC;CACvC,IAAI,MAAM,WAAW,KAAK,WAAW;EACnC,OAAO,oBAAoB,WAAW,eAAe;EACrD,YAAY;CACd;AACF;;;;;;;;;;;;AAeA,SAAgB,aAAa,WAAW,EAAE,QAAQ,SAAS,MAAM,YAAY;CAC3E,MAAM,QAAQ;EACZ,iBAAiB,UAAU,KAAK;EAChC,UAAU;CACZ;CACA,IAAI,WAAW;CACf,IAAI,UAAU;CAId,IAAI,SAAS;CAEb,MAAM,eAAe;EACnB,IAAI,WAAW,OAAO,aAAa,aAAa;EAChD,UAAU;EACV,WAAW,SAAS;EACpB,MAAM,iBAAiB;GAErB,IADgB,OAAO,WAAW,aAAa,OAAO,IAAI,QAC7C,WAAW;EAC1B;EACA,KAAK,KAAK;EACV,eAAe;GACb,MAAM,KAAK,MAAM,UAAU;GAC3B,IAAI,IAAI,SAAS;GACjB,IAAI,CAAC,MAAM,GAAG,SAAS,SAAS,aAAa,GAAG;GAChD,MAAM,CAAC,SAAS,WAAW,EAAE;GAC5B,CAAC,SAAS,GAAA,CAAI,MAAM,EAAE,eAAe,KAAK,CAAC;EAC9C,CAAC;CACH;CAEA,MAAM,gBAAgB;EACpB,IAAI,CAAC,SAAS;EACd,UAAU;EACV,OAAO,KAAK;EACZ,MAAM,SAAS;EACf,MAAM,UAAU,MAAM,UAAU,KAAK;EACrC,WAAW;EACX,SAAS;EAGT,IAAI,UAAU,OAAO,OAAO,UAAU,cAAc,SAAS,SAAS,MAAM,GAAG;GAC7E,MAAM,UAAU,SAAS;GACzB,IAAI,CAAC,WAAW,YAAY,SAAS,QAAQ,SAAS,SAAS,OAAO,GACpE,OAAO,MAAM,EAAE,eAAe,KAAK,CAAC;EAExC;CACF;CAEA,MAAM,SAAS,OAAQ,KAAK,OAAO,IAAI,QAAQ,GAAI;EAAE,WAAW;EAAM,OAAO;CAAO,CAAC;CACrF,gBAAgB,OAAO;AACzB"}
|
package/dist/manifest.js
CHANGED
|
@@ -28,10 +28,12 @@ var COMPONENT_NAMES = [
|
|
|
28
28
|
"Button",
|
|
29
29
|
"Card",
|
|
30
30
|
"Checkbox",
|
|
31
|
+
"ChipsInput",
|
|
31
32
|
"CodeBlock",
|
|
32
33
|
"CopyField",
|
|
33
34
|
"DescriptionList",
|
|
34
35
|
"Divider",
|
|
36
|
+
"Drawer",
|
|
35
37
|
"Dropdown",
|
|
36
38
|
"DropdownItem",
|
|
37
39
|
"DropdownRow",
|
|
@@ -58,8 +60,10 @@ var COMPONENT_NAMES = [
|
|
|
58
60
|
"Sidebar",
|
|
59
61
|
"SidebarGroup",
|
|
60
62
|
"SidebarItem",
|
|
63
|
+
"Skeleton",
|
|
61
64
|
"Slider",
|
|
62
65
|
"Spinner",
|
|
66
|
+
"SplitPane",
|
|
63
67
|
"StatCard",
|
|
64
68
|
"Stepper",
|
|
65
69
|
"Table",
|
|
@@ -67,7 +71,9 @@ var COMPONENT_NAMES = [
|
|
|
67
71
|
"ThemeToggle",
|
|
68
72
|
"Toast",
|
|
69
73
|
"Toggle",
|
|
70
|
-
"Tooltip"
|
|
74
|
+
"Tooltip",
|
|
75
|
+
"Tree",
|
|
76
|
+
"VirtualList"
|
|
71
77
|
];
|
|
72
78
|
/**
|
|
73
79
|
* The icon component is listed separately: it lives outside `components/`
|
package/dist/manifest.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest.js","names":[],"sources":["../src/manifest.js"],"sourcesContent":["/**\n * Component manifest — the single list of what Numori UI ships.\n *\n * Kept as plain data (no imports) so it can be consumed by things that must\n * not pull Vue or any `.vue` file into their graph: the Nuxt module and the\n * Vite plugin both run in Node at config time and only need names and paths.\n *\n * `src/components/index.js` holds the matching real imports for bundling. The\n * two are cross-checked by `scripts/verify.mjs`, so a component added in one\n * place and forgotten in the other fails the build rather than shipping\n * half-registered.\n */\n\n/** Default prefix for registered component names, e.g. `Ui` -> `<UiButton>`. */\nexport const DEFAULT_PREFIX = 'Ui'\n\n/**\n * Base names of every shipped component, without prefix or extension.\n * Order is alphabetical, matching the files on disk.\n * @type {string[]}\n */\nexport const COMPONENT_NAMES = [\n 'Alert',\n 'AppShell',\n 'Avatar',\n 'Badge',\n 'Banner',\n 'Breadcrumb',\n 'Button',\n 'Card',\n 'Checkbox',\n 'CodeBlock',\n 'CopyField',\n 'DescriptionList',\n 'Divider',\n 'Dropdown',\n 'DropdownItem',\n 'DropdownRow',\n 'DropdownSubmenu',\n 'EmptyState',\n 'FileInput',\n 'FormField',\n 'IconTile',\n 'Input',\n 'Kbd',\n 'ListMenu',\n 'ListMenuItem',\n 'Modal',\n 'Numpad',\n 'PageHeader',\n 'Pagination',\n 'Popup',\n 'ProgressBar',\n 'Prompt',\n 'Radio',\n 'SectionHeading',\n 'Segmented',\n 'Select',\n 'Sidebar',\n 'SidebarGroup',\n 'SidebarItem',\n 'Slider',\n 'Spinner',\n 'StatCard',\n 'Stepper',\n 'Table',\n 'Tabs',\n 'ThemeToggle',\n 'Toast',\n 'Toggle',\n 'Tooltip',\n]\n\n/**\n * The icon component is listed separately: it lives outside `components/`\n * because it is the framework seam rather than a UI primitive, and the other\n * components import it directly by path.\n */\nexport const ICON_COMPONENT = { name: 'Icon', file: 'icons/Icon.vue' }\n\n/**\n * Every registerable component as `{ name, file }`, where `file` is relative\n * to `src/`. Includes the icon component.\n * @returns {Array<{ name: string, file: string }>}\n */\nexport function componentEntries() {\n return [\n ...COMPONENT_NAMES.map((name) => ({ name, file: `components/${name}.vue` })),\n ICON_COMPONENT,\n ]\n}\n\n/**\n * Apply a prefix to a base component name.\n *\n * The prefix must be non-empty; the entry points validate this. Registering\n * bare names breaks `Button`, whose root is `<component :is=\"tag\">` with `tag`\n * defaulting to `'button'` — Vue capitalises when resolving dynamic components,\n * so a registered `Button` would match its own root element and recurse.\n *\n * @param {string} name Base name, e.g. 'Button'.\n * @param {string} [prefix=DEFAULT_PREFIX] Prefix to apply, e.g. 'Ui' or 'N'.\n * @returns {string} e.g. 'UiButton'\n */\nexport function prefixed(name, prefix = DEFAULT_PREFIX) {\n return `${prefix || ''}${name}`\n}\n"],"mappings":";;;;;;;;;;;;;;AAcA,IAAa,iBAAiB;;;;;;AAO9B,IAAa,kBAAkB;CAC7B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;;;AAOA,IAAa,iBAAiB;CAAE,MAAM;CAAQ,MAAM;AAAiB;;;;;;AAOrE,SAAgB,mBAAmB;CACjC,OAAO,CACL,GAAG,gBAAgB,KAAK,UAAU;EAAE;EAAM,MAAM,cAAc,KAAK;CAAM,EAAE,GAC3E,cACF;AACF;;;;;;;;;;;;;AAcA,SAAgB,SAAS,MAAM,SAAA,MAAyB;CACtD,OAAO,GAAG,UAAU,KAAK;AAC3B"}
|
|
1
|
+
{"version":3,"file":"manifest.js","names":[],"sources":["../src/manifest.js"],"sourcesContent":["/**\n * Component manifest — the single list of what Numori UI ships.\n *\n * Kept as plain data (no imports) so it can be consumed by things that must\n * not pull Vue or any `.vue` file into their graph: the Nuxt module and the\n * Vite plugin both run in Node at config time and only need names and paths.\n *\n * `src/components/index.js` holds the matching real imports for bundling. The\n * two are cross-checked by `scripts/verify.mjs`, so a component added in one\n * place and forgotten in the other fails the build rather than shipping\n * half-registered.\n */\n\n/** Default prefix for registered component names, e.g. `Ui` -> `<UiButton>`. */\nexport const DEFAULT_PREFIX = 'Ui'\n\n/**\n * Base names of every shipped component, without prefix or extension.\n * Order is alphabetical, matching the files on disk.\n * @type {string[]}\n */\nexport const COMPONENT_NAMES = [\n 'Alert',\n 'AppShell',\n 'Avatar',\n 'Badge',\n 'Banner',\n 'Breadcrumb',\n 'Button',\n 'Card',\n 'Checkbox',\n 'ChipsInput',\n 'CodeBlock',\n 'CopyField',\n 'DescriptionList',\n 'Divider',\n 'Drawer',\n 'Dropdown',\n 'DropdownItem',\n 'DropdownRow',\n 'DropdownSubmenu',\n 'EmptyState',\n 'FileInput',\n 'FormField',\n 'IconTile',\n 'Input',\n 'Kbd',\n 'ListMenu',\n 'ListMenuItem',\n 'Modal',\n 'Numpad',\n 'PageHeader',\n 'Pagination',\n 'Popup',\n 'ProgressBar',\n 'Prompt',\n 'Radio',\n 'SectionHeading',\n 'Segmented',\n 'Select',\n 'Sidebar',\n 'SidebarGroup',\n 'SidebarItem',\n 'Skeleton',\n 'Slider',\n 'Spinner',\n 'SplitPane',\n 'StatCard',\n 'Stepper',\n 'Table',\n 'Tabs',\n 'ThemeToggle',\n 'Toast',\n 'Toggle',\n 'Tooltip',\n 'Tree',\n 'VirtualList',\n]\n\n/**\n * The icon component is listed separately: it lives outside `components/`\n * because it is the framework seam rather than a UI primitive, and the other\n * components import it directly by path.\n */\nexport const ICON_COMPONENT = { name: 'Icon', file: 'icons/Icon.vue' }\n\n/**\n * Every registerable component as `{ name, file }`, where `file` is relative\n * to `src/`. Includes the icon component.\n * @returns {Array<{ name: string, file: string }>}\n */\nexport function componentEntries() {\n return [\n ...COMPONENT_NAMES.map((name) => ({ name, file: `components/${name}.vue` })),\n ICON_COMPONENT,\n ]\n}\n\n/**\n * Apply a prefix to a base component name.\n *\n * The prefix must be non-empty; the entry points validate this. Registering\n * bare names breaks `Button`, whose root is `<component :is=\"tag\">` with `tag`\n * defaulting to `'button'` — Vue capitalises when resolving dynamic components,\n * so a registered `Button` would match its own root element and recurse.\n *\n * @param {string} name Base name, e.g. 'Button'.\n * @param {string} [prefix=DEFAULT_PREFIX] Prefix to apply, e.g. 'Ui' or 'N'.\n * @returns {string} e.g. 'UiButton'\n */\nexport function prefixed(name, prefix = DEFAULT_PREFIX) {\n return `${prefix || ''}${name}`\n}\n"],"mappings":";;;;;;;;;;;;;;AAcA,IAAa,iBAAiB;;;;;;AAO9B,IAAa,kBAAkB;CAC7B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;;;AAOA,IAAa,iBAAiB;CAAE,MAAM;CAAQ,MAAM;AAAiB;;;;;;AAOrE,SAAgB,mBAAmB;CACjC,OAAO,CACL,GAAG,gBAAgB,KAAK,UAAU;EAAE;EAAM,MAAM,cAAc,KAAK;CAAM,EAAE,GAC3E,cACF;AACF;;;;;;;;;;;;;AAcA,SAAgB,SAAS,MAAM,SAAA,MAAyB;CACtD,OAAO,GAAG,UAAU,KAAK;AAC3B"}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "numori-ui",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
5
|
-
"description": "The Numori design system
|
|
4
|
+
"version": "0.7.0",
|
|
5
|
+
"description": "The Numori design system \u2014 a Tailwind 4 Vue 3 component library, consumable as a Nuxt module or a Vite plugin.",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Erik Bjerke",
|
|
8
8
|
"email": "contact@erikbjerke.com",
|
|
@@ -1,48 +1,80 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<!-- Circular avatar container with image or fallback icon -->
|
|
2
|
+
<!-- Circular avatar container with an image, initials or a fallback icon -->
|
|
3
3
|
<div
|
|
4
4
|
class="rounded-full flex items-center justify-center overflow-hidden shrink-0"
|
|
5
5
|
:class="[sizeClass, bgClass, ringClass]"
|
|
6
|
+
:role="showImage ? undefined : 'img'"
|
|
7
|
+
:aria-label="showImage ? undefined : alt"
|
|
6
8
|
>
|
|
7
|
-
<img
|
|
8
|
-
|
|
9
|
+
<img
|
|
10
|
+
v-if="showImage"
|
|
11
|
+
ref="imgRef"
|
|
12
|
+
:src="src"
|
|
13
|
+
:alt="alt"
|
|
14
|
+
class="w-full h-full object-cover"
|
|
15
|
+
@error="failed = true"
|
|
16
|
+
/>
|
|
17
|
+
<span
|
|
18
|
+
v-else-if="shownInitials"
|
|
19
|
+
class="font-semibold leading-none tracking-tight select-none"
|
|
20
|
+
:class="textSizeClass"
|
|
21
|
+
aria-hidden="true"
|
|
22
|
+
>{{ shownInitials }}</span
|
|
23
|
+
>
|
|
24
|
+
<UiIcon v-else :name="fallbackIcon" :class="iconSizeClass" aria-hidden="true" />
|
|
9
25
|
</div>
|
|
10
26
|
</template>
|
|
11
27
|
|
|
12
28
|
<script setup>
|
|
13
29
|
/**
|
|
14
|
-
* UiAvatar — Circular avatar component displaying an image or a fallback icon.
|
|
30
|
+
* UiAvatar — Circular avatar component displaying an image, initials or a fallback icon.
|
|
15
31
|
*
|
|
16
|
-
* When a `src` URL is provided, renders a cover-fit image
|
|
17
|
-
*
|
|
18
|
-
*
|
|
32
|
+
* When a `src` URL is provided, renders a cover-fit image; if the image fails
|
|
33
|
+
* to load, it falls back rather than showing a broken-image glyph. Without an
|
|
34
|
+
* image it shows `initials` (at most two characters, upper-cased), and without
|
|
35
|
+
* those a configurable fallback icon, on a colored background. Supports five
|
|
36
|
+
* sizes, two color themes for the fallback state, and an optional ring border.
|
|
37
|
+
*
|
|
38
|
+
* Without an image the avatar is exposed as `role="img"` named by `alt`, so
|
|
39
|
+
* pass the person's name there rather than the default.
|
|
19
40
|
*
|
|
20
41
|
* @example Image avatar
|
|
21
42
|
* <UiAvatar src="/img/user.jpg" alt="Jane Doe" size="lg" />
|
|
22
43
|
*
|
|
44
|
+
* @example Initials
|
|
45
|
+
* <UiAvatar initials="JD" alt="Jane Doe" />
|
|
46
|
+
*
|
|
23
47
|
* @example Fallback icon avatar with ring
|
|
24
48
|
* <UiAvatar size="md" color="primary" ring />
|
|
25
49
|
*
|
|
26
50
|
* @example Small gray avatar with custom icon
|
|
27
51
|
* <UiAvatar size="sm" color="gray" fallback-icon="mdi:account-group" />
|
|
28
52
|
*/
|
|
29
|
-
import { computed } from 'vue'
|
|
53
|
+
import { computed, onMounted, ref, watch } from 'vue'
|
|
30
54
|
import UiIcon from '../icons/Icon.vue'
|
|
55
|
+
|
|
31
56
|
const props = defineProps({
|
|
32
57
|
/**
|
|
33
|
-
* Image source URL. When empty
|
|
58
|
+
* Image source URL. When empty (or it fails to load), initials or the
|
|
59
|
+
* fallback icon are shown.
|
|
34
60
|
* @type {string}
|
|
35
61
|
* @default ''
|
|
36
62
|
*/
|
|
37
63
|
src: { type: String, default: '' },
|
|
38
|
-
|
|
39
64
|
/**
|
|
40
|
-
* Alt text for the avatar image (accessibility)
|
|
65
|
+
* Alt text for the avatar image (accessibility), and the accessible name
|
|
66
|
+
* when initials or the icon are shown.
|
|
41
67
|
* @type {string}
|
|
42
68
|
* @default 'Avatar'
|
|
43
69
|
*/
|
|
44
70
|
alt: { type: String, default: 'Avatar' },
|
|
45
|
-
|
|
71
|
+
/**
|
|
72
|
+
* Initials shown when there is no image. Trimmed to two characters and
|
|
73
|
+
* upper-cased.
|
|
74
|
+
* @type {string}
|
|
75
|
+
* @default ''
|
|
76
|
+
*/
|
|
77
|
+
initials: { type: String, default: '' },
|
|
46
78
|
/**
|
|
47
79
|
* Avatar size controlling width, height, and icon dimensions.
|
|
48
80
|
* @type {string}
|
|
@@ -50,14 +82,12 @@ const props = defineProps({
|
|
|
50
82
|
* @values 'xs' (24px) | 'sm' (32px) | 'md' (36px) | 'lg' (48px) | 'xl' (64px)
|
|
51
83
|
*/
|
|
52
84
|
size: { type: String, default: 'md' },
|
|
53
|
-
|
|
54
85
|
/**
|
|
55
|
-
* MDI icon name used when
|
|
86
|
+
* MDI icon name used when there is neither an image nor initials.
|
|
56
87
|
* @type {string}
|
|
57
88
|
* @default 'mdi:account'
|
|
58
89
|
*/
|
|
59
90
|
fallbackIcon: { type: String, default: 'mdi:account' },
|
|
60
|
-
|
|
61
91
|
/**
|
|
62
92
|
* Background color theme for the fallback icon state.
|
|
63
93
|
* @type {string}
|
|
@@ -65,7 +95,6 @@ const props = defineProps({
|
|
|
65
95
|
* @values 'primary' | 'gray'
|
|
66
96
|
*/
|
|
67
97
|
color: { type: String, default: 'primary' },
|
|
68
|
-
|
|
69
98
|
/**
|
|
70
99
|
* Show a ring border around the avatar for emphasis.
|
|
71
100
|
* @type {boolean}
|
|
@@ -74,6 +103,23 @@ const props = defineProps({
|
|
|
74
103
|
ring: { type: Boolean, default: false },
|
|
75
104
|
})
|
|
76
105
|
|
|
106
|
+
// A failed load falls back to initials or the icon; a new src retries.
|
|
107
|
+
const failed = ref(false)
|
|
108
|
+
const imgRef = ref(null)
|
|
109
|
+
watch(
|
|
110
|
+
() => props.src,
|
|
111
|
+
() => (failed.value = false),
|
|
112
|
+
)
|
|
113
|
+
// Server-rendered images can fail before hydration attaches `@error`, so the
|
|
114
|
+
// event is never seen. Check once on mount for an image that already failed.
|
|
115
|
+
onMounted(() => {
|
|
116
|
+
const img = imgRef.value
|
|
117
|
+
if (img && img.complete && img.naturalWidth === 0) failed.value = true
|
|
118
|
+
})
|
|
119
|
+
const showImage = computed(() => !!props.src && !failed.value)
|
|
120
|
+
|
|
121
|
+
const shownInitials = computed(() => [...props.initials.trim()].slice(0, 2).join('').toUpperCase())
|
|
122
|
+
|
|
77
123
|
const sizeClass = computed(() => {
|
|
78
124
|
const map = { xs: 'w-6 h-6', sm: 'w-8 h-8', md: 'w-9 h-9', lg: 'w-12 h-12', xl: 'w-16 h-16' }
|
|
79
125
|
return map[props.size] || map.md
|
|
@@ -84,9 +130,14 @@ const iconSizeClass = computed(() => {
|
|
|
84
130
|
return map[props.size] || map.md
|
|
85
131
|
})
|
|
86
132
|
|
|
87
|
-
|
|
133
|
+
const textSizeClass = computed(() => {
|
|
134
|
+
const map = { xs: 'text-[10px]', sm: 'text-xs', md: 'text-sm', lg: 'text-base', xl: 'text-xl' }
|
|
135
|
+
return map[props.size] || map.md
|
|
136
|
+
})
|
|
137
|
+
|
|
138
|
+
// Only apply background color when not showing an image
|
|
88
139
|
const bgClass = computed(() => {
|
|
89
|
-
if (
|
|
140
|
+
if (showImage.value) return ''
|
|
90
141
|
const map = {
|
|
91
142
|
primary: 'bg-primary-100 dark:bg-primary-900/30 text-primary-600 dark:text-primary-400',
|
|
92
143
|
gray: 'bg-gray-200 dark:bg-gray-700 text-gray-500 dark:text-gray-400',
|