numori-ui 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  import { MDI_VIEW_BOX } from "./mdi.js";
2
2
  import { resolveIconPath } from "./registry.js";
3
3
  import { useIconComponent } from "./resolver.js";
4
- import { computed, defineComponent, h } from "vue";
4
+ import { computed, defineComponent, h, resolveComponent } from "vue";
5
5
  //#region src/icons/Icon.vue
6
6
  /**
7
7
  * UiIcon — renders an icon by name, either from the bundled Material Design
@@ -92,11 +92,14 @@ name: {
92
92
  return rest;
93
93
  });
94
94
  return () => {
95
- if (hostComponent) return h(hostComponent, {
96
- ...restAttrs.value,
97
- name: props.name,
98
- class: sizeClass.value
99
- });
95
+ if (hostComponent) {
96
+ const comp = typeof hostComponent === "string" ? resolveComponent(hostComponent) : hostComponent;
97
+ return h(comp, {
98
+ ...restAttrs.value,
99
+ name: props.name,
100
+ class: sizeClass.value
101
+ });
102
+ }
100
103
  if (path.value) return h("svg", {
101
104
  ...restAttrs.value,
102
105
  class: sizeClass.value,
@@ -1 +1 @@
1
- {"version":3,"file":"Icon.js","names":[],"sources":["../../src/icons/Icon.vue"],"sourcesContent":["<script>\n/**\n * UiIcon — renders an icon by name, either from the bundled Material Design\n * Icons subset or through a host-supplied icon component.\n *\n * This is the seam that lets Numori UI stay framework-agnostic. Numori Notes\n * used `<Icon>` from `@nuxt/icon`, which only exists inside Nuxt; this\n * component gives the same ergonomics with no framework coupling:\n *\n * - **Default** — draws inline SVG from the MDI paths bundled in `mdi.js`.\n * Zero dependencies, zero network requests, SSR-safe.\n * - **Overridden** — if the host provided a component (via the plugin's\n * `icons.component` option or `provideIconComponent`), every icon is\n * delegated to it, so an app that already ships an icon system does not end\n * up with two.\n *\n * Only the icons the library itself needs are bundled. To draw others without\n * replacing the whole renderer, add them with `registerIcons()`.\n *\n * Sizing and colour come from classes, exactly as they did before: the class you\n * pass lands on the rendered element, and the SVG fills with `currentColor`, so\n * `text-*` utilities colour icons the same way they colour text.\n *\n * ---\n *\n * Why a render function instead of a `<template>`:\n *\n * `viewBox` is case-sensitive, and Vue's SSR runtime lowercases the keys of a\n * merged prop bag — `ssrRenderAttrs({ viewBox })` emits `viewbox=\"…\"`. Because\n * this `<svg>` also needs a dynamic `class`, a template always goes through that\n * path, and no amount of writing `viewBox` in the template survives it. Browsers\n * paper over it (the HTML parser's foreign-content attribute adjustment maps\n * `viewbox` back to `viewBox`), but the emitted markup is still invalid SVG and\n * breaks anything that parses it as XML or post-processes the HTML.\n *\n * Building the vnode directly keeps the prop object intact, so the attribute is\n * serialised with its real casing on both the server and the client. This is the\n * only component in the library that emits raw SVG, so it is the only one that\n * has to care.\n *\n * @example\n * <UiIcon name=\"mdi:check\" class=\"w-4 h-4\" />\n *\n * @example Inherits the parent's text colour\n * <span class=\"text-primary-600\"><UiIcon name=\"mdi:alert-circle\" class=\"w-5 h-5\" /></span>\n */\nimport { computed, defineComponent, h } from 'vue'\nimport { MDI_VIEW_BOX } from './mdi.js'\nimport { resolveIconPath } from './registry.js'\nimport { useIconComponent } from './resolver.js'\n\nexport default defineComponent({\n name: 'UiIcon',\n\n // Attributes are placed deliberately: `class` is merged into the sizing\n // logic below, and everything else is forwarded to whichever element wins.\n inheritAttrs: false,\n\n props: {\n /**\n * Icon name. The bundled set uses the `mdi:` prefix, e.g. `'mdi:check'`.\n * A bare name (`'check'`) is also accepted and treated as MDI.\n *\n * Optional rather than required on purpose. Several components pass an\n * optional icon prop straight through (`<UiIcon :name=\"icon\" />`), so\n * requiring it would emit a Vue warning every time a caller legitimately\n * omitted the icon. An empty or missing name renders the placeholder\n * branch, which reserves the same box without drawing anything.\n */\n name: { type: String, default: '' },\n },\n\n setup(props, { attrs }) {\n // Read at setup time: injection is not available inside a render function.\n const hostComponent = useIconComponent()\n\n /**\n * Icons are sized by the caller, so the incoming `class` is kept verbatim.\n * A default square is added only when the caller supplied no dimensions,\n * which stops an un-sized icon collapsing to zero height.\n */\n const sizeClass = computed(() => {\n const external = attrs.class || ''\n const hasSize = /(^|\\s)(w-|h-|size-)/.test(String(external))\n return [hasSize ? '' : 'w-4 h-4', 'inline-block shrink-0', external].filter(Boolean)\n })\n\n /**\n * Resolved through the registry rather than the generated map directly, so\n * icons added at runtime with `registerIcons()` are found too.\n */\n const path = computed(() => (props.name ? resolveIconPath(props.name) : null))\n\n /** Forwarded attributes minus `class`, which sizeClass already absorbed. */\n const restAttrs = computed(() => {\n const { class: _class, ...rest } = attrs\n return rest\n })\n\n return () => {\n // 1. Host-supplied renderer wins, so the app keeps one icon pipeline.\n // A string is allowed and resolves as a globally registered component,\n // which is how the Nuxt module forwards e.g. @nuxt/icon's <Icon>.\n if (hostComponent) {\n return h(hostComponent, {\n ...restAttrs.value,\n name: props.name,\n class: sizeClass.value,\n })\n }\n\n // 2. Bundled inline SVG. `currentColor` makes colour inherit from text.\n if (path.value) {\n return h(\n 'svg',\n {\n ...restAttrs.value,\n class: sizeClass.value,\n viewBox: MDI_VIEW_BOX,\n xmlns: 'http://www.w3.org/2000/svg',\n fill: 'currentColor',\n 'aria-hidden': 'true',\n focusable: 'false',\n },\n [h('path', { d: path.value })],\n )\n }\n\n // 3. Unknown name: hold the same box so layout does not shift, and stay\n // invisible rather than rendering a broken glyph.\n return h('span', {\n ...restAttrs.value,\n class: sizeClass.value,\n 'aria-hidden': 'true',\n })\n }\n },\n})\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmDA,IAAK,YAAa,gBAAa;CAC7B,MAAM;CAIN,cAAc;CAEd,OAAO;;;;;;;;;;;AAWL,MAAM;EAAE,MAAM;EAAQ,SAAS;CAAG,EACpC;CAEA,MAAM,OAAO,EAAE,SAAS;EAEtB,MAAM,gBAAgB,iBAAiB;;;;;;EAOvC,MAAM,YAAY,eAAe;GAC/B,MAAM,WAAW,MAAM,SAAS;GAEhC,OAAO;IADS,sBAAsB,KAAK,OAAO,QAAQ,CAC5C,IAAI,KAAK;IAAW;IAAyB;GAAQ,CAAC,CAAC,OAAO,OAAO;EACrF,CAAC;;;;;EAMD,MAAM,OAAO,eAAgB,MAAM,OAAO,gBAAgB,MAAM,IAAI,IAAI,IAAK;;EAG7E,MAAM,YAAY,eAAe;GAC/B,MAAM,EAAE,OAAO,QAAQ,GAAG,SAAS;GACnC,OAAO;EACT,CAAC;EAED,aAAa;GAIX,IAAI,eACF,OAAO,EAAE,eAAe;IACtB,GAAG,UAAU;IACb,MAAM,MAAM;IACZ,OAAO,UAAU;GACnB,CAAC;GAIH,IAAI,KAAK,OACP,OAAO,EACL,OACA;IACE,GAAG,UAAU;IACb,OAAO,UAAU;IACjB,SAAS;IACT,OAAO;IACP,MAAM;IACN,eAAe;IACf,WAAW;GACb,GACA,CAAC,EAAE,QAAQ,EAAE,GAAG,KAAK,MAAM,CAAC,CAAC,CAC/B;GAKF,OAAO,EAAE,QAAQ;IACf,GAAG,UAAU;IACb,OAAO,UAAU;IACjB,eAAe;GACjB,CAAC;EACH;CACF;AACF,CAAC"}
1
+ {"version":3,"file":"Icon.js","names":[],"sources":["../../src/icons/Icon.vue"],"sourcesContent":["<script>\n/**\n * UiIcon — renders an icon by name, either from the bundled Material Design\n * Icons subset or through a host-supplied icon component.\n *\n * This is the seam that lets Numori UI stay framework-agnostic. Numori Notes\n * used `<Icon>` from `@nuxt/icon`, which only exists inside Nuxt; this\n * component gives the same ergonomics with no framework coupling:\n *\n * - **Default** — draws inline SVG from the MDI paths bundled in `mdi.js`.\n * Zero dependencies, zero network requests, SSR-safe.\n * - **Overridden** — if the host provided a component (via the plugin's\n * `icons.component` option or `provideIconComponent`), every icon is\n * delegated to it, so an app that already ships an icon system does not end\n * up with two.\n *\n * Only the icons the library itself needs are bundled. To draw others without\n * replacing the whole renderer, add them with `registerIcons()`.\n *\n * Sizing and colour come from classes, exactly as they did before: the class you\n * pass lands on the rendered element, and the SVG fills with `currentColor`, so\n * `text-*` utilities colour icons the same way they colour text.\n *\n * ---\n *\n * Why a render function instead of a `<template>`:\n *\n * `viewBox` is case-sensitive, and Vue's SSR runtime lowercases the keys of a\n * merged prop bag — `ssrRenderAttrs({ viewBox })` emits `viewbox=\"…\"`. Because\n * this `<svg>` also needs a dynamic `class`, a template always goes through that\n * path, and no amount of writing `viewBox` in the template survives it. Browsers\n * paper over it (the HTML parser's foreign-content attribute adjustment maps\n * `viewbox` back to `viewBox`), but the emitted markup is still invalid SVG and\n * breaks anything that parses it as XML or post-processes the HTML.\n *\n * Building the vnode directly keeps the prop object intact, so the attribute is\n * serialised with its real casing on both the server and the client. This is the\n * only component in the library that emits raw SVG, so it is the only one that\n * has to care.\n *\n * @example\n * <UiIcon name=\"mdi:check\" class=\"w-4 h-4\" />\n *\n * @example Inherits the parent's text colour\n * <span class=\"text-primary-600\"><UiIcon name=\"mdi:alert-circle\" class=\"w-5 h-5\" /></span>\n */\nimport { computed, defineComponent, h, resolveComponent } from 'vue'\nimport { MDI_VIEW_BOX } from './mdi.js'\nimport { resolveIconPath } from './registry.js'\nimport { useIconComponent } from './resolver.js'\n\nexport default defineComponent({\n name: 'UiIcon',\n\n // Attributes are placed deliberately: `class` is merged into the sizing\n // logic below, and everything else is forwarded to whichever element wins.\n inheritAttrs: false,\n\n props: {\n /**\n * Icon name. The bundled set uses the `mdi:` prefix, e.g. `'mdi:check'`.\n * A bare name (`'check'`) is also accepted and treated as MDI.\n *\n * Optional rather than required on purpose. Several components pass an\n * optional icon prop straight through (`<UiIcon :name=\"icon\" />`), so\n * requiring it would emit a Vue warning every time a caller legitimately\n * omitted the icon. An empty or missing name renders the placeholder\n * branch, which reserves the same box without drawing anything.\n */\n name: { type: String, default: '' },\n },\n\n setup(props, { attrs }) {\n // Read at setup time: injection is not available inside a render function.\n const hostComponent = useIconComponent()\n\n /**\n * Icons are sized by the caller, so the incoming `class` is kept verbatim.\n * A default square is added only when the caller supplied no dimensions,\n * which stops an un-sized icon collapsing to zero height.\n */\n const sizeClass = computed(() => {\n const external = attrs.class || ''\n const hasSize = /(^|\\s)(w-|h-|size-)/.test(String(external))\n return [hasSize ? '' : 'w-4 h-4', 'inline-block shrink-0', external].filter(Boolean)\n })\n\n /**\n * Resolved through the registry rather than the generated map directly, so\n * icons added at runtime with `registerIcons()` are found too.\n */\n const path = computed(() => (props.name ? resolveIconPath(props.name) : null))\n\n /** Forwarded attributes minus `class`, which sizeClass already absorbed. */\n const restAttrs = computed(() => {\n const { class: _class, ...rest } = attrs\n return rest\n })\n\n return () => {\n // 1. Host-supplied renderer wins, so the app keeps one icon pipeline.\n // A string is allowed and resolves as a globally registered component,\n // which is how the Nuxt module forwards e.g. @nuxt/icon's <Icon>.\n if (hostComponent) {\n // A string names a globally registered component (e.g. @nuxt/icon's\n // <Icon>). In a render function that must be resolved explicitly:\n // h('Icon', …) would emit a literal <Icon> element, not the component.\n const comp =\n typeof hostComponent === 'string' ? resolveComponent(hostComponent) : hostComponent\n return h(comp, {\n ...restAttrs.value,\n name: props.name,\n class: sizeClass.value,\n })\n }\n\n // 2. Bundled inline SVG. `currentColor` makes colour inherit from text.\n if (path.value) {\n return h(\n 'svg',\n {\n ...restAttrs.value,\n class: sizeClass.value,\n viewBox: MDI_VIEW_BOX,\n xmlns: 'http://www.w3.org/2000/svg',\n fill: 'currentColor',\n 'aria-hidden': 'true',\n focusable: 'false',\n },\n [h('path', { d: path.value })],\n )\n }\n\n // 3. Unknown name: hold the same box so layout does not shift, and stay\n // invisible rather than rendering a broken glyph.\n return h('span', {\n ...restAttrs.value,\n class: sizeClass.value,\n 'aria-hidden': 'true',\n })\n }\n },\n})\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmDA,IAAK,YAAa,gBAAa;CAC7B,MAAM;CAIN,cAAc;CAEd,OAAO;;;;;;;;;;;AAWL,MAAM;EAAE,MAAM;EAAQ,SAAS;CAAG,EACpC;CAEA,MAAM,OAAO,EAAE,SAAS;EAEtB,MAAM,gBAAgB,iBAAiB;;;;;;EAOvC,MAAM,YAAY,eAAe;GAC/B,MAAM,WAAW,MAAM,SAAS;GAEhC,OAAO;IADS,sBAAsB,KAAK,OAAO,QAAQ,CAC5C,IAAI,KAAK;IAAW;IAAyB;GAAQ,CAAC,CAAC,OAAO,OAAO;EACrF,CAAC;;;;;EAMD,MAAM,OAAO,eAAgB,MAAM,OAAO,gBAAgB,MAAM,IAAI,IAAI,IAAK;;EAG7E,MAAM,YAAY,eAAe;GAC/B,MAAM,EAAE,OAAO,QAAQ,GAAG,SAAS;GACnC,OAAO;EACT,CAAC;EAED,aAAa;GAIX,IAAI,eAAe;IAIjB,MAAM,OACJ,OAAO,kBAAkB,WAAW,iBAAiB,aAAa,IAAI;IACxE,OAAO,EAAE,MAAM;KACb,GAAG,UAAU;KACb,MAAM,MAAM;KACZ,OAAO,UAAU;IACnB,CAAC;GACH;GAGA,IAAI,KAAK,OACP,OAAO,EACL,OACA;IACE,GAAG,UAAU;IACb,OAAO,UAAU;IACjB,SAAS;IACT,OAAO;IACP,MAAM;IACN,eAAe;IACf,WAAW;GACb,GACA,CAAC,EAAE,QAAQ,EAAE,GAAG,KAAK,MAAM,CAAC,CAAC,CAC/B;GAKF,OAAO,EAAE,QAAQ;IACf,GAAG,UAAU;IACb,OAAO,UAAU;IACjB,eAAe;GACjB,CAAC;EACH;CACF;AACF,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "numori-ui",
3
3
  "type": "module",
4
- "version": "0.1.0",
4
+ "version": "0.1.1",
5
5
  "description": "The Numori design system — a Tailwind 4 Vue 3 component library, consumable as a Nuxt module or a Vite plugin.",
6
6
  "author": {
7
7
  "name": "Erik Bjerke",
@@ -19,7 +19,7 @@
19
19
  "url": "https://theprocedural.com"
20
20
  }
21
21
  ],
22
- "license": "AGPL-3.0",
22
+ "license": "AGPL-3.0-or-later",
23
23
  "homepage": "https://github.com/Numori-Ecosystem/Numori-UI",
24
24
  "repository": {
25
25
  "type": "git",
@@ -123,8 +123,8 @@
123
123
  },
124
124
  "devDependencies": {
125
125
  "@eslint/js": "^10.0.1",
126
- "@nuxt/kit": "^4.5.2",
127
126
  "@iconify-json/mdi": "^1.2.3",
127
+ "@nuxt/kit": "^4.5.2",
128
128
  "@vitejs/plugin-vue": "^6.0.8",
129
129
  "eslint": "^10.8.0",
130
130
  "eslint-plugin-vue": "^10.10.0",
@@ -44,7 +44,7 @@
44
44
  * @example Inherits the parent's text colour
45
45
  * <span class="text-primary-600"><UiIcon name="mdi:alert-circle" class="w-5 h-5" /></span>
46
46
  */
47
- import { computed, defineComponent, h } from 'vue'
47
+ import { computed, defineComponent, h, resolveComponent } from 'vue'
48
48
  import { MDI_VIEW_BOX } from './mdi.js'
49
49
  import { resolveIconPath } from './registry.js'
50
50
  import { useIconComponent } from './resolver.js'
@@ -102,7 +102,12 @@ export default defineComponent({
102
102
  // A string is allowed and resolves as a globally registered component,
103
103
  // which is how the Nuxt module forwards e.g. @nuxt/icon's <Icon>.
104
104
  if (hostComponent) {
105
- return h(hostComponent, {
105
+ // A string names a globally registered component (e.g. @nuxt/icon's
106
+ // <Icon>). In a render function that must be resolved explicitly:
107
+ // h('Icon', …) would emit a literal <Icon> element, not the component.
108
+ const comp =
109
+ typeof hostComponent === 'string' ? resolveComponent(hostComponent) : hostComponent
110
+ return h(comp, {
106
111
  ...restAttrs.value,
107
112
  name: props.name,
108
113
  class: sizeClass.value,