@sparklingopinions/sparkling-ui 0.4.2 → 0.6.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 (100) hide show
  1. package/README.md +1 -1
  2. package/dist/aliases.d.ts +176 -26
  3. package/dist/components/Avatar/Avatar.js.map +1 -1
  4. package/dist/components/Avatar/Avatar.vue.d.ts +3 -2
  5. package/dist/components/Avatar/Avatar.vue_vue_type_script_setup_true_lang.js +20 -14
  6. package/dist/components/Avatar/Avatar.vue_vue_type_script_setup_true_lang.js.map +1 -1
  7. package/dist/components/Board/Board.js.map +1 -1
  8. package/dist/components/Board/Board.vue.d.ts +6 -2
  9. package/dist/components/Board/Board.vue_vue_type_script_setup_true_lang.js +142 -74
  10. package/dist/components/Board/Board.vue_vue_type_script_setup_true_lang.js.map +1 -1
  11. package/dist/components/Button/Button.js.map +1 -1
  12. package/dist/components/Button/Button.vue.d.ts +1 -1
  13. package/dist/components/Button/Button.vue_vue_type_script_setup_true_lang.js +4 -2
  14. package/dist/components/Button/Button.vue_vue_type_script_setup_true_lang.js.map +1 -1
  15. package/dist/components/ContextMenu/ContextMenu.js +7 -0
  16. package/dist/components/ContextMenu/ContextMenu.js.map +1 -0
  17. package/dist/components/ContextMenu/ContextMenu.vue.d.ts +44 -0
  18. package/dist/components/ContextMenu/ContextMenu.vue_vue_type_script_setup_true_lang.js +84 -0
  19. package/dist/components/ContextMenu/ContextMenu.vue_vue_type_script_setup_true_lang.js.map +1 -0
  20. package/dist/components/ContextMenu/index.d.ts +2 -0
  21. package/dist/components/DataList/DataList.js.map +1 -1
  22. package/dist/components/DataList/DataList.vue.d.ts +8 -0
  23. package/dist/components/DataList/DataList.vue_vue_type_script_setup_true_lang.js +71 -52
  24. package/dist/components/DataList/DataList.vue_vue_type_script_setup_true_lang.js.map +1 -1
  25. package/dist/components/DataList/types.d.ts +5 -1
  26. package/dist/components/Dialog/Dialog.js.map +1 -1
  27. package/dist/components/Dialog/Dialog.vue.d.ts +22 -6
  28. package/dist/components/Dialog/Dialog.vue_vue_type_script_setup_true_lang.js +174 -72
  29. package/dist/components/Dialog/Dialog.vue_vue_type_script_setup_true_lang.js.map +1 -1
  30. package/dist/components/Dialog/useSheetDrag.d.ts +16 -0
  31. package/dist/components/Dialog/useSheetDrag.js +37 -0
  32. package/dist/components/Dialog/useSheetDrag.js.map +1 -0
  33. package/dist/components/DropdownMenu/DropdownMenu.js.map +1 -1
  34. package/dist/components/DropdownMenu/DropdownMenu.vue.d.ts +6 -30
  35. package/dist/components/DropdownMenu/DropdownMenu.vue_vue_type_script_setup_true_lang.js +54 -74
  36. package/dist/components/DropdownMenu/DropdownMenu.vue_vue_type_script_setup_true_lang.js.map +1 -1
  37. package/dist/components/EmptyState/EmptyState.js.map +1 -1
  38. package/dist/components/EmptyState/EmptyState.vue.d.ts +9 -3
  39. package/dist/components/EmptyState/EmptyState.vue_vue_type_script_setup_true_lang.js +35 -7
  40. package/dist/components/EmptyState/EmptyState.vue_vue_type_script_setup_true_lang.js.map +1 -1
  41. package/dist/components/Filters/FilterChip.js.map +1 -1
  42. package/dist/components/Filters/FilterChip.vue.d.ts +4 -1
  43. package/dist/components/Filters/FilterChip.vue_vue_type_script_setup_true_lang.js +29 -24
  44. package/dist/components/Filters/FilterChip.vue_vue_type_script_setup_true_lang.js.map +1 -1
  45. package/dist/components/Filters/FilterMenu.js.map +1 -1
  46. package/dist/components/Filters/FilterMenu.vue.d.ts +20 -1
  47. package/dist/components/Filters/FilterMenu.vue_vue_type_script_setup_true_lang.js +78 -56
  48. package/dist/components/Filters/FilterMenu.vue_vue_type_script_setup_true_lang.js.map +1 -1
  49. package/dist/components/Filters/SortMenu.js.map +1 -1
  50. package/dist/components/Filters/SortMenu.vue.d.ts +21 -1
  51. package/dist/components/Filters/SortMenu.vue_vue_type_script_setup_true_lang.js +90 -66
  52. package/dist/components/Filters/SortMenu.vue_vue_type_script_setup_true_lang.js.map +1 -1
  53. package/dist/components/Filters/index.d.ts +2 -1
  54. package/dist/components/Filters/trigger.d.ts +17 -0
  55. package/dist/components/Filters/trigger.js +33 -0
  56. package/dist/components/Filters/trigger.js.map +1 -0
  57. package/dist/components/Filters/types.d.ts +8 -0
  58. package/dist/components/FormField/FormField.js.map +1 -1
  59. package/dist/components/FormField/FormField.vue.d.ts +10 -0
  60. package/dist/components/FormField/FormField.vue_vue_type_script_setup_true_lang.js +31 -20
  61. package/dist/components/FormField/FormField.vue_vue_type_script_setup_true_lang.js.map +1 -1
  62. package/dist/components/Icon/iconSet.js +9 -1
  63. package/dist/components/Icon/iconSet.js.map +1 -1
  64. package/dist/components/SegmentedControl/SegmentedControl.js.map +1 -1
  65. package/dist/components/SegmentedControl/SegmentedControl.vue.d.ts +6 -3
  66. package/dist/components/SegmentedControl/SegmentedControl.vue_vue_type_script_setup_true_lang.js +20 -17
  67. package/dist/components/SegmentedControl/SegmentedControl.vue_vue_type_script_setup_true_lang.js.map +1 -1
  68. package/dist/components/SegmentedControl/index.d.ts +1 -1
  69. package/dist/components/Table/Table.js.map +1 -1
  70. package/dist/components/Table/Table.vue.d.ts +4 -0
  71. package/dist/components/Table/Table.vue_vue_type_script_setup_true_lang.js +66 -56
  72. package/dist/components/Table/Table.vue_vue_type_script_setup_true_lang.js.map +1 -1
  73. package/dist/components/Table/types.d.ts +2 -0
  74. package/dist/components/Tag/Tag.js.map +1 -1
  75. package/dist/components/Tag/Tag.vue.d.ts +16 -3
  76. package/dist/components/Tag/Tag.vue_vue_type_script_setup_true_lang.js +42 -19
  77. package/dist/components/Tag/Tag.vue_vue_type_script_setup_true_lang.js.map +1 -1
  78. package/dist/components/Toast/ToastMessage.js.map +1 -1
  79. package/dist/components/Toast/ToastMessage.vue.d.ts +13 -1
  80. package/dist/components/Toast/ToastMessage.vue_vue_type_script_setup_true_lang.js +58 -23
  81. package/dist/components/Toast/ToastMessage.vue_vue_type_script_setup_true_lang.js.map +1 -1
  82. package/dist/components/Toast/Toaster.js.map +1 -1
  83. package/dist/components/Toast/Toaster.vue.d.ts +7 -3
  84. package/dist/components/Toast/Toaster.vue_vue_type_script_setup_true_lang.js +50 -21
  85. package/dist/components/Toast/Toaster.vue_vue_type_script_setup_true_lang.js.map +1 -1
  86. package/dist/components/internal/MenuItemContent.js +7 -0
  87. package/dist/components/internal/MenuItemContent.js.map +1 -0
  88. package/dist/components/internal/MenuItemContent.vue.d.ts +7 -0
  89. package/dist/components/internal/MenuItemContent.vue_vue_type_script_setup_true_lang.js +26 -0
  90. package/dist/components/internal/MenuItemContent.vue_vue_type_script_setup_true_lang.js.map +1 -0
  91. package/dist/components/internal/menu.d.ts +46 -0
  92. package/dist/components/internal/menu.js +33 -0
  93. package/dist/components/internal/menu.js.map +1 -0
  94. package/dist/composables/toast.d.ts +20 -5
  95. package/dist/composables/toast.js +28 -20
  96. package/dist/composables/toast.js.map +1 -1
  97. package/dist/index.d.ts +2 -1
  98. package/dist/index.js +34 -33
  99. package/package.json +1 -1
  100. package/src/styles/tailwind.css +29 -0
@@ -0,0 +1,46 @@
1
+ export interface DropdownMenuAction {
2
+ type: 'action';
3
+ label: string;
4
+ action?: string;
5
+ icon?: string;
6
+ variant?: 'danger';
7
+ shortcut?: string;
8
+ /** Asks first, with this wording; `confirmed: true` asks with the generic wording. */
9
+ confirm?: {
10
+ message: string;
11
+ title?: string;
12
+ acceptLabel?: string;
13
+ };
14
+ confirmed?: boolean;
15
+ [key: string]: unknown;
16
+ }
17
+ export type DropdownMenuEntry = DropdownMenuAction | {
18
+ type: 'separator';
19
+ };
20
+ /** The confirm step's wording, shared by DropdownMenu and ContextMenu. */
21
+ export interface MenuConfirmLabels {
22
+ /** Passed back with every clicked item, e.g. the record the menu acts on. */
23
+ id?: string;
24
+ confirmTitle?: string;
25
+ confirmMessage?: string;
26
+ confirmLabel?: string;
27
+ deleteLabel?: string;
28
+ cancelLabel?: string;
29
+ }
30
+ export declare const menuConfirmDefaults: {
31
+ id: undefined;
32
+ confirmTitle: string;
33
+ confirmMessage: string;
34
+ confirmLabel: string;
35
+ deleteLabel: string;
36
+ cancelLabel: string;
37
+ };
38
+ export declare const menuContentClass = "z-[1100] rounded-xl border border-sui-line-subtle bg-sui-surface p-1 shadow-lg outline-hidden data-[state=open]:animate-sui-menu-in";
39
+ export declare const menuItemClass = "relative rounded-lg text-sm text-sui-ink transition-colors duration-150 outline-hidden hover:bg-sui-sunken focus-visible:sui-ring-inset data-highlighted:bg-sui-sunken";
40
+ export declare const menuSeparatorClass = "my-1 border-t border-sui-line-subtle";
41
+ /** Runs an item: asks first when it says so, then emits it with the menu's `id`. */
42
+ export declare function useMenuSelect(props: Required<Omit<MenuConfirmLabels, 'id'>> & {
43
+ id?: string;
44
+ }, emit: (item: DropdownMenuAction & {
45
+ id?: string;
46
+ }) => void): (item: DropdownMenuAction) => Promise<void>;
@@ -0,0 +1,33 @@
1
+ import { useConfirm as e } from "../../composables/useConfirm.js";
2
+ //#region src/components/internal/menu.ts
3
+ var t = {
4
+ id: void 0,
5
+ confirmTitle: "Are you sure?",
6
+ confirmMessage: "This can't be undone.",
7
+ confirmLabel: "Confirm",
8
+ deleteLabel: "Delete",
9
+ cancelLabel: "Cancel"
10
+ }, n = "z-[1100] rounded-xl border border-sui-line-subtle bg-sui-surface p-1 shadow-lg outline-hidden data-[state=open]:animate-sui-menu-in", r = "relative rounded-lg text-sm text-sui-ink transition-colors duration-150 outline-hidden hover:bg-sui-sunken focus-visible:sui-ring-inset data-highlighted:bg-sui-sunken", i = "my-1 border-t border-sui-line-subtle";
11
+ function a(t, n) {
12
+ let r = e();
13
+ return async function(e) {
14
+ if (e.confirm || e.confirmed) {
15
+ let n = e.variant === "danger" || e.action === "delete";
16
+ if (!await r({
17
+ title: e.confirm?.title ?? t.confirmTitle,
18
+ message: e.confirm?.message ?? t.confirmMessage,
19
+ cancelLabel: t.cancelLabel,
20
+ confirmLabel: e.confirm?.acceptLabel ?? (e.action === "delete" ? t.deleteLabel : t.confirmLabel),
21
+ confirmVariant: n ? "danger" : "primary"
22
+ })) return;
23
+ }
24
+ n({
25
+ id: t.id,
26
+ ...e
27
+ });
28
+ };
29
+ }
30
+ //#endregion
31
+ export { t as menuConfirmDefaults, n as menuContentClass, r as menuItemClass, i as menuSeparatorClass, a as useMenuSelect };
32
+
33
+ //# sourceMappingURL=menu.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"menu.js","names":["menuConfirmDefaults","menuContentClass","menuItemClass","menuSeparatorClass","useMenuSelect","confirm","useConfirm","item","destructive","props"],"sources":["../../../src/components/internal/menu.ts"],"sourcesContent":["import { useConfirm } from '../../composables/useConfirm'\n\nexport interface DropdownMenuAction {\n type: 'action'\n label: string\n action?: string\n icon?: string\n variant?: 'danger'\n shortcut?: string\n /** Asks first, with this wording; `confirmed: true` asks with the generic wording. */\n confirm?: { message: string; title?: string; acceptLabel?: string }\n confirmed?: boolean\n [key: string]: unknown\n}\n\nexport type DropdownMenuEntry = DropdownMenuAction | { type: 'separator' }\n\n/** The confirm step's wording, shared by DropdownMenu and ContextMenu. */\nexport interface MenuConfirmLabels {\n /** Passed back with every clicked item, e.g. the record the menu acts on. */\n id?: string\n confirmTitle?: string\n confirmMessage?: string\n confirmLabel?: string\n deleteLabel?: string\n cancelLabel?: string\n}\n\nexport const menuConfirmDefaults = {\n id: undefined,\n confirmTitle: 'Are you sure?',\n confirmMessage: \"This can't be undone.\",\n confirmLabel: 'Confirm',\n deleteLabel: 'Delete',\n cancelLabel: 'Cancel'\n}\n\nexport const menuContentClass =\n 'z-[1100] rounded-xl border border-sui-line-subtle bg-sui-surface p-1 shadow-lg outline-hidden data-[state=open]:animate-sui-menu-in'\nexport const menuItemClass =\n 'relative rounded-lg text-sm text-sui-ink transition-colors duration-150 outline-hidden hover:bg-sui-sunken focus-visible:sui-ring-inset data-highlighted:bg-sui-sunken'\nexport const menuSeparatorClass = 'my-1 border-t border-sui-line-subtle'\n\n/** Runs an item: asks first when it says so, then emits it with the menu's `id`. */\nexport function useMenuSelect(\n props: Required<Omit<MenuConfirmLabels, 'id'>> & { id?: string },\n emit: (item: DropdownMenuAction & { id?: string }) => void\n) {\n const confirm = useConfirm()\n\n return async function select(item: DropdownMenuAction) {\n if (item.confirm || item.confirmed) {\n const destructive = item.variant === 'danger' || item.action === 'delete'\n const confirmed = await confirm({\n title: item.confirm?.title ?? props.confirmTitle,\n message: item.confirm?.message ?? props.confirmMessage,\n cancelLabel: props.cancelLabel,\n confirmLabel: item.confirm?.acceptLabel ?? (item.action === 'delete' ? props.deleteLabel : props.confirmLabel),\n confirmVariant: destructive ? 'danger' : 'primary'\n })\n if (!confirmed) return\n }\n emit({ id: props.id, ...item })\n }\n}\n"],"mappings":";;AA4BA,IAAaA,IAAsB;CACjC,IAAI,KAAA;CACJ,cAAc;CACd,gBAAgB;CAChB,cAAc;CACd,aAAa;CACb,aAAa;AACf,GAEaC,IACX,uIACWC,IACX,0KACWC,IAAqB;AAGlC,SAAgBC,EACd,GACA,GACA;CACA,IAAMC,IAAUC,EAAW;CAE3B,OAAO,eAAsB,GAA0B;EACrD,IAAIC,EAAK,WAAWA,EAAK,WAAW;GAClC,IAAMC,IAAcD,EAAK,YAAY,YAAYA,EAAK,WAAW;GAQjE,IAAI,CAAC,MAPmBF,EAAQ;IAC9B,OAAOE,EAAK,SAAS,SAASE,EAAM;IACpC,SAASF,EAAK,SAAS,WAAWE,EAAM;IACxC,aAAaA,EAAM;IACnB,cAAcF,EAAK,SAAS,gBAAgBA,EAAK,WAAW,WAAWE,EAAM,cAAcA,EAAM;IACjG,gBAAgBD,IAAc,WAAW;GAC3C,CAAC,GACe;EAClB;EACA,EAAK;GAAE,IAAIC,EAAM;GAAI,GAAGF;EAAK,CAAC;CAChC;AACF"}
@@ -1,23 +1,38 @@
1
- export type ToastSeverity = 'info' | 'success' | 'error';
1
+ export type ToastSeverity = 'info' | 'success' | 'warning' | 'error';
2
+ /** A button on the toast: pressing it runs `onClick`, then closes the toast. */
3
+ export interface ToastAction {
4
+ label: string;
5
+ onClick: () => void;
6
+ }
7
+ /** Why a toast left: one of its actions, its close button (or Escape), or its timer running out. */
8
+ export type ToastDismissReason = 'action' | 'close' | 'timeout';
2
9
  export interface ToastOptions {
3
10
  /** A second line under the message. */
4
11
  detail?: string;
5
- /** How long it stays, in ms; 0 keeps it until closed. */
12
+ /** How long it stays, in ms; 0 keeps it until closed. 3000 by default, 6000 with an action. */
6
13
  life?: number;
7
14
  closable?: boolean;
15
+ action?: ToastAction;
16
+ /** One or two; any more are ignored. */
17
+ actions?: ToastAction[];
18
+ onDismiss?: (reason: ToastDismissReason) => void;
8
19
  }
9
- export interface ToastItem extends ToastOptions {
20
+ export interface ToastItem extends Omit<ToastOptions, 'action'> {
10
21
  id: number;
11
22
  severity: ToastSeverity;
12
23
  summary: string;
24
+ actions: ToastAction[];
13
25
  open: boolean;
14
26
  }
27
+ /** A toast's actions, from `action` or `actions`, at most two. */
28
+ export declare function toastActions(options: Pick<ToastOptions, 'action' | 'actions'>): ToastAction[];
15
29
  export declare const toasts: import("vue").ShallowReactive<ToastItem[]>;
16
- /** Removes a toast once its closing animation has had time to play. */
17
- export declare function removeToast(id: number): void;
30
+ /** Closes a toast, then removes it once its closing animation has had time to play. */
31
+ export declare function removeToast(id: number, reason?: ToastDismissReason): void;
18
32
  /** Shows a message in the app's <Toaster />: `toast.info('Saved')`. */
19
33
  export declare const toast: {
20
34
  info: (summary: string, options?: ToastOptions) => void;
21
35
  success: (summary: string, options?: ToastOptions) => void;
36
+ warning: (summary: string, options?: ToastOptions) => void;
22
37
  error: (summary: string, options?: ToastOptions) => void;
23
38
  };
@@ -1,32 +1,40 @@
1
1
  import { shallowReactive as e } from "vue";
2
2
  //#region src/composables/toast.ts
3
- var t = e([]), n = 0;
4
- function r(e, r, i = {}) {
5
- t.push({
6
- life: 3e3,
7
- ...i,
8
- id: n++,
3
+ function t(e) {
4
+ return (e.actions ?? (e.action ? [e.action] : [])).slice(0, 2);
5
+ }
6
+ var n = e([]), r = 0;
7
+ function i(e, i, a = {}) {
8
+ let { action: o, ...s } = a, c = t(a);
9
+ n.push({
10
+ ...s,
11
+ life: a.life ?? (c.length ? 6e3 : 3e3),
12
+ actions: c,
13
+ id: r++,
9
14
  severity: e,
10
- summary: r,
15
+ summary: i,
11
16
  open: !0
12
17
  });
13
18
  }
14
- function i(e) {
15
- let n = t.findIndex((t) => t.id === e);
16
- n < 0 || (t[n] = {
17
- ...t[n],
19
+ function a(e, t = "close") {
20
+ let r = n.findIndex((t) => t.id === e);
21
+ if (r < 0 || !n[r].open) return;
22
+ let i = n[r];
23
+ n[r] = {
24
+ ...i,
18
25
  open: !1
19
- }, setTimeout(() => {
20
- let n = t.findIndex((t) => t.id === e);
21
- n >= 0 && t.splice(n, 1);
22
- }, 500));
26
+ }, i.onDismiss?.(t), setTimeout(() => {
27
+ let t = n.findIndex((t) => t.id === e);
28
+ t >= 0 && n.splice(t, 1);
29
+ }, 500);
23
30
  }
24
- var a = {
25
- info: (e, t) => r("info", e, t),
26
- success: (e, t) => r("success", e, t),
27
- error: (e, t) => r("error", e, t)
31
+ var o = {
32
+ info: (e, t) => i("info", e, t),
33
+ success: (e, t) => i("success", e, t),
34
+ warning: (e, t) => i("warning", e, t),
35
+ error: (e, t) => i("error", e, t)
28
36
  };
29
37
  //#endregion
30
- export { i as removeToast, a as toast, t as toasts };
38
+ export { a as removeToast, o as toast, t as toastActions, n as toasts };
31
39
 
32
40
  //# sourceMappingURL=toast.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"toast.js","names":["toasts","shallowReactive","nextId","add","options","removeToast","index","item","id","at","toast","summary"],"sources":["../../src/composables/toast.ts"],"sourcesContent":["import { shallowReactive } from 'vue'\n\nexport type ToastSeverity = 'info' | 'success' | 'error'\n\nexport interface ToastOptions {\n /** A second line under the message. */\n detail?: string\n /** How long it stays, in ms; 0 keeps it until closed. */\n life?: number\n closable?: boolean\n}\n\nexport interface ToastItem extends ToastOptions {\n id: number\n severity: ToastSeverity\n summary: string\n open: boolean\n}\n\n// The messages one <Toaster /> near the app root shows.\nexport const toasts = shallowReactive<ToastItem[]>([])\n\nlet nextId = 0\n\nfunction add(severity: ToastSeverity, summary: string, options: ToastOptions = {}) {\n toasts.push({ life: 3000, ...options, id: nextId++, severity, summary, open: true })\n}\n\n/** Removes a toast once its closing animation has had time to play. */\nexport function removeToast(id: number) {\n const index = toasts.findIndex((item) => item.id === id)\n if (index < 0) return\n toasts[index] = { ...toasts[index]!, open: false }\n setTimeout(() => {\n const at = toasts.findIndex((item) => item.id === id)\n if (at >= 0) toasts.splice(at, 1)\n }, 500)\n}\n\n/** Shows a message in the app's <Toaster />: `toast.info('Saved')`. */\nexport const toast = {\n info: (summary: string, options?: ToastOptions) => add('info', summary, options),\n success: (summary: string, options?: ToastOptions) => add('success', summary, options),\n error: (summary: string, options?: ToastOptions) => add('error', summary, options)\n}\n"],"mappings":";;AAoBA,IAAaA,IAASC,EAA6B,CAAC,CAAC,GAEjDC,IAAS;AAEb,SAASC,EAAI,GAAyB,GAAiB,IAAwB,CAAC,GAAG;CACjF,EAAO,KAAK;EAAE,MAAM;EAAM,GAAGC;EAAS,IAAI;EAAU;EAAU;EAAS,MAAM;CAAK,CAAC;AACrF;AAGA,SAAgBC,EAAY,GAAY;CACtC,IAAMC,IAAQN,EAAO,WAAW,MAASO,EAAK,OAAOC,CAAE;CACvD,AAAIF,IAAQ,MACZ,EAAOA,KAAS;EAAE,GAAGN,EAAOM;EAAS,MAAM;CAAM,GACjD,iBAAiB;EACf,IAAMG,IAAKT,EAAO,WAAW,MAASO,EAAK,OAAOC,CAAE;EACpD,AAAIC,KAAM,KAAGT,EAAO,OAAOS,GAAI,CAAC;CAClC,GAAG,GAAG;AACR;AAGA,IAAaC,IAAQ;CACnB,OAAO,GAAiB,MAA2BP,EAAI,QAAQQ,GAASP,CAAO;CAC/E,UAAU,GAAiB,MAA2BD,EAAI,WAAWQ,GAASP,CAAO;CACrF,QAAQ,GAAiB,MAA2BD,EAAI,SAASQ,GAASP,CAAO;AACnF"}
1
+ {"version":3,"file":"toast.js","names":["toastActions","options","toasts","shallowReactive","nextId","add","_","rest","actions","removeToast","index","item","id","reason","at","toast","summary"],"sources":["../../src/composables/toast.ts"],"sourcesContent":["import { shallowReactive } from 'vue'\n\nexport type ToastSeverity = 'info' | 'success' | 'warning' | 'error'\n\n/** A button on the toast: pressing it runs `onClick`, then closes the toast. */\nexport interface ToastAction {\n label: string\n onClick: () => void\n}\n\n/** Why a toast left: one of its actions, its close button (or Escape), or its timer running out. */\nexport type ToastDismissReason = 'action' | 'close' | 'timeout'\n\nexport interface ToastOptions {\n /** A second line under the message. */\n detail?: string\n /** How long it stays, in ms; 0 keeps it until closed. 3000 by default, 6000 with an action. */\n life?: number\n closable?: boolean\n action?: ToastAction\n /** One or two; any more are ignored. */\n actions?: ToastAction[]\n onDismiss?: (reason: ToastDismissReason) => void\n}\n\nexport interface ToastItem extends Omit<ToastOptions, 'action'> {\n id: number\n severity: ToastSeverity\n summary: string\n actions: ToastAction[]\n open: boolean\n}\n\n/** A toast's actions, from `action` or `actions`, at most two. */\nexport function toastActions(options: Pick<ToastOptions, 'action' | 'actions'>): ToastAction[] {\n return (options.actions ?? (options.action ? [options.action] : [])).slice(0, 2)\n}\n\n// The messages one <Toaster /> near the app root shows.\nexport const toasts = shallowReactive<ToastItem[]>([])\n\nlet nextId = 0\n\nfunction add(severity: ToastSeverity, summary: string, options: ToastOptions = {}) {\n const { action: _, ...rest } = options\n const actions = toastActions(options)\n toasts.push({\n ...rest,\n life: options.life ?? (actions.length ? 6000 : 3000),\n actions,\n id: nextId++,\n severity,\n summary,\n open: true\n })\n}\n\n/** Closes a toast, then removes it once its closing animation has had time to play. */\nexport function removeToast(id: number, reason: ToastDismissReason = 'close') {\n const index = toasts.findIndex((item) => item.id === id)\n if (index < 0 || !toasts[index]!.open) return\n const item = toasts[index]!\n toasts[index] = { ...item, open: false }\n item.onDismiss?.(reason)\n setTimeout(() => {\n const at = toasts.findIndex((item) => item.id === id)\n if (at >= 0) toasts.splice(at, 1)\n }, 500)\n}\n\n/** Shows a message in the app's <Toaster />: `toast.info('Saved')`. */\nexport const toast = {\n info: (summary: string, options?: ToastOptions) => add('info', summary, options),\n success: (summary: string, options?: ToastOptions) => add('success', summary, options),\n warning: (summary: string, options?: ToastOptions) => add('warning', summary, options),\n error: (summary: string, options?: ToastOptions) => add('error', summary, options)\n}\n"],"mappings":";;AAkCA,SAAgBA,EAAa,GAAkE;CAC7F,QAAQC,EAAQ,YAAYA,EAAQ,SAAS,CAACA,EAAQ,MAAM,IAAI,CAAC,GAAA,CAAI,MAAM,GAAG,CAAC;AACjF;AAGA,IAAaC,IAASC,EAA6B,CAAC,CAAC,GAEjDC,IAAS;AAEb,SAASC,EAAI,GAAyB,GAAiB,IAAwB,CAAC,GAAG;CACjF,IAAM,EAAE,QAAQC,GAAG,GAAGC,MAASN,GACzBO,IAAUR,EAAaC,CAAO;CACpC,EAAO,KAAK;EACV,GAAGM;EACH,MAAMN,EAAQ,SAASO,EAAQ,SAAS,MAAO;EAC/C;EACA,IAAI;EACJ;EACA;EACA,MAAM;CACR,CAAC;AACH;AAGA,SAAgBC,EAAY,GAAY,IAA6B,SAAS;CAC5E,IAAMC,IAAQR,EAAO,WAAW,MAASS,EAAK,OAAOC,CAAE;CACvD,IAAIF,IAAQ,KAAK,CAACR,EAAOQ,EAAM,CAAE,MAAM;CACvC,IAAMC,IAAOT,EAAOQ;CAGpB,AAFA,EAAOA,KAAS;EAAE,GAAGC;EAAM,MAAM;CAAM,GACvCA,EAAK,YAAYE,CAAM,GACvB,iBAAiB;EACf,IAAMC,IAAKZ,EAAO,WAAW,MAASS,EAAK,OAAOC,CAAE;EACpD,AAAIE,KAAM,KAAGZ,EAAO,OAAOY,GAAI,CAAC;CAClC,GAAG,GAAG;AACR;AAGA,IAAaC,IAAQ;CACnB,OAAO,GAAiB,MAA2BV,EAAI,QAAQW,GAASf,CAAO;CAC/E,UAAU,GAAiB,MAA2BI,EAAI,WAAWW,GAASf,CAAO;CACrF,UAAU,GAAiB,MAA2BI,EAAI,WAAWW,GAASf,CAAO;CACrF,QAAQ,GAAiB,MAA2BI,EAAI,SAASW,GAASf,CAAO;AACnF"}
package/dist/index.d.ts CHANGED
@@ -7,6 +7,7 @@ export * from './components/Board';
7
7
  export * from './components/Button';
8
8
  export * from './components/Calendar';
9
9
  export * from './components/Checkbox';
10
+ export * from './components/ContextMenu';
10
11
  export * from './components/DataList';
11
12
  export * from './components/Dialog';
12
13
  export * from './components/DropdownMenu';
@@ -35,6 +36,6 @@ export * from './components/Tooltip';
35
36
  export * from './components/TypingIndicator';
36
37
  export { hueFor, type Hue } from './utils/hues';
37
38
  export { initColorMode, useColorMode, useForceLightMode, type ColorMode } from './composables/useColorMode';
38
- export { toast, type ToastOptions, type ToastSeverity } from './composables/toast';
39
+ export { toast, type ToastAction, type ToastDismissReason, type ToastOptions, type ToastSeverity } from './composables/toast';
39
40
  export { useConfirm, type ConfirmOptions } from './composables/useConfirm';
40
41
  export * from './aliases';
package/dist/index.js CHANGED
@@ -13,36 +13,37 @@ import f from "./components/Skeleton/Skeleton.js";
13
13
  import p from "./components/Board/Board.js";
14
14
  import m from "./components/Calendar/Calendar.js";
15
15
  import h from "./components/Checkbox/Checkbox.js";
16
- import g from "./components/DataList/DataList.js";
17
- import { saveHint as _ } from "./components/Dialog/focus.js";
18
- import v from "./components/Dialog/Dialog.js";
19
- import y from "./components/DropdownMenu/DropdownMenu.js";
20
- import b from "./components/EmptyState/EmptyState.js";
21
- import x from "./components/ErrorSummary/ErrorSummary.js";
22
- import S from "./components/Input/Input.js";
23
- import C from "./components/SegmentedControl/SegmentedControl.js";
24
- import { datePresets as w, describeFilter as T, filterOperators as E, sortDirections as D } from "./components/Filters/defaults.js";
25
- import O from "./components/Filters/FilterChip.js";
26
- import k from "./components/Filters/FilterMenu.js";
27
- import A from "./components/Filters/SortMenu.js";
28
- import j from "./components/FormField/FormField.js";
29
- import M from "./components/ImageUpload/ImageUpload.js";
30
- import N from "./components/Kbd/Kbd.js";
31
- import P from "./components/Pagination/Pagination.js";
32
- import F from "./components/Popover/Popover.js";
33
- import I from "./components/Spinner/Spinner.js";
34
- import L from "./components/Tag/Tag.js";
35
- import R from "./components/Select/Select.js";
36
- import z from "./components/Textarea/Textarea.js";
37
- import B from "./components/PropertyList/Editable.js";
38
- import V from "./components/PropertyList/PropertyList.js";
39
- import H from "./components/PropertyRow/Collapsible.js";
40
- import U from "./components/PropertyRow/PropertyRow.js";
41
- import W from "./components/Radio/Radio.js";
42
- import G from "./components/Table/Table.js";
43
- import { toast as K } from "./composables/toast.js";
44
- import q from "./components/Toast/Toaster.js";
45
- import J from "./components/TypingIndicator/TypingIndicator.js";
46
- import { initColorMode as Y, useColorMode as X, useForceLightMode as Z } from "./composables/useColorMode.js";
47
- import { Banner as Q, BulkActions as $, CalendarMonth as ee, Chip as te, ConfirmDialog as ne, Field as re, FilterFieldPicker as ie, FormErrors as ae, ImageInput as oe, InlineField as se, InlineForm as ce, LedgerMore as le, LedgerRow as ue, List as de, Modal as fe, OptionsMenu as pe, Pill as me, SortControl as he, TextInput as ge, TypingDots as _e } from "./aliases.js";
48
- export { a as ActionBar, o as Alert, c as AlertDialog, u as Avatar, d as Badge, Q as Banner, p as Board, $ as BulkActions, e as Button, m as Calendar, ee as CalendarMonth, h as Checkbox, te as Chip, H as Collapsible, ne as ConfirmDialog, g as DataList, v as Dialog, y as DropdownMenu, B as Editable, b as EmptyState, x as ErrorSummary, re as Field, O as FilterChip, ie as FilterFieldPicker, k as FilterMenu, ae as FormErrors, j as FormField, r as Icon, oe as ImageInput, M as ImageUpload, se as InlineField, ce as InlineForm, S as Input, N as Kbd, le as LedgerMore, ue as LedgerRow, de as List, fe as Modal, pe as OptionsMenu, P as Pagination, me as Pill, F as Popover, V as PropertyList, U as PropertyRow, W as Radio, C as SegmentedControl, R as Select, f as Skeleton, he as SortControl, A as SortMenu, I as Spinner, G as Table, L as Tag, ge as TextInput, z as Textarea, q as Toaster, i as Tooltip, _e as TypingDots, J as TypingIndicator, w as datePresets, T as describeFilter, E as filterOperators, l as hueFor, t as iconNames, Y as initColorMode, _ as saveHint, n as setIconResolver, D as sortDirections, K as toast, X as useColorMode, s as useConfirm, Z as useForceLightMode };
16
+ import g from "./components/ContextMenu/ContextMenu.js";
17
+ import _ from "./components/DataList/DataList.js";
18
+ import { saveHint as v } from "./components/Dialog/focus.js";
19
+ import y from "./components/Dialog/Dialog.js";
20
+ import b from "./components/DropdownMenu/DropdownMenu.js";
21
+ import x from "./components/EmptyState/EmptyState.js";
22
+ import S from "./components/ErrorSummary/ErrorSummary.js";
23
+ import C from "./components/Input/Input.js";
24
+ import w from "./components/SegmentedControl/SegmentedControl.js";
25
+ import { datePresets as T, describeFilter as E, filterOperators as D, sortDirections as O } from "./components/Filters/defaults.js";
26
+ import k from "./components/Filters/FilterChip.js";
27
+ import A from "./components/Filters/FilterMenu.js";
28
+ import j from "./components/Filters/SortMenu.js";
29
+ import M from "./components/FormField/FormField.js";
30
+ import N from "./components/ImageUpload/ImageUpload.js";
31
+ import P from "./components/Kbd/Kbd.js";
32
+ import F from "./components/Pagination/Pagination.js";
33
+ import I from "./components/Popover/Popover.js";
34
+ import L from "./components/Spinner/Spinner.js";
35
+ import R from "./components/Tag/Tag.js";
36
+ import z from "./components/Select/Select.js";
37
+ import B from "./components/Textarea/Textarea.js";
38
+ import V from "./components/PropertyList/Editable.js";
39
+ import H from "./components/PropertyList/PropertyList.js";
40
+ import U from "./components/PropertyRow/Collapsible.js";
41
+ import W from "./components/PropertyRow/PropertyRow.js";
42
+ import G from "./components/Radio/Radio.js";
43
+ import K from "./components/Table/Table.js";
44
+ import { toast as q } from "./composables/toast.js";
45
+ import J from "./components/Toast/Toaster.js";
46
+ import Y from "./components/TypingIndicator/TypingIndicator.js";
47
+ import { initColorMode as X, useColorMode as Z, useForceLightMode as Q } from "./composables/useColorMode.js";
48
+ import { Banner as $, BulkActions as ee, CalendarMonth as te, Chip as ne, ConfirmDialog as re, Field as ie, FilterFieldPicker as ae, FormErrors as oe, ImageInput as se, InlineField as ce, InlineForm as le, LedgerMore as ue, LedgerRow as de, List as fe, Modal as pe, OptionsMenu as me, Pill as he, SortControl as ge, TextInput as _e, TypingDots as ve } from "./aliases.js";
49
+ export { a as ActionBar, o as Alert, c as AlertDialog, u as Avatar, d as Badge, $ as Banner, p as Board, ee as BulkActions, e as Button, m as Calendar, te as CalendarMonth, h as Checkbox, ne as Chip, U as Collapsible, re as ConfirmDialog, g as ContextMenu, _ as DataList, y as Dialog, b as DropdownMenu, V as Editable, x as EmptyState, S as ErrorSummary, ie as Field, k as FilterChip, ae as FilterFieldPicker, A as FilterMenu, oe as FormErrors, M as FormField, r as Icon, se as ImageInput, N as ImageUpload, ce as InlineField, le as InlineForm, C as Input, P as Kbd, ue as LedgerMore, de as LedgerRow, fe as List, pe as Modal, me as OptionsMenu, F as Pagination, he as Pill, I as Popover, H as PropertyList, W as PropertyRow, G as Radio, w as SegmentedControl, z as Select, f as Skeleton, ge as SortControl, j as SortMenu, L as Spinner, K as Table, R as Tag, _e as TextInput, B as Textarea, J as Toaster, i as Tooltip, ve as TypingDots, Y as TypingIndicator, T as datePresets, E as describeFilter, D as filterOperators, l as hueFor, t as iconNames, X as initColorMode, v as saveHint, n as setIconResolver, O as sortDirections, q as toast, Z as useColorMode, s as useConfirm, Q as useForceLightMode };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sparklingopinions/sparkling-ui",
3
- "version": "0.4.2",
3
+ "version": "0.6.0",
4
4
  "description": "A product-agnostic Vue 3 component library, themed by semantic tokens",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -294,6 +294,10 @@
294
294
  --sui-button-padding-x: 0.875rem;
295
295
  --sui-button-text: 0.875rem;
296
296
  --sui-radius-button: 0.5rem;
297
+ /* A bottom sheet's top corners. */
298
+ --sui-radius-sheet: 1.25rem;
299
+ /* Table rows and headers at one height, e.g. 44px; unset (initial), each Table's size decides. */
300
+ --sui-table-row: initial;
297
301
  --sui-shadow-raised: 0 1px 2px 0 rgb(0 0 0 / 0.05);
298
302
  --sui-focus-width: 2px;
299
303
  --sui-focus-offset: 2px;
@@ -357,10 +361,14 @@
357
361
  --animate-sui-scrim-out: sui-scrim-out 200ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
358
362
  --animate-sui-dialog-in: sui-dialog-in 200ms ease-out;
359
363
  --animate-sui-dialog-out: sui-dialog-out 200ms ease-out forwards;
364
+ --animate-sui-sheet-in: sui-sheet-in 300ms cubic-bezier(0.32, 0.72, 0, 1);
365
+ --animate-sui-sheet-out: sui-sheet-out 200ms cubic-bezier(0.4, 0, 1, 1) forwards;
360
366
  --animate-sui-toast-in: sui-toast-in 300ms cubic-bezier(0.4, 0, 0.2, 1);
361
367
  --animate-sui-toast-out:
362
368
  sui-toast-collapse 450ms cubic-bezier(0, 1, 0, 1) forwards,
363
369
  sui-toast-fade 300ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
370
+ /* Its duration is the toast's life, set inline. */
371
+ --animate-sui-toast-timer: sui-toast-timer linear forwards;
364
372
 
365
373
  @keyframes sui-spinner-rotate {
366
374
  to {
@@ -430,6 +438,18 @@
430
438
  }
431
439
  }
432
440
 
441
+ @keyframes sui-sheet-in {
442
+ from {
443
+ transform: translateY(100%);
444
+ }
445
+ }
446
+
447
+ @keyframes sui-sheet-out {
448
+ to {
449
+ transform: translateY(100%);
450
+ }
451
+ }
452
+
433
453
  @keyframes sui-toast-in {
434
454
  from {
435
455
  opacity: 0;
@@ -453,6 +473,15 @@
453
473
  }
454
474
  }
455
475
 
476
+ @keyframes sui-toast-timer {
477
+ from {
478
+ transform: scaleX(1);
479
+ }
480
+ to {
481
+ transform: scaleX(0);
482
+ }
483
+ }
484
+
456
485
  @keyframes sui-typing {
457
486
  0%,
458
487
  80%,