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.
Files changed (54) hide show
  1. package/CHANGELOG.md +85 -0
  2. package/README.md +11 -3
  3. package/dist/components/Avatar.js +71 -19
  4. package/dist/components/Avatar.js.map +1 -1
  5. package/dist/components/ChipsInput.js +423 -0
  6. package/dist/components/ChipsInput.js.map +1 -0
  7. package/dist/components/Drawer.js +236 -0
  8. package/dist/components/Drawer.js.map +1 -0
  9. package/dist/components/Dropdown.js +4 -2
  10. package/dist/components/Dropdown.js.map +1 -1
  11. package/dist/components/Modal.js +61 -4
  12. package/dist/components/Modal.js.map +1 -1
  13. package/dist/components/Prompt.js +11 -6
  14. package/dist/components/Prompt.js.map +1 -1
  15. package/dist/components/Select.js +1 -1
  16. package/dist/components/Select.js.map +1 -1
  17. package/dist/components/Skeleton.js +122 -0
  18. package/dist/components/Skeleton.js.map +1 -0
  19. package/dist/components/SplitPane.js +264 -0
  20. package/dist/components/SplitPane.js.map +1 -0
  21. package/dist/components/Toast.js +62 -16
  22. package/dist/components/Toast.js.map +1 -1
  23. package/dist/components/Tree.js +417 -0
  24. package/dist/components/Tree.js.map +1 -0
  25. package/dist/components/VirtualList.js +292 -0
  26. package/dist/components/VirtualList.js.map +1 -0
  27. package/dist/components/index.js +93 -82
  28. package/dist/components/index.js.map +1 -1
  29. package/dist/icons/mdi.js +3 -0
  30. package/dist/icons/mdi.js.map +1 -1
  31. package/dist/index.d.ts +6 -0
  32. package/dist/index.js +49 -43
  33. package/dist/index.js.map +1 -1
  34. package/dist/internal/focusTrap.js +163 -0
  35. package/dist/internal/focusTrap.js.map +1 -0
  36. package/dist/manifest.js +7 -1
  37. package/dist/manifest.js.map +1 -1
  38. package/package.json +2 -2
  39. package/src/components/Avatar.vue +69 -18
  40. package/src/components/ChipsInput.vue +387 -0
  41. package/src/components/Drawer.vue +213 -0
  42. package/src/components/Dropdown.vue +4 -1
  43. package/src/components/Modal.vue +51 -3
  44. package/src/components/Prompt.vue +14 -3
  45. package/src/components/Select.vue +1 -1
  46. package/src/components/Skeleton.vue +91 -0
  47. package/src/components/SplitPane.vue +264 -0
  48. package/src/components/Toast.vue +57 -13
  49. package/src/components/Tree.vue +428 -0
  50. package/src/components/VirtualList.vue +250 -0
  51. package/src/components/index.js +18 -1
  52. package/src/icons/mdi.js +3 -0
  53. package/src/internal/focusTrap.js +185 -0
  54. package/src/manifest.js +6 -0
@@ -18,10 +18,12 @@ import Breadcrumb from './Breadcrumb.vue'
18
18
  import Button from './Button.vue'
19
19
  import Card from './Card.vue'
20
20
  import Checkbox from './Checkbox.vue'
21
+ import ChipsInput from './ChipsInput.vue'
21
22
  import CodeBlock from './CodeBlock.vue'
22
23
  import CopyField from './CopyField.vue'
23
24
  import DescriptionList from './DescriptionList.vue'
24
25
  import Divider from './Divider.vue'
26
+ import Drawer from './Drawer.vue'
25
27
  import Dropdown from './Dropdown.vue'
26
28
  import DropdownItem from './DropdownItem.vue'
27
29
  import DropdownRow from './DropdownRow.vue'
@@ -48,8 +50,10 @@ import Select from './Select.vue'
48
50
  import Sidebar from './Sidebar.vue'
49
51
  import SidebarGroup from './SidebarGroup.vue'
50
52
  import SidebarItem from './SidebarItem.vue'
53
+ import Skeleton from './Skeleton.vue'
51
54
  import Slider from './Slider.vue'
52
55
  import Spinner from './Spinner.vue'
56
+ import SplitPane from './SplitPane.vue'
53
57
  import StatCard from './StatCard.vue'
54
58
  import Stepper from './Stepper.vue'
55
59
  import Table from './Table.vue'
@@ -58,6 +62,8 @@ import ThemeToggle from './ThemeToggle.vue'
58
62
  import Toast from './Toast.vue'
59
63
  import Toggle from './Toggle.vue'
60
64
  import Tooltip from './Tooltip.vue'
65
+ import Tree from './Tree.vue'
66
+ import VirtualList from './VirtualList.vue'
61
67
  import Icon from '../icons/Icon.vue'
62
68
 
63
69
  export {
@@ -70,10 +76,12 @@ export {
70
76
  Button as UiButton,
71
77
  Card as UiCard,
72
78
  Checkbox as UiCheckbox,
79
+ ChipsInput as UiChipsInput,
73
80
  CodeBlock as UiCodeBlock,
74
81
  CopyField as UiCopyField,
75
82
  DescriptionList as UiDescriptionList,
76
83
  Divider as UiDivider,
84
+ Drawer as UiDrawer,
77
85
  Dropdown as UiDropdown,
78
86
  DropdownItem as UiDropdownItem,
79
87
  DropdownRow as UiDropdownRow,
@@ -100,8 +108,10 @@ export {
100
108
  Sidebar as UiSidebar,
101
109
  SidebarGroup as UiSidebarGroup,
102
110
  SidebarItem as UiSidebarItem,
111
+ Skeleton as UiSkeleton,
103
112
  Slider as UiSlider,
104
113
  Spinner as UiSpinner,
114
+ SplitPane as UiSplitPane,
105
115
  StatCard as UiStatCard,
106
116
  Stepper as UiStepper,
107
117
  Table as UiTable,
@@ -110,6 +120,8 @@ export {
110
120
  Toast as UiToast,
111
121
  Toggle as UiToggle,
112
122
  Tooltip as UiTooltip,
123
+ Tree as UiTree,
124
+ VirtualList as UiVirtualList,
113
125
  Icon as UiIcon,
114
126
  }
115
127
 
@@ -123,10 +135,12 @@ export const components = {
123
135
  Button,
124
136
  Card,
125
137
  Checkbox,
138
+ ChipsInput,
126
139
  CodeBlock,
127
140
  CopyField,
128
141
  DescriptionList,
129
142
  Divider,
143
+ Drawer,
130
144
  Dropdown,
131
145
  DropdownItem,
132
146
  DropdownRow,
@@ -153,8 +167,10 @@ export const components = {
153
167
  Sidebar,
154
168
  SidebarGroup,
155
169
  SidebarItem,
170
+ Skeleton,
156
171
  Slider,
157
172
  Spinner,
173
+ SplitPane,
158
174
  StatCard,
159
175
  Stepper,
160
176
  Table,
@@ -163,5 +179,6 @@ export const components = {
163
179
  Toast,
164
180
  Toggle,
165
181
  Tooltip,
166
- Icon,
182
+ Tree,
183
+ VirtualList,
167
184
  }
package/src/icons/mdi.js CHANGED
@@ -21,6 +21,7 @@ export const mdiPaths = {
21
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
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
23
  'alert-outline': "M12 2L1 21h22M12 6l7.53 13H4.47M11 10v4h2v-4m-2 6v2h2v-2",
24
+ 'archive-outline': "M20 21H4V10h2v9h12v-9h2zM3 3h18v6H3zm6.5 8h5c.28 0 .5.22.5.5V13H9v-1.5c0-.28.22-.5.5-.5M5 5v2h14V5z",
24
25
  'arrow-down': "M11 4h2v12l5.5-5.5l1.42 1.42L12 19.84l-7.92-7.92L5.5 10.5L11 16z",
25
26
  'arrow-up': "M13 20h-2V8l-5.5 5.5l-1.42-1.42L12 4.16l7.92 7.92l-1.42 1.42L13 8z",
26
27
  '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",
@@ -41,9 +42,11 @@ export const mdiPaths = {
41
42
  '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",
42
43
  '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",
43
44
  'file-document-outline': "M6 2a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8l-6-6zm0 2h7v5h5v11H6zm2 8v2h8v-2zm0 4v2h5v-2z",
45
+ 'folder-outline': "M20 18H4V8h16m0-2h-8l-2-2H4c-1.11 0-2 .89-2 2v12a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2",
44
46
  '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",
45
47
  'format-italic': "M10 4v3h2.21l-3.42 8H6v3h8v-3h-2.21l3.42-8H18V4z",
46
48
  '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",
49
+ 'inbox': "M19 15h-4a3 3 0 0 1-3 3a3 3 0 0 1-3-3H5V5h14m0-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2",
47
50
  'inbox-outline': "M19 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2M5 19v-2h3.13a4.13 4.13 0 0 0 1.27 2m9.6 0h-4.4a4.13 4.13 0 0 0 1.27-2H19m0-2h-5v1a2 2 0 0 1-4 0v-1H5V5h14Z",
48
51
  '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",
49
52
  'lan-connect': "M4 1c-1.11 0-2 .89-2 2v4c0 1.11.89 2 2 2H1v2h12V9h-3c1.11 0 2-.89 2-2V3c0-1.11-.89-2-2-2zm0 2h6v4H4zM3 13v7h7v-2H5v-5zm11 0c-1.11 0-2 .89-2 2v4c0 1.11.89 2 2 2h-3v2h12v-2h-3c1.11 0 2-.89 2-2v-4c0-1.11-.89-2-2-2zm0 2h6v4h-6z",
@@ -0,0 +1,185 @@
1
+ /**
2
+ * Focus management for modal surfaces (`UiModal`, and anything built on it).
3
+ *
4
+ * A modal dialog has three keyboard obligations under the WAI-ARIA dialog
5
+ * pattern, and all three are easy to get subtly wrong:
6
+ *
7
+ * 1. **Move focus in** when it opens — otherwise a keyboard user is left on
8
+ * the button behind the backdrop, and a screen reader never announces the
9
+ * dialog.
10
+ * 2. **Keep focus in** while it is open — Tab from the last control wraps to
11
+ * the first, Shift+Tab from the first wraps to the last.
12
+ * 3. **Put focus back** when it closes, on whatever opened it.
13
+ *
14
+ * Escape also closes the dialog, unless the caller says otherwise.
15
+ *
16
+ * Dialogs can stack (a confirmation over a settings modal), and only the top
17
+ * one may react to Tab or Escape — so every trap registers on a module-level
18
+ * stack and a single listener dispatches to whichever is on top.
19
+ *
20
+ * That listener is on `window`, not `document`, deliberately: `window` is the
21
+ * last stop of a bubbling keydown, so a control inside the dialog that closes
22
+ * itself on Escape (an open `UiDropdown`, `UiSelect`'s search field) runs first
23
+ * and calls `preventDefault()`, and the dialog then leaves the key alone. One
24
+ * Escape closes one thing.
25
+ *
26
+ * Initial focus is only moved if nothing inside the container already has it.
27
+ * That lets a wrapper such as `UiPrompt` focus its confirm button without the
28
+ * trap then stealing focus back to the first control.
29
+ *
30
+ * SSR-safe: nothing touches `document` until the trap activates, which only
31
+ * happens in the browser.
32
+ */
33
+ import { nextTick, onBeforeUnmount, watch } from 'vue'
34
+
35
+ // ── Focusable elements ───────────────────────────────────────────────
36
+
37
+ const FOCUSABLE = [
38
+ 'a[href]',
39
+ 'area[href]',
40
+ 'button:not([disabled])',
41
+ 'input:not([disabled]):not([type="hidden"])',
42
+ 'select:not([disabled])',
43
+ 'textarea:not([disabled])',
44
+ 'iframe',
45
+ 'audio[controls]',
46
+ 'video[controls]',
47
+ '[contenteditable]:not([contenteditable="false"])',
48
+ '[tabindex]:not([tabindex="-1"])',
49
+ ].join(',')
50
+
51
+ /**
52
+ * Tabbable descendants of `container`, in DOM order, skipping anything hidden.
53
+ *
54
+ * @param {HTMLElement} container
55
+ * @returns {HTMLElement[]}
56
+ */
57
+ export function tabbableIn(container) {
58
+ if (!container) return []
59
+ return [...container.querySelectorAll(FOCUSABLE)].filter(
60
+ (el) => !el.closest('[inert]') && el.getClientRects().length > 0,
61
+ )
62
+ }
63
+
64
+ // ── The stack of active traps ────────────────────────────────────────
65
+
66
+ /** @type {Array<{ container: () => HTMLElement | null, onEscape: (() => void) | null }>} */
67
+ const stack = []
68
+ let listening = false
69
+
70
+ function onWindowKeydown(event) {
71
+ const top = stack[stack.length - 1]
72
+ if (!top) return
73
+ const container = top.container()
74
+ if (!container) return
75
+
76
+ if (event.key === 'Escape') {
77
+ // A control inside the dialog (an open select, a search field) may have
78
+ // handled Escape already; respect that rather than closing over it.
79
+ if (event.defaultPrevented || !top.onEscape) return
80
+ event.preventDefault()
81
+ top.onEscape()
82
+ return
83
+ }
84
+
85
+ if (event.key !== 'Tab') return
86
+ const items = tabbableIn(container)
87
+ if (items.length === 0) {
88
+ event.preventDefault()
89
+ container.focus()
90
+ return
91
+ }
92
+ const first = items[0]
93
+ const last = items[items.length - 1]
94
+ const active = document.activeElement
95
+ const inside = container.contains(active)
96
+ if (event.shiftKey && (active === first || !inside)) {
97
+ event.preventDefault()
98
+ last.focus()
99
+ } else if (!event.shiftKey && (active === last || !inside)) {
100
+ event.preventDefault()
101
+ first.focus()
102
+ }
103
+ }
104
+
105
+ function push(entry) {
106
+ stack.push(entry)
107
+ if (!listening) {
108
+ window.addEventListener('keydown', onWindowKeydown)
109
+ listening = true
110
+ }
111
+ }
112
+
113
+ function remove(entry) {
114
+ const index = stack.indexOf(entry)
115
+ if (index !== -1) stack.splice(index, 1)
116
+ if (stack.length === 0 && listening) {
117
+ window.removeEventListener('keydown', onWindowKeydown)
118
+ listening = false
119
+ }
120
+ }
121
+
122
+ // ── Composable ───────────────────────────────────────────────────────
123
+
124
+ /**
125
+ * Trap focus inside an element while `active()` is true.
126
+ *
127
+ * @param {() => HTMLElement | null | undefined} container Getter for the
128
+ * element focus is confined to. It must itself be focusable
129
+ * (`tabindex="-1"`) so there is somewhere to land when it has no controls.
130
+ * @param {object} options
131
+ * @param {() => boolean} options.active Whether the trap is engaged.
132
+ * @param {(() => boolean) | boolean} [options.escape] Whether Escape closes.
133
+ * @param {() => void} [options.onEscape] Called when Escape should close.
134
+ */
135
+ export function useFocusTrap(container, { active, escape = true, onEscape }) {
136
+ const entry = {
137
+ container: () => container() ?? null,
138
+ onEscape: null,
139
+ }
140
+ let returnTo = null
141
+ let engaged = false
142
+ // The element as it was while open. A template ref is cleared the moment its
143
+ // owner starts leaving, but a Transition keeps the element (and the focus
144
+ // inside it) on screen for the length of the leave animation.
145
+ let lastEl = null
146
+
147
+ const engage = () => {
148
+ if (engaged || typeof document === 'undefined') return
149
+ engaged = true
150
+ returnTo = document.activeElement
151
+ entry.onEscape = () => {
152
+ const allowed = typeof escape === 'function' ? escape() : escape
153
+ if (allowed) onEscape?.()
154
+ }
155
+ push(entry)
156
+ nextTick(() => {
157
+ const el = entry.container()
158
+ if (el) lastEl = el
159
+ if (!el || el.contains(document.activeElement)) return
160
+ const [first] = tabbableIn(el)
161
+ ;(first ?? el).focus({ preventScroll: true })
162
+ })
163
+ }
164
+
165
+ const release = () => {
166
+ if (!engaged) return
167
+ engaged = false
168
+ remove(entry)
169
+ const target = returnTo
170
+ const closing = entry.container() ?? lastEl
171
+ returnTo = null
172
+ lastEl = null
173
+ // Only restore if focus is still lost inside the closing surface or on the
174
+ // body — never yank it away from somewhere the user has since moved to.
175
+ if (target && typeof target.focus === 'function' && document.contains(target)) {
176
+ const current = document.activeElement
177
+ if (!current || current === document.body || closing?.contains(current)) {
178
+ target.focus({ preventScroll: true })
179
+ }
180
+ }
181
+ }
182
+
183
+ watch(active, (on) => (on ? engage() : release()), { immediate: true, flush: 'post' })
184
+ onBeforeUnmount(release)
185
+ }
package/src/manifest.js CHANGED
@@ -29,10 +29,12 @@ export const COMPONENT_NAMES = [
29
29
  'Button',
30
30
  'Card',
31
31
  'Checkbox',
32
+ 'ChipsInput',
32
33
  'CodeBlock',
33
34
  'CopyField',
34
35
  'DescriptionList',
35
36
  'Divider',
37
+ 'Drawer',
36
38
  'Dropdown',
37
39
  'DropdownItem',
38
40
  'DropdownRow',
@@ -59,8 +61,10 @@ export const COMPONENT_NAMES = [
59
61
  'Sidebar',
60
62
  'SidebarGroup',
61
63
  'SidebarItem',
64
+ 'Skeleton',
62
65
  'Slider',
63
66
  'Spinner',
67
+ 'SplitPane',
64
68
  'StatCard',
65
69
  'Stepper',
66
70
  'Table',
@@ -69,6 +73,8 @@ export const COMPONENT_NAMES = [
69
73
  'Toast',
70
74
  'Toggle',
71
75
  'Tooltip',
76
+ 'Tree',
77
+ 'VirtualList',
72
78
  ]
73
79
 
74
80
  /**