numori-ui 0.6.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.
@@ -5,22 +5,42 @@
5
5
  :class="positionClass"
6
6
  >
7
7
  <TransitionGroup
8
- enter-active-class="transition-all duration-250 ease-out"
8
+ enter-active-class="transition-all duration-250 ease-out motion-reduce:transition-none"
9
9
  enter-from-class="opacity-0 -translate-y-3 scale-95"
10
10
  enter-to-class="opacity-100 translate-y-0 scale-100"
11
- leave-active-class="transition-all duration-200 ease-in"
11
+ leave-active-class="transition-all duration-200 ease-in motion-reduce:transition-none"
12
12
  leave-from-class="opacity-100 translate-y-0 scale-100"
13
13
  leave-to-class="opacity-0 -translate-y-1 scale-95"
14
14
  >
15
15
  <div
16
16
  v-for="toast in toasts"
17
17
  :key="toast.id"
18
- class="pointer-events-auto flex items-center gap-2 px-4 py-2.5 rounded-xl shadow-lg text-sm font-medium backdrop-blur-xs"
19
- :class="toastClass(toast.type)"
18
+ class="pointer-events-auto flex items-center gap-2 rounded-xl py-2.5 text-sm font-medium shadow-lg backdrop-blur-xs"
19
+ :class="[
20
+ toastClass(toast.type),
21
+ toast.action || toast.dismissible ? 'pl-4 pr-2' : 'px-4',
22
+ ]"
20
23
  role="status"
21
24
  >
22
25
  <UiIcon v-if="toast.icon" :name="toast.icon" class="w-4 h-4 shrink-0" />
23
26
  <span>{{ toast.message }}</span>
27
+ <button
28
+ v-if="toast.action"
29
+ type="button"
30
+ class="-my-1 ml-1 rounded-lg px-2.5 py-1 text-sm font-semibold underline-offset-2 transition-colors hover:bg-white/15 hover:underline focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-current dark:hover:bg-gray-900/10"
31
+ @click="$emit('action', toast)"
32
+ >
33
+ {{ toast.action }}
34
+ </button>
35
+ <button
36
+ v-if="toast.dismissible"
37
+ type="button"
38
+ class="-my-1 inline-flex size-7 items-center justify-center rounded-lg opacity-80 transition hover:bg-white/15 hover:opacity-100 focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-current dark:hover:bg-gray-900/10"
39
+ :aria-label="dismissLabel"
40
+ @click="$emit('dismiss', toast)"
41
+ >
42
+ <UiIcon name="mdi:close" class="w-4 h-4" />
43
+ </button>
24
44
  </div>
25
45
  </TransitionGroup>
26
46
  </div>
@@ -38,9 +58,14 @@
38
58
  * worth announcing is application logic, not layout. Hand it a reactive array
39
59
  * and mutate that array; the enter/leave transitions handle the rest.
40
60
  *
41
- * Each entry is `{ id, message, type?, icon? }`. `id` must be stable and unique
42
- * (it keys the transition); `type` picks the colour and defaults to a neutral
43
- * dark pill; `icon` is optional and drawn through `UiIcon`.
61
+ * Each entry is `{ id, message, type?, icon?, action?, dismissible? }`. `id`
62
+ * must be stable and unique (it keys the transition); `type` picks the colour
63
+ * and defaults to a neutral dark pill; `icon` is optional and drawn through
64
+ * `UiIcon`. `action` is the label of one button — "Undo", typically — and
65
+ * clicking it emits `action` with the toast; `dismissible` adds a close
66
+ * button that emits `dismiss`. Keep toasts with an action on screen long
67
+ * enough to reach (five seconds or more), and offer the same command from the
68
+ * keyboard elsewhere: a toast is never the only way to do something.
44
69
  *
45
70
  * The container does not capture pointer events, so it never blocks the UI
46
71
  * underneath; only the pills themselves do. Each pill is a `role="status"`, so a
@@ -60,20 +85,29 @@
60
85
  *
61
86
  * <UiToast :toasts="toasts" />
62
87
  * <UiButton @click="notify('Saved', 'success')">Save</UiButton>
88
+ *
89
+ * @example With an undo action
90
+ * <UiToast
91
+ * :toasts="[{ id: 1, message: 'Moved to Archive', icon: 'mdi:archive-outline', action: 'Undo' }]"
92
+ * @action="(toast) => undo(toast.id)"
93
+ * />
94
+ *
95
+ * @emits {object} action — The toast's action button was pressed (the toast).
96
+ * @emits {object} dismiss — The toast's close button was pressed (the toast).
63
97
  */
64
98
  import { computed } from 'vue'
65
99
  import UiIcon from '../icons/Icon.vue'
66
100
 
67
101
  const props = defineProps({
68
102
  /**
69
- * The messages to show. Each is `{ id, message, type?, icon? }`, where `id`
70
- * is stable and unique, `type` is one of the values below (default neutral),
71
- * and `icon` is an optional MDI name.
72
- * @type {Array<{ id: string|number, message: string, type?: string, icon?: string }>}
103
+ * The messages to show. Each is `{ id, message, type?, icon?, action?,
104
+ * dismissible? }`, where `id` is stable and unique, `type` is one of the
105
+ * values below (default neutral), `icon` is an optional MDI name, `action`
106
+ * labels a button, and `dismissible` adds a close button.
107
+ * @type {Array<{ id: string|number, message: string, type?: string, icon?: string, action?: string, dismissible?: boolean }>}
73
108
  * @default []
74
109
  */
75
110
  toasts: { type: Array, default: () => [] },
76
-
77
111
  /**
78
112
  * Where the stack anchors on screen.
79
113
  * @type {string}
@@ -81,9 +115,19 @@ const props = defineProps({
81
115
  * @values 'top' | 'bottom'
82
116
  */
83
117
  position: { type: String, default: 'top' },
118
+ /**
119
+ * Accessible name of the close button on dismissible toasts.
120
+ * @type {string}
121
+ * @default 'Dismiss'
122
+ */
123
+ dismissLabel: { type: String, default: 'Dismiss' },
84
124
  })
85
125
 
86
- const positionClass = computed(() => (props.position === 'bottom' ? 'bottom-6' : 'top-6'))
126
+ defineEmits(['action', 'dismiss'])
127
+
128
+ const positionClass = computed(() =>
129
+ props.position === 'bottom' ? 'bottom-[max(1.5rem,env(safe-area-inset-bottom))]' : 'top-6',
130
+ )
87
131
 
88
132
  /**
89
133
  * Toast colours are drawn from the design tokens (`success`/`warning`/`error`)
@@ -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'
@@ -74,10 +76,12 @@ export {
74
76
  Button as UiButton,
75
77
  Card as UiCard,
76
78
  Checkbox as UiCheckbox,
79
+ ChipsInput as UiChipsInput,
77
80
  CodeBlock as UiCodeBlock,
78
81
  CopyField as UiCopyField,
79
82
  DescriptionList as UiDescriptionList,
80
83
  Divider as UiDivider,
84
+ Drawer as UiDrawer,
81
85
  Dropdown as UiDropdown,
82
86
  DropdownItem as UiDropdownItem,
83
87
  DropdownRow as UiDropdownRow,
@@ -131,10 +135,12 @@ export const components = {
131
135
  Button,
132
136
  Card,
133
137
  Checkbox,
138
+ ChipsInput,
134
139
  CodeBlock,
135
140
  CopyField,
136
141
  DescriptionList,
137
142
  Divider,
143
+ Drawer,
138
144
  Dropdown,
139
145
  DropdownItem,
140
146
  DropdownRow,
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",
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',