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.
Files changed (130) hide show
  1. package/LICENSE +651 -0
  2. package/README.md +466 -0
  3. package/dist/components/Alert.js +137 -0
  4. package/dist/components/Alert.js.map +1 -0
  5. package/dist/components/Avatar.js +133 -0
  6. package/dist/components/Avatar.js.map +1 -0
  7. package/dist/components/Badge.js +93 -0
  8. package/dist/components/Badge.js.map +1 -0
  9. package/dist/components/Button.js +428 -0
  10. package/dist/components/Button.js.map +1 -0
  11. package/dist/components/ButtonsGroup.js +153 -0
  12. package/dist/components/ButtonsGroup.js.map +1 -0
  13. package/dist/components/Checkbox.js +93 -0
  14. package/dist/components/Checkbox.js.map +1 -0
  15. package/dist/components/Divider.js +79 -0
  16. package/dist/components/Divider.js.map +1 -0
  17. package/dist/components/Dropdown.js +166 -0
  18. package/dist/components/Dropdown.js.map +1 -0
  19. package/dist/components/DropdownItem.js +106 -0
  20. package/dist/components/DropdownItem.js.map +1 -0
  21. package/dist/components/DropdownRow.js +41 -0
  22. package/dist/components/DropdownRow.js.map +1 -0
  23. package/dist/components/DropdownSubmenu.js +142 -0
  24. package/dist/components/DropdownSubmenu.js.map +1 -0
  25. package/dist/components/FileInput.js +122 -0
  26. package/dist/components/FileInput.js.map +1 -0
  27. package/dist/components/FormField.js +112 -0
  28. package/dist/components/FormField.js.map +1 -0
  29. package/dist/components/Input.js +603 -0
  30. package/dist/components/Input.js.map +1 -0
  31. package/dist/components/Kbd.js +35 -0
  32. package/dist/components/Kbd.js.map +1 -0
  33. package/dist/components/ListMenu.js +143 -0
  34. package/dist/components/ListMenu.js.map +1 -0
  35. package/dist/components/ListMenuItem.js +189 -0
  36. package/dist/components/ListMenuItem.js.map +1 -0
  37. package/dist/components/Modal.js +206 -0
  38. package/dist/components/Modal.js.map +1 -0
  39. package/dist/components/Numpad.js +123 -0
  40. package/dist/components/Numpad.js.map +1 -0
  41. package/dist/components/Popup.js +170 -0
  42. package/dist/components/Popup.js.map +1 -0
  43. package/dist/components/ProgressBar.js +118 -0
  44. package/dist/components/ProgressBar.js.map +1 -0
  45. package/dist/components/Prompt.js +201 -0
  46. package/dist/components/Prompt.js.map +1 -0
  47. package/dist/components/Radio.js +81 -0
  48. package/dist/components/Radio.js.map +1 -0
  49. package/dist/components/Select.js +441 -0
  50. package/dist/components/Select.js.map +1 -0
  51. package/dist/components/Slider.js +116 -0
  52. package/dist/components/Slider.js.map +1 -0
  53. package/dist/components/Stepper.js +65 -0
  54. package/dist/components/Stepper.js.map +1 -0
  55. package/dist/components/Toggle.js +133 -0
  56. package/dist/components/Toggle.js.map +1 -0
  57. package/dist/components/Tooltip.js +120 -0
  58. package/dist/components/Tooltip.js.map +1 -0
  59. package/dist/components/index.js +81 -0
  60. package/dist/components/index.js.map +1 -0
  61. package/dist/composables/onClickOutside.js +51 -0
  62. package/dist/composables/onClickOutside.js.map +1 -0
  63. package/dist/composables/useBackButton.js +98 -0
  64. package/dist/composables/useBackButton.js.map +1 -0
  65. package/dist/composables/useEventListener.js +63 -0
  66. package/dist/composables/useEventListener.js.map +1 -0
  67. package/dist/icons/Icon.js +120 -0
  68. package/dist/icons/Icon.js.map +1 -0
  69. package/dist/icons/mdi.js +69 -0
  70. package/dist/icons/mdi.js.map +1 -0
  71. package/dist/icons/registry.js +63 -0
  72. package/dist/icons/registry.js.map +1 -0
  73. package/dist/icons/resolver.js +49 -0
  74. package/dist/icons/resolver.js.map +1 -0
  75. package/dist/index.d.ts +108 -0
  76. package/dist/index.js +157 -0
  77. package/dist/index.js.map +1 -0
  78. package/dist/manifest.js +89 -0
  79. package/dist/manifest.js.map +1 -0
  80. package/dist/numori-ui.css +184 -0
  81. package/dist/nuxt.d.ts +35 -0
  82. package/dist/nuxt.mjs +243 -0
  83. package/dist/nuxt.mjs.map +1 -0
  84. package/dist/vite.d.ts +29 -0
  85. package/dist/vite.mjs +187 -0
  86. package/dist/vite.mjs.map +1 -0
  87. package/package.json +138 -0
  88. package/src/components/Alert.vue +127 -0
  89. package/src/components/Avatar.vue +100 -0
  90. package/src/components/Badge.vue +77 -0
  91. package/src/components/Button.vue +419 -0
  92. package/src/components/ButtonsGroup.vue +140 -0
  93. package/src/components/Checkbox.vue +81 -0
  94. package/src/components/Divider.vue +64 -0
  95. package/src/components/Dropdown.vue +150 -0
  96. package/src/components/DropdownItem.vue +78 -0
  97. package/src/components/DropdownRow.vue +37 -0
  98. package/src/components/DropdownSubmenu.vue +127 -0
  99. package/src/components/FileInput.vue +107 -0
  100. package/src/components/FormField.vue +86 -0
  101. package/src/components/Input.vue +619 -0
  102. package/src/components/Kbd.vue +30 -0
  103. package/src/components/ListMenu.vue +127 -0
  104. package/src/components/ListMenuItem.vue +171 -0
  105. package/src/components/Modal.vue +209 -0
  106. package/src/components/Numpad.vue +118 -0
  107. package/src/components/Popup.vue +156 -0
  108. package/src/components/ProgressBar.vue +107 -0
  109. package/src/components/Prompt.vue +161 -0
  110. package/src/components/Radio.vue +50 -0
  111. package/src/components/Select.vue +470 -0
  112. package/src/components/Slider.vue +93 -0
  113. package/src/components/Stepper.vue +53 -0
  114. package/src/components/Toggle.vue +125 -0
  115. package/src/components/Tooltip.vue +113 -0
  116. package/src/components/index.js +109 -0
  117. package/src/composables/onClickOutside.js +61 -0
  118. package/src/composables/useBackButton.js +98 -0
  119. package/src/composables/useEventListener.js +65 -0
  120. package/src/icons/Icon.vue +139 -0
  121. package/src/icons/mdi.js +67 -0
  122. package/src/icons/registry.js +64 -0
  123. package/src/icons/resolver.js +48 -0
  124. package/src/index.js +167 -0
  125. package/src/manifest.js +86 -0
  126. package/src/nuxt.js +315 -0
  127. package/src/style.css +20 -0
  128. package/src/tailwind.css +18 -0
  129. package/src/theme.css +172 -0
  130. package/src/vite.js +235 -0
@@ -0,0 +1,139 @@
1
+ <script>
2
+ /**
3
+ * UiIcon — renders an icon by name, either from the bundled Material Design
4
+ * Icons subset or through a host-supplied icon component.
5
+ *
6
+ * This is the seam that lets Numori UI stay framework-agnostic. Numori Notes
7
+ * used `<Icon>` from `@nuxt/icon`, which only exists inside Nuxt; this
8
+ * component gives the same ergonomics with no framework coupling:
9
+ *
10
+ * - **Default** — draws inline SVG from the MDI paths bundled in `mdi.js`.
11
+ * Zero dependencies, zero network requests, SSR-safe.
12
+ * - **Overridden** — if the host provided a component (via the plugin's
13
+ * `icons.component` option or `provideIconComponent`), every icon is
14
+ * delegated to it, so an app that already ships an icon system does not end
15
+ * up with two.
16
+ *
17
+ * Only the icons the library itself needs are bundled. To draw others without
18
+ * replacing the whole renderer, add them with `registerIcons()`.
19
+ *
20
+ * Sizing and colour come from classes, exactly as they did before: the class you
21
+ * pass lands on the rendered element, and the SVG fills with `currentColor`, so
22
+ * `text-*` utilities colour icons the same way they colour text.
23
+ *
24
+ * ---
25
+ *
26
+ * Why a render function instead of a `<template>`:
27
+ *
28
+ * `viewBox` is case-sensitive, and Vue's SSR runtime lowercases the keys of a
29
+ * merged prop bag — `ssrRenderAttrs({ viewBox })` emits `viewbox="…"`. Because
30
+ * this `<svg>` also needs a dynamic `class`, a template always goes through that
31
+ * path, and no amount of writing `viewBox` in the template survives it. Browsers
32
+ * paper over it (the HTML parser's foreign-content attribute adjustment maps
33
+ * `viewbox` back to `viewBox`), but the emitted markup is still invalid SVG and
34
+ * breaks anything that parses it as XML or post-processes the HTML.
35
+ *
36
+ * Building the vnode directly keeps the prop object intact, so the attribute is
37
+ * serialised with its real casing on both the server and the client. This is the
38
+ * only component in the library that emits raw SVG, so it is the only one that
39
+ * has to care.
40
+ *
41
+ * @example
42
+ * <UiIcon name="mdi:check" class="w-4 h-4" />
43
+ *
44
+ * @example Inherits the parent's text colour
45
+ * <span class="text-primary-600"><UiIcon name="mdi:alert-circle" class="w-5 h-5" /></span>
46
+ */
47
+ import { computed, defineComponent, h } from 'vue'
48
+ import { MDI_VIEW_BOX } from './mdi.js'
49
+ import { resolveIconPath } from './registry.js'
50
+ import { useIconComponent } from './resolver.js'
51
+
52
+ export default defineComponent({
53
+ name: 'UiIcon',
54
+
55
+ // Attributes are placed deliberately: `class` is merged into the sizing
56
+ // logic below, and everything else is forwarded to whichever element wins.
57
+ inheritAttrs: false,
58
+
59
+ props: {
60
+ /**
61
+ * Icon name. The bundled set uses the `mdi:` prefix, e.g. `'mdi:check'`.
62
+ * A bare name (`'check'`) is also accepted and treated as MDI.
63
+ *
64
+ * Optional rather than required on purpose. Several components pass an
65
+ * optional icon prop straight through (`<UiIcon :name="icon" />`), so
66
+ * requiring it would emit a Vue warning every time a caller legitimately
67
+ * omitted the icon. An empty or missing name renders the placeholder
68
+ * branch, which reserves the same box without drawing anything.
69
+ */
70
+ name: { type: String, default: '' },
71
+ },
72
+
73
+ setup(props, { attrs }) {
74
+ // Read at setup time: injection is not available inside a render function.
75
+ const hostComponent = useIconComponent()
76
+
77
+ /**
78
+ * Icons are sized by the caller, so the incoming `class` is kept verbatim.
79
+ * A default square is added only when the caller supplied no dimensions,
80
+ * which stops an un-sized icon collapsing to zero height.
81
+ */
82
+ const sizeClass = computed(() => {
83
+ const external = attrs.class || ''
84
+ const hasSize = /(^|\s)(w-|h-|size-)/.test(String(external))
85
+ return [hasSize ? '' : 'w-4 h-4', 'inline-block shrink-0', external].filter(Boolean)
86
+ })
87
+
88
+ /**
89
+ * Resolved through the registry rather than the generated map directly, so
90
+ * icons added at runtime with `registerIcons()` are found too.
91
+ */
92
+ const path = computed(() => (props.name ? resolveIconPath(props.name) : null))
93
+
94
+ /** Forwarded attributes minus `class`, which sizeClass already absorbed. */
95
+ const restAttrs = computed(() => {
96
+ const { class: _class, ...rest } = attrs
97
+ return rest
98
+ })
99
+
100
+ return () => {
101
+ // 1. Host-supplied renderer wins, so the app keeps one icon pipeline.
102
+ // A string is allowed and resolves as a globally registered component,
103
+ // which is how the Nuxt module forwards e.g. @nuxt/icon's <Icon>.
104
+ if (hostComponent) {
105
+ return h(hostComponent, {
106
+ ...restAttrs.value,
107
+ name: props.name,
108
+ class: sizeClass.value,
109
+ })
110
+ }
111
+
112
+ // 2. Bundled inline SVG. `currentColor` makes colour inherit from text.
113
+ if (path.value) {
114
+ return h(
115
+ 'svg',
116
+ {
117
+ ...restAttrs.value,
118
+ class: sizeClass.value,
119
+ viewBox: MDI_VIEW_BOX,
120
+ xmlns: 'http://www.w3.org/2000/svg',
121
+ fill: 'currentColor',
122
+ 'aria-hidden': 'true',
123
+ focusable: 'false',
124
+ },
125
+ [h('path', { d: path.value })],
126
+ )
127
+ }
128
+
129
+ // 3. Unknown name: hold the same box so layout does not shift, and stay
130
+ // invisible rather than rendering a broken glyph.
131
+ return h('span', {
132
+ ...restAttrs.value,
133
+ class: sizeClass.value,
134
+ 'aria-hidden': 'true',
135
+ })
136
+ }
137
+ },
138
+ })
139
+ </script>
@@ -0,0 +1,67 @@
1
+ /**
2
+ * GENERATED FILE — do not edit by hand.
3
+ * Regenerate with: npm run icons
4
+ *
5
+ * Inline path data for the Material Design Icons used by Numori UI, keyed by
6
+ * icon name without the `mdi:` prefix. All paths are drawn on a 24x24 grid
7
+ * and filled with `currentColor`.
8
+ *
9
+ * Material Design Icons — https://pictogrammers.com/library/mdi/
10
+ * Copyright (c) Austin Andrews and contributors, licensed under Apache-2.0:
11
+ * https://github.com/Templarian/MaterialDesign/blob/master/LICENSE
12
+ * Icon data sourced from @iconify-json/mdi.
13
+ */
14
+
15
+ /** Shared viewBox for every icon in this set. */
16
+ export const MDI_VIEW_BOX = '0 0 24 24'
17
+
18
+ /** @type {Record<string, string>} */
19
+ export const mdiPaths = {
20
+ '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",
21
+ '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",
22
+ '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",
23
+ 'alert-outline': "M12 2L1 21h22M12 6l7.53 13H4.47M11 10v4h2v-4m-2 6v2h2v-2",
24
+ '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",
25
+ 'check': "M21 7L9 19l-5.5-5.5l1.41-1.41L9 16.17L19.59 5.59z",
26
+ '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",
27
+ 'chevron-down': "M7.41 8.58L12 13.17l4.59-4.59L18 10l-6 6l-6-6z",
28
+ 'chevron-right': "M8.59 16.58L13.17 12L8.59 7.41L10 6l6 6l-6 6z",
29
+ 'chevron-up': "M7.41 15.41L12 10.83l4.59 4.58L18 14l-6-6l-6 6z",
30
+ '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",
31
+ '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",
32
+ 'delete': "M19 4h-3.5l-1-1h-5l-1 1H5v2h14M6 19a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V7H6z",
33
+ '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",
34
+ '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",
35
+ '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",
36
+ '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",
37
+ '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",
38
+ '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",
39
+ 'format-italic': "M10 4v3h2.21l-3.42 8H6v3h8v-3h-2.21l3.42-8H18V4z",
40
+ '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",
41
+ '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",
42
+ 'loading': "M12 4V2A10 10 0 0 0 2 12h2a8 8 0 0 1 8-8",
43
+ '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",
44
+ '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",
45
+ 'minus': "M19 13H5v-2h14z",
46
+ '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",
47
+ '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",
48
+ 'plus': "M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6z",
49
+ 'share': "m21 12l-7-7v4C7 10 4 15 3 20c2.5-3.5 6-5.1 11-5.1V19z",
50
+ '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",
51
+ 'trash-can': "M9 3v1H4v2h1v13a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V6h1V4h-5V3zm0 5h2v9H9zm4 0h2v9h-2z",
52
+ 'trash-can-outline': "M9 3v1H4v2h1v13a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V6h1V4h-5V3zM7 6h10v13H7zm2 2v9h2V8zm4 0v9h2V8z",
53
+ 'view-grid': "M3 11h8V3H3m0 18h8v-8H3m10 8h8v-8h-8m0-10v8h8V3",
54
+ 'view-list': "M9 5v4h12V5M9 19h12v-4H9m0-1h12v-4H9M4 9h4V5H4m0 14h4v-4H4m0-1h4v-4H4z",
55
+ '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",
56
+ }
57
+
58
+ /**
59
+ * Icon names available in the bundled subset.
60
+ *
61
+ * Annotated pure so bundlers can drop it. Without the annotation this
62
+ * top-level `Object.keys` call is treated as a possible side effect, which
63
+ * keeps `mdiPaths` reachable and forces every icon into any bundle that
64
+ * touches this package — even one importing only `UiKbd`, which draws no
65
+ * icons.
66
+ */
67
+ export const mdiIconNames = /*#__PURE__*/ Object.keys(mdiPaths)
@@ -0,0 +1,64 @@
1
+ import { shallowRef } from 'vue'
2
+ import { mdiPaths } from './mdi.js'
3
+
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
+ /**
22
+ * The `/*#__PURE__*\/` annotation matters for tree-shaking. This is a top-level
23
+ * function call, which a bundler must assume has side effects and therefore
24
+ * cannot remove — and because its argument spreads `mdiPaths`, keeping it alive
25
+ * also keeps every bundled icon path alive. That put the whole icon set into any
26
+ * bundle importing any component, even `UiKbd`, which draws no icons at all.
27
+ *
28
+ * Marking it pure lets the bundler drop the registry when nothing references it,
29
+ * and `mdiPaths` then falls away with it.
30
+ *
31
+ * @type {import('vue').ShallowRef<Record<string, string>>}
32
+ */
33
+ export const iconRegistry = /*#__PURE__*/ shallowRef({ ...mdiPaths })
34
+
35
+ /**
36
+ * Add icons to the registry, or override bundled ones.
37
+ *
38
+ * Keys may be bare (`'rocket'`) or prefixed (`'mdi:rocket'`) — the prefix is
39
+ * stripped, matching how `<UiIcon>` looks names up. Values are the `d`
40
+ * attribute of a path drawn on a 24x24 grid.
41
+ *
42
+ * @param {Record<string, string>} icons Map of icon name to SVG path data.
43
+ *
44
+ * @example
45
+ * import { registerIcons } from 'numori-ui'
46
+ * registerIcons({ rocket: 'M12 2c...' })
47
+ * // <UiIcon name="mdi:rocket" class="w-5 h-5" />
48
+ */
49
+ export function registerIcons(icons) {
50
+ const next = { ...iconRegistry.value }
51
+ for (const [name, path] of Object.entries(icons)) {
52
+ next[name.replace(/^[a-z0-9]+:/i, '')] = path
53
+ }
54
+ iconRegistry.value = next
55
+ }
56
+
57
+ /**
58
+ * Look up path data for an icon name.
59
+ * @param {string} name Icon name, with or without a set prefix.
60
+ * @returns {string | null}
61
+ */
62
+ export function resolveIconPath(name) {
63
+ return iconRegistry.value[String(name).replace(/^[a-z0-9]+:/i, '')] || null
64
+ }
@@ -0,0 +1,48 @@
1
+ import { inject, provide } from 'vue'
2
+
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
+
17
+ /** Injection key for a host-supplied icon component. */
18
+ export const ICON_COMPONENT_KEY = Symbol('numori-ui:icon-component')
19
+
20
+ /**
21
+ * Provide a custom icon component for every Numori UI icon below this point in
22
+ * the tree. Call from a parent component's setup, or use the `icons.component`
23
+ * option on the Vue plugin / Nuxt module to apply it app-wide.
24
+ *
25
+ * The component receives a single `name` prop (e.g. `'mdi:check'`) plus any
26
+ * `class` the calling component applied for sizing and colour, so it must
27
+ * accept and forward `class` to its root element.
28
+ *
29
+ * @param {import('vue').Component | string} component
30
+ * Component (or globally registered component name) to render icons with.
31
+ *
32
+ * @example Delegate to @nuxt/icon inside a Nuxt app
33
+ * // plugins/numori-ui-icons.js
34
+ * import { provideIconComponent } from 'numori-ui'
35
+ * // in a parent component's setup():
36
+ * provideIconComponent(resolveComponent('Icon'))
37
+ */
38
+ export function provideIconComponent(component) {
39
+ provide(ICON_COMPONENT_KEY, component)
40
+ }
41
+
42
+ /**
43
+ * Read the host-supplied icon component, if any.
44
+ * @returns {import('vue').Component | string | null}
45
+ */
46
+ export function useIconComponent() {
47
+ return inject(ICON_COMPONENT_KEY, null)
48
+ }
package/src/index.js ADDED
@@ -0,0 +1,167 @@
1
+ /**
2
+ * Numori UI — the Numori design system as a standalone Vue 3 component library.
3
+ *
4
+ * This is the framework-agnostic entry point. It works in any Vue 3 app with
5
+ * no build-tool integration at all:
6
+ *
7
+ * import { createApp } from 'vue'
8
+ * import NumoriUI from 'numori-ui'
9
+ * import './app.css' // @import "tailwindcss"; @import "numori-ui/css";
10
+ *
11
+ * createApp(App).use(NumoriUI).mount('#app')
12
+ *
13
+ * For a nicer developer experience there are two build-tool integrations that
14
+ * register the components for you, so templates need no imports:
15
+ *
16
+ * - `numori-ui/nuxt` — a Nuxt module
17
+ * - `numori-ui/vite` — a Vite plugin
18
+ *
19
+ * Styling is Tailwind CSS v4 and is deliberately NOT bundled as compiled CSS.
20
+ * The components are plain utility classes, so they inherit the host app's
21
+ * Tailwind build: one pass, one stylesheet, no duplication, and every token is
22
+ * overridable. All the host has to do is import `numori-ui/css`, which supplies
23
+ * the design tokens and tells Tailwind to scan this package for classes.
24
+ */
25
+
26
+ import { components } from './components/index.js'
27
+ import { DEFAULT_PREFIX, prefixed } from './manifest.js'
28
+ import { ICON_COMPONENT_KEY } from './icons/resolver.js'
29
+ import { registerIcons } from './icons/registry.js'
30
+
31
+ export * from './components/index.js'
32
+
33
+ export { DEFAULT_PREFIX, COMPONENT_NAMES, componentEntries, prefixed } from './manifest.js'
34
+ export { registerIcons, iconRegistry, resolveIconPath } from './icons/registry.js'
35
+ export { provideIconComponent, useIconComponent, ICON_COMPONENT_KEY } from './icons/resolver.js'
36
+ export { MDI_VIEW_BOX, mdiPaths, mdiIconNames } from './icons/mdi.js'
37
+ export { useBackButton } from './composables/useBackButton.js'
38
+ export { onClickOutside } from './composables/onClickOutside.js'
39
+ export { useEventListener } from './composables/useEventListener.js'
40
+
41
+ /**
42
+ * Vue plugin that globally registers every Numori UI component.
43
+ *
44
+ * @type {import('vue').Plugin}
45
+ *
46
+ * @param {import('vue').App} app
47
+ * @param {object} [options]
48
+ * @param {string} [options.prefix='Ui']
49
+ * Prefix for registered tags. `'Ui'` gives `<UiButton>`. Must be non-empty —
50
+ * see the note in `install` for why.
51
+ * @param {string[]} [options.include]
52
+ * Register only these base names (e.g. `['Button', 'Modal']`). Note this
53
+ * affects *global registration* only — it is not tree-shaking. To actually
54
+ * drop unused components from the bundle, skip the plugin and import the
55
+ * components you use directly.
56
+ * @param {string[]} [options.exclude]
57
+ * Skip these base names. Useful when the host has its own `<UiButton>`.
58
+ * @param {object} [options.icons]
59
+ * @param {import('vue').Component|string} [options.icons.component]
60
+ * Render all icons with this component instead of the bundled inline SVGs.
61
+ * Receives a `name` prop and must forward `class` to its root element.
62
+ * @param {Record<string,string>} [options.icons.extra]
63
+ * Extra icon path data to add to the bundled set, keyed by name.
64
+ *
65
+ * @example Default registration
66
+ * app.use(NumoriUI)
67
+ *
68
+ * @example Custom prefix
69
+ * app.use(NumoriUI, { prefix: 'N' }) // <NButton>
70
+ *
71
+ * @example Delegate icons to an existing icon component
72
+ * app.use(NumoriUI, { icons: { component: MyIcon } })
73
+ */
74
+ export const NumoriUI = {
75
+ install(app, options = {}) {
76
+ const { prefix = DEFAULT_PREFIX, include, exclude = [], icons = {} } = options
77
+
78
+ // An empty prefix is rejected rather than merely discouraged. `Button`
79
+ // renders its root as `<component :is="tag">` with `tag` defaulting to
80
+ // `'button'`, and Vue's dynamic-component lookup capitalises before
81
+ // matching — so a globally registered `Button` would resolve `'button'`
82
+ // back to itself and recurse until the stack blows. The failure is a bare
83
+ // "Maximum call stack size exceeded" with no hint of the cause, so it is
84
+ // much kinder to refuse up front.
85
+ if (typeof prefix !== 'string' || prefix.length === 0) {
86
+ throw new Error(
87
+ '[numori-ui] `prefix` must be a non-empty string. Registering components under their ' +
88
+ 'bare names would make <Button> resolve its own native `button` root element, ' +
89
+ 'recursing infinitely. Use a prefix such as "Ui" or "N".',
90
+ )
91
+ }
92
+
93
+ if (icons.extra) registerIcons(icons.extra)
94
+ // app-level provide, so it reaches every component including those
95
+ // teleported out of the tree (modals, select panels).
96
+ if (icons.component) app.provide(ICON_COMPONENT_KEY, icons.component)
97
+
98
+ for (const [name, component] of Object.entries(components)) {
99
+ if (include && !include.includes(name)) continue
100
+ if (exclude.includes(name)) continue
101
+ app.component(prefixed(name, prefix), component)
102
+ }
103
+ },
104
+ }
105
+
106
+ export default NumoriUI
107
+
108
+ /**
109
+ * Build a Vue plugin that globally registers only the components you hand it.
110
+ *
111
+ * `NumoriUI` is convenient but it is not tree-shakeable: to register everything
112
+ * it has to reference everything, so `app.use(NumoriUI)` puts all 29 components
113
+ * in your bundle (~82 kB) whether you render them or not. The `include` option
114
+ * does not change that — it controls registration, not bundling.
115
+ *
116
+ * This factory is the way to get both. You import the components you want, so
117
+ * the bundler sees exactly that set and drops the rest, and you still get global
118
+ * tags instead of importing them into every file.
119
+ *
120
+ * Keys become the registered tag names verbatim, so no prefix option is needed
121
+ * and there is no naming magic — rename in the object literal if you want a
122
+ * different tag.
123
+ *
124
+ * @param {Record<string, import('vue').Component>} components
125
+ * Map of tag name to component, e.g. `{ UiButton, UiModal }`.
126
+ * @param {object} [options]
127
+ * @param {object} [options.icons] Same shape as the `NumoriUI` plugin's option.
128
+ * @returns {import('vue').Plugin}
129
+ *
130
+ * @example Global tags, but only two components bundled
131
+ * import { createNumoriUI, UiButton, UiModal } from 'numori-ui'
132
+ *
133
+ * app.use(createNumoriUI({ UiButton, UiModal }))
134
+ *
135
+ * @example Registering under different tag names
136
+ * app.use(createNumoriUI({ NButton: UiButton, NModal: UiModal }))
137
+ */
138
+ export function createNumoriUI(components = {}, options = {}) {
139
+ const { icons = {} } = options
140
+
141
+ // `UiButton` renders its root as `<component :is="tag">`, and Vue capitalises
142
+ // when resolving a dynamic component. Registering it under a name that
143
+ // case-insensitively matches one of those tags would make it resolve itself
144
+ // and recurse until the stack overflows, reported only as "Maximum call stack
145
+ // size exceeded". Cheap to catch here, miserable to debug later.
146
+ const DYNAMIC_TAGS = ['button', 'a', 'div', 'span', 'label', 'li']
147
+ for (const name of Object.keys(components)) {
148
+ if (DYNAMIC_TAGS.includes(name.toLowerCase())) {
149
+ throw new Error(
150
+ `[numori-ui] Cannot register a component as "${name}": it collides with the native <${name.toLowerCase()}> ` +
151
+ 'element that UiButton can render as its root, which would recurse infinitely. ' +
152
+ `Use a prefixed name such as "Ui${name}".`,
153
+ )
154
+ }
155
+ }
156
+
157
+ return {
158
+ install(app) {
159
+ if (icons.extra) registerIcons(icons.extra)
160
+ if (icons.component) app.provide(ICON_COMPONENT_KEY, icons.component)
161
+
162
+ for (const [name, component] of Object.entries(components)) {
163
+ app.component(name, component)
164
+ }
165
+ },
166
+ }
167
+ }
@@ -0,0 +1,86 @@
1
+ /**
2
+ * Component manifest — the single list of what Numori UI ships.
3
+ *
4
+ * Kept as plain data (no imports) so it can be consumed by things that must
5
+ * not pull Vue or any `.vue` file into their graph: the Nuxt module and the
6
+ * Vite plugin both run in Node at config time and only need names and paths.
7
+ *
8
+ * `src/components/index.js` holds the matching real imports for bundling. The
9
+ * two are cross-checked by `scripts/verify.mjs`, so a component added in one
10
+ * place and forgotten in the other fails the build rather than shipping
11
+ * half-registered.
12
+ */
13
+
14
+ /** Default prefix for registered component names, e.g. `Ui` -> `<UiButton>`. */
15
+ export const DEFAULT_PREFIX = 'Ui'
16
+
17
+ /**
18
+ * Base names of every shipped component, without prefix or extension.
19
+ * Order is alphabetical, matching the files on disk.
20
+ * @type {string[]}
21
+ */
22
+ export const COMPONENT_NAMES = [
23
+ 'Alert',
24
+ 'Avatar',
25
+ 'Badge',
26
+ 'Button',
27
+ 'ButtonsGroup',
28
+ 'Checkbox',
29
+ 'Divider',
30
+ 'Dropdown',
31
+ 'DropdownItem',
32
+ 'DropdownRow',
33
+ 'DropdownSubmenu',
34
+ 'FileInput',
35
+ 'FormField',
36
+ 'Input',
37
+ 'Kbd',
38
+ 'ListMenu',
39
+ 'ListMenuItem',
40
+ 'Modal',
41
+ 'Numpad',
42
+ 'Popup',
43
+ 'ProgressBar',
44
+ 'Prompt',
45
+ 'Radio',
46
+ 'Select',
47
+ 'Slider',
48
+ 'Stepper',
49
+ 'Toggle',
50
+ 'Tooltip',
51
+ ]
52
+
53
+ /**
54
+ * The icon component is listed separately: it lives outside `components/`
55
+ * because it is the framework seam rather than a UI primitive, and the other
56
+ * components import it directly by path.
57
+ */
58
+ export const ICON_COMPONENT = { name: 'Icon', file: 'icons/Icon.vue' }
59
+
60
+ /**
61
+ * Every registerable component as `{ name, file }`, where `file` is relative
62
+ * to `src/`. Includes the icon component.
63
+ * @returns {Array<{ name: string, file: string }>}
64
+ */
65
+ export function componentEntries() {
66
+ return [
67
+ ...COMPONENT_NAMES.map((name) => ({ name, file: `components/${name}.vue` })),
68
+ ICON_COMPONENT,
69
+ ]
70
+ }
71
+
72
+ /**
73
+ * Apply a prefix to a base component name.
74
+ *
75
+ * The prefix must be non-empty; the entry points validate this. Registering
76
+ * bare names breaks `Button`, whose root is `<component :is="tag">` with `tag`
77
+ * defaulting to `'button'` — Vue capitalises when resolving dynamic components,
78
+ * so a registered `Button` would match its own root element and recurse.
79
+ *
80
+ * @param {string} name Base name, e.g. 'Button'.
81
+ * @param {string} [prefix=DEFAULT_PREFIX] Prefix to apply, e.g. 'Ui' or 'N'.
82
+ * @returns {string} e.g. 'UiButton'
83
+ */
84
+ export function prefixed(name, prefix = DEFAULT_PREFIX) {
85
+ return `${prefix || ''}${name}`
86
+ }