@digitalwalletcorp/vue-core 1.4.3 → 1.4.6

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 (42) hide show
  1. package/README.md +14 -3
  2. package/lib/{components-ytOBcKlQ.cjs → components-Dniui6mw.cjs} +1 -1
  3. package/lib/{components-Mk1fpjbw.js → components-gKR_xoi-.js} +1 -1
  4. package/lib/copy-button.d.cts +6 -0
  5. package/lib/copy-button.d.ts +6 -0
  6. package/lib/help-button.d.cts +2 -2
  7. package/lib/help-button.d.ts +2 -2
  8. package/lib/help-popper.d.cts +2 -2
  9. package/lib/help-popper.d.ts +2 -2
  10. package/lib/helpers/snackbar.d.cts +17 -2
  11. package/lib/helpers/snackbar.d.ts +17 -2
  12. package/lib/helpers/vue-core-options.d.cts +12 -1
  13. package/lib/helpers/vue-core-options.d.ts +12 -1
  14. package/lib/index.cjs +1 -1
  15. package/lib/index.d.cts +2 -2
  16. package/lib/index.d.ts +2 -2
  17. package/lib/index.js +139 -265
  18. package/lib/internal/anchored-popover.d.cts +2 -2
  19. package/lib/internal/anchored-popover.d.ts +2 -2
  20. package/lib/internal/date-format.d.cts +9 -0
  21. package/lib/internal/date-format.d.ts +9 -0
  22. package/lib/internal/icon-popper.d.cts +2 -2
  23. package/lib/internal/icon-popper.d.ts +2 -2
  24. package/lib/nuxt.cjs +1 -1
  25. package/lib/nuxt.js +1 -1
  26. package/lib/register.cjs +1 -1
  27. package/lib/register.js +1 -1
  28. package/lib/style.css +1 -1
  29. package/lib/warning-popper.d.cts +2 -2
  30. package/lib/warning-popper.d.ts +2 -2
  31. package/lib/warning-popper.vue_vue_type_style_index_0_lang-BxdfpRXg.cjs +4 -0
  32. package/lib/warning-popper.vue_vue_type_style_index_0_lang-DuzeuEx2.js +2178 -0
  33. package/package.json +1 -1
  34. package/src/copy-button.vue +14 -1
  35. package/src/data-table.vue +1 -2
  36. package/src/helpers/snackbar.ts +34 -3
  37. package/src/helpers/vue-core-options.ts +13 -1
  38. package/src/index.ts +2 -2
  39. package/src/internal/date-format.ts +25 -0
  40. package/src/screen-loading.vue +8 -0
  41. package/lib/warning-popper.vue_vue_type_style_index_0_lang-142lRixg.cjs +0 -4
  42. package/lib/warning-popper.vue_vue_type_style_index_0_lang-BKR56ef2.js +0 -2019
package/README.md CHANGED
@@ -146,7 +146,13 @@ Components automatically adapt to your application's color-scheme (supporting bo
146
146
 
147
147
  **🛠️ Customizing Styles (`--dwui-*` Variables)**
148
148
 
149
- Default styles use CSS variables (`--dwui-*`) and zero-specificity selectors (`:where()`), making them easy to override. The variables of each component are listed in its document.
149
+ Default styles use CSS variables (`--dwui-*`) and zero-specificity selectors (`:where()`), making them easy to override. The variables of each component are listed in its document. [docs/dwui-variables.css](https://github.com/digitalwalletcorp/vue-core/blob/main/docs/dwui-variables.css) lists all of them with their default values, grouped by the component they apply to. Copy the lines you want to change into your own `dwui-variables.css`.
150
+
151
+ The following default styles do not use `:where()`. To override them, use a CSS rule with higher specificity.
152
+
153
+ | Component | Style | Reason |
154
+ | --------- | ----- | ------ |
155
+ | [`ScreenLoading`](https://github.com/digitalwalletcorp/vue-core/blob/main/docs/components/screen-loading.md) | `outline` on focus | The loading does not accept user interaction, so it does not show a focus ring. |
150
156
 
151
157
  We recommend creating a `dwui-variables.css` file to map your application's design tokens to the library's `--dwui-*` variables, and importing it after the library stylesheet. If you use both `vue-forms` and `vue-core`, you can use a single `dwui-variables.css` file for both libraries, as they share common variables like those for focus rings.
152
158
 
@@ -174,7 +180,7 @@ export default defineNuxtConfig({
174
180
 
175
181
  **🧭 Application-wide Options (`vueCoreOptionsKey`)**
176
182
 
177
- Settings that are the same on every page, such as the texts of `DataTable`, can be provided once for the whole application instead of being passed to each component.
183
+ Settings that are the same on every page, such as the texts of `DataTable` or the timezone of the time on snackbars, can be provided once for the whole application instead of being passed to each component.
178
184
  Provide `vueCoreOptionsKey` in a component above the components or with `app.provide`.
179
185
  A prop wins over the provided value, and without either, the default of the library is used.
180
186
 
@@ -199,6 +205,10 @@ export default defineNuxtPlugin((nuxtApp) => {
199
205
  dataTable: {
200
206
  labels: { totalCount: 'Total', totalUnit: 'records', noData: 'No data' },
201
207
  sortMode: 'page'
208
+ },
209
+ snackbar: {
210
+ // The timezone the user selected. A ref or a function is read each time a snackbar is shown.
211
+ timezone: () => userSession.timezone
202
212
  }
203
213
  });
204
214
  });
@@ -207,6 +217,7 @@ export default defineNuxtPlugin((nuxtApp) => {
207
217
  | Property | Type | Description |
208
218
  | ----------- | ------------------ | ----------- |
209
219
  | `dataTable` | `DataTableOptions` | Sets default props for [`DataTable`](https://github.com/digitalwalletcorp/vue-core/blob/main/docs/components/data-table.md) components across the application. For example, you can configure default labels or sort behavior. |
220
+ | `snackbar` | `SnackbarOptions` | Sets the default `timezone` of the time shown on snackbars, as a string, a ref, or a function that returns it. It applies to the snackbars shown with [`useSnackbar()`](https://github.com/digitalwalletcorp/vue-core/blob/main/docs/components/snackbar.md) and to `CopyButton`. |
210
221
 
211
222
  #### 🛠️ Helper Functions
212
223
 
@@ -227,7 +238,7 @@ const onClickDelete = async () => {
227
238
  | Function | Description |
228
239
  | -------- | ----------- |
229
240
  | [`showInformationDialog()` / `showConfirmationDialog()` / `showWarningDialog()` / `showErrorDialog()` / `showModalDialog()`](https://github.com/digitalwalletcorp/vue-core/blob/main/docs/components/modal-dialog.md) | Shows a modal dialog with a message and returns the button the user chose. |
230
- | [`showSnackbar()` / `closeAllSnackbars()`](https://github.com/digitalwalletcorp/vue-core/blob/main/docs/components/snackbar.md) | Shows a short message at an edge of the screen. |
241
+ | [`showSnackbar()` / `closeAllSnackbars()` / `useSnackbar()`](https://github.com/digitalwalletcorp/vue-core/blob/main/docs/components/snackbar.md) | Shows a short message at an edge of the screen. |
231
242
  | [`showOverlayBox()` / `closeAllOverlayBoxes()` / `useOverlayBox()`](https://github.com/digitalwalletcorp/vue-core/blob/main/docs/components/overlay-box.md) | Shows a component in an `OverlayBox` and returns a handle to close it. |
232
243
  | [`showFloatingComponent()` / `showFloatingMessage()` / `closeAllFloatingComponents()` / `useFloatingComponent()`](https://github.com/digitalwalletcorp/vue-core/blob/main/docs/components/floating-component.md) | Shows a component or a message in a window that floats over the page without a backdrop. |
233
244
  | [`showScreenLoading()`](https://github.com/digitalwalletcorp/vue-core/blob/main/docs/components/screen-loading.md) | Covers the whole screen with a spinner until the returned handle is closed. |
@@ -1 +1 @@
1
- "use strict";const n=require("./warning-popper.vue_vue_type_style_index_0_lang-142lRixg.cjs"),_=Object.freeze(Object.defineProperty({__proto__:null,AccordionFieldset:n._sfc_main$4,AccordionSection:n._sfc_main$5,CopyButton:n._sfc_main$1,DarkModeSelector:n._sfc_main$6,DataTable:n._sfc_main$7,HelpButton:n._sfc_main$8,HelpPopper:n._sfc_main$9,HourglassLoading:n._sfc_main$10,IntersectionLazyComponent:n._sfc_main$11,LabelButton:n._sfc_main$12,LabelIcon:n._sfc_main$13,ModalDialog:n._sfc_main$2,OverlayBox:n._sfc_main$14,PageSection:n._sfc_main$15,PageTitle:n._sfc_main$16,ScreenLoading:n._sfc_main$3,TabContent:n._sfc_main$17,TabGroup:n._sfc_main$18,WarningPopper:n._sfc_main$19},Symbol.toStringTag,{value:"Module"}));exports.components=_;
1
+ "use strict";const n=require("./warning-popper.vue_vue_type_style_index_0_lang-BxdfpRXg.cjs"),_=Object.freeze(Object.defineProperty({__proto__:null,AccordionFieldset:n._sfc_main$4,AccordionSection:n._sfc_main$5,CopyButton:n._sfc_main$1,DarkModeSelector:n._sfc_main$6,DataTable:n._sfc_main$7,HelpButton:n._sfc_main$8,HelpPopper:n._sfc_main$9,HourglassLoading:n._sfc_main$10,IntersectionLazyComponent:n._sfc_main$11,LabelButton:n._sfc_main$12,LabelIcon:n._sfc_main$13,ModalDialog:n._sfc_main$2,OverlayBox:n._sfc_main$14,PageSection:n._sfc_main$15,PageTitle:n._sfc_main$16,ScreenLoading:n._sfc_main$3,TabContent:n._sfc_main$17,TabGroup:n._sfc_main$18,WarningPopper:n._sfc_main$19},Symbol.toStringTag,{value:"Module"}));exports.components=_;
@@ -1,4 +1,4 @@
1
- import { e as a, f as s, a as n, g as _, h as o, i as e, j as c, k as i, l as t, o as f, p as m, b as r, q as l, r as $, s as p, d, v as g, w as b, x as u } from "./warning-popper.vue_vue_type_style_index_0_lang-BKR56ef2.js";
1
+ import { e as a, f as s, a as n, g as _, h as o, i as e, j as c, k as i, l as t, o as f, p as m, b as r, q as l, r as $, s as p, d, v as g, w as b, x as u } from "./warning-popper.vue_vue_type_style_index_0_lang-DuzeuEx2.js";
2
2
  const y = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3
3
  __proto__: null,
4
4
  AccordionFieldset: a,
@@ -3,6 +3,10 @@ export interface Props {
3
3
  value: string | number | (() => string | number);
4
4
  /** ボタンの読み上げ名。スロットで文字を渡したときは使わない */
5
5
  label?: string;
6
+ /** コピーした後に snackbar で表示する文字列。未指定なら表示しない */
7
+ copiedMessage?: string;
8
+ /** copiedMessage の snackbar が自動で閉じるまでの時間(ミリ秒) */
9
+ copiedDuration?: number;
6
10
  }
7
11
  export interface Emits {
8
12
  /** コピーに成功したときに、コピーした文字列を発行する */
@@ -23,6 +27,8 @@ declare const __VLS_base: import('vue').DefineComponent<Props, {}, {}, {}, {}, i
23
27
  "onEmit:error"?: ((error: unknown) => any) | undefined;
24
28
  }>, {
25
29
  label: string;
30
+ copiedMessage: string;
31
+ copiedDuration: number;
26
32
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
27
33
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
28
34
  declare const _default: typeof __VLS_export;
@@ -3,6 +3,10 @@ export interface Props {
3
3
  value: string | number | (() => string | number);
4
4
  /** ボタンの読み上げ名。スロットで文字を渡したときは使わない */
5
5
  label?: string;
6
+ /** コピーした後に snackbar で表示する文字列。未指定なら表示しない */
7
+ copiedMessage?: string;
8
+ /** copiedMessage の snackbar が自動で閉じるまでの時間(ミリ秒) */
9
+ copiedDuration?: number;
6
10
  }
7
11
  export interface Emits {
8
12
  /** コピーに成功したときに、コピーした文字列を発行する */
@@ -23,6 +27,8 @@ declare const __VLS_base: import('vue').DefineComponent<Props, {}, {}, {}, {}, i
23
27
  "onEmit:error"?: ((error: unknown) => any) | undefined;
24
28
  }>, {
25
29
  label: string;
30
+ copiedMessage: string;
31
+ copiedDuration: number;
26
32
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
27
33
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
28
34
  declare const _default: typeof __VLS_export;
@@ -19,11 +19,11 @@ export interface Slots {
19
19
  }
20
20
  type __VLS_Slots = Slots;
21
21
  declare const __VLS_base: import('vue').DefineComponent<Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
22
- "emit:open": () => any;
23
22
  "emit:close": () => any;
23
+ "emit:open": () => any;
24
24
  }, string, import('vue').PublicProps, Readonly<Props> & Readonly<{
25
- "onEmit:open"?: (() => any) | undefined;
26
25
  "onEmit:close"?: (() => any) | undefined;
26
+ "onEmit:open"?: (() => any) | undefined;
27
27
  }>, {
28
28
  label: string;
29
29
  placement: PopoverPlacement;
@@ -19,11 +19,11 @@ export interface Slots {
19
19
  }
20
20
  type __VLS_Slots = Slots;
21
21
  declare const __VLS_base: import('vue').DefineComponent<Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
22
- "emit:open": () => any;
23
22
  "emit:close": () => any;
23
+ "emit:open": () => any;
24
24
  }, string, import('vue').PublicProps, Readonly<Props> & Readonly<{
25
- "onEmit:open"?: (() => any) | undefined;
26
25
  "onEmit:close"?: (() => any) | undefined;
26
+ "onEmit:open"?: (() => any) | undefined;
27
27
  }>, {
28
28
  label: string;
29
29
  placement: PopoverPlacement;
@@ -19,11 +19,11 @@ export interface Slots {
19
19
  }
20
20
  type __VLS_Slots = Slots;
21
21
  declare const __VLS_base: import('vue').DefineComponent<Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
22
- "emit:open": () => any;
23
22
  "emit:close": () => any;
23
+ "emit:open": () => any;
24
24
  }, string, import('vue').PublicProps, Readonly<Props> & Readonly<{
25
- "onEmit:open"?: (() => any) | undefined;
26
25
  "onEmit:close"?: (() => any) | undefined;
26
+ "onEmit:open"?: (() => any) | undefined;
27
27
  }>, {
28
28
  label: string;
29
29
  placement: PopoverPlacement;
@@ -19,11 +19,11 @@ export interface Slots {
19
19
  }
20
20
  type __VLS_Slots = Slots;
21
21
  declare const __VLS_base: import('vue').DefineComponent<Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
22
- "emit:open": () => any;
23
22
  "emit:close": () => any;
23
+ "emit:open": () => any;
24
24
  }, string, import('vue').PublicProps, Readonly<Props> & Readonly<{
25
- "onEmit:open"?: (() => any) | undefined;
26
25
  "onEmit:close"?: (() => any) | undefined;
26
+ "onEmit:open"?: (() => any) | undefined;
27
27
  }>, {
28
28
  label: string;
29
29
  placement: PopoverPlacement;
@@ -22,8 +22,11 @@ export interface ShowSnackbarOptions {
22
22
  title?: string;
23
23
  /** 見出しの右側に出す短い文字 */
24
24
  label?: string;
25
- /** 右下に出す時刻。整形済みの文字列を渡す */
26
- timestamp?: string;
25
+ /**
26
+ * 右下に出す時刻のタイムゾーン(IANA名)。未指定か空文字なら UTC、false なら時刻を出さない。
27
+ * useSnackbar() から呼ぶときは、未指定なら vueCoreOptionsKey の snackbar.timezone を使う
28
+ */
29
+ timezone?: string | false;
27
30
  /** 自動で閉じるまでの時間(ミリ秒)。未指定ならクリックするまで閉じない */
28
31
  duration?: number;
29
32
  /** 表示する位置 */
@@ -51,6 +54,8 @@ export interface SnackbarHandle {
51
54
  * placement と direction の組み合わせが同じ snackbar は同じ表示領域に並び、新しいものが末尾(overlap では前面)に加わる。
52
55
  * クリックすると閉じる。ブラウザでのみ動作する
53
56
  *
57
+ * 時刻は timezone で整形する。アプリ既定のタイムゾーンを使うには useSnackbar() から呼ぶ
58
+ *
54
59
  * @param {string} message 表示する文字列
55
60
  * @param {ShowSnackbarOptions} [options]
56
61
  * @returns {SnackbarHandle}
@@ -60,3 +65,13 @@ export declare function showSnackbar(message: string, options?: ShowSnackbarOpti
60
65
  * 表示中の snackbar をすべて閉じる。表示領域ごとに、古い順に少しずつずらして閉じる
61
66
  */
62
67
  export declare function closeAllSnackbars(): void;
68
+ /**
69
+ * vueCoreOptionsKey の snackbar の設定を既定にして snackbar を表示する関数を返す。
70
+ * 設定は表示するたびに読むため、ref や関数で渡した値の変化に追従する。
71
+ * コンポーネントの setup の中で呼ぶこと
72
+ *
73
+ * @returns {{ showSnackbar: typeof showSnackbar }}
74
+ */
75
+ export declare function useSnackbar(): {
76
+ showSnackbar: typeof showSnackbar;
77
+ };
@@ -22,8 +22,11 @@ export interface ShowSnackbarOptions {
22
22
  title?: string;
23
23
  /** 見出しの右側に出す短い文字 */
24
24
  label?: string;
25
- /** 右下に出す時刻。整形済みの文字列を渡す */
26
- timestamp?: string;
25
+ /**
26
+ * 右下に出す時刻のタイムゾーン(IANA名)。未指定か空文字なら UTC、false なら時刻を出さない。
27
+ * useSnackbar() から呼ぶときは、未指定なら vueCoreOptionsKey の snackbar.timezone を使う
28
+ */
29
+ timezone?: string | false;
27
30
  /** 自動で閉じるまでの時間(ミリ秒)。未指定ならクリックするまで閉じない */
28
31
  duration?: number;
29
32
  /** 表示する位置 */
@@ -51,6 +54,8 @@ export interface SnackbarHandle {
51
54
  * placement と direction の組み合わせが同じ snackbar は同じ表示領域に並び、新しいものが末尾(overlap では前面)に加わる。
52
55
  * クリックすると閉じる。ブラウザでのみ動作する
53
56
  *
57
+ * 時刻は timezone で整形する。アプリ既定のタイムゾーンを使うには useSnackbar() から呼ぶ
58
+ *
54
59
  * @param {string} message 表示する文字列
55
60
  * @param {ShowSnackbarOptions} [options]
56
61
  * @returns {SnackbarHandle}
@@ -60,3 +65,13 @@ export declare function showSnackbar(message: string, options?: ShowSnackbarOpti
60
65
  * 表示中の snackbar をすべて閉じる。表示領域ごとに、古い順に少しずつずらして閉じる
61
66
  */
62
67
  export declare function closeAllSnackbars(): void;
68
+ /**
69
+ * vueCoreOptionsKey の snackbar の設定を既定にして snackbar を表示する関数を返す。
70
+ * 設定は表示するたびに読むため、ref や関数で渡した値の変化に追従する。
71
+ * コンポーネントの setup の中で呼ぶこと
72
+ *
73
+ * @returns {{ showSnackbar: typeof showSnackbar }}
74
+ */
75
+ export declare function useSnackbar(): {
76
+ showSnackbar: typeof showSnackbar;
77
+ };
@@ -1,14 +1,25 @@
1
- import { InjectionKey } from 'vue';
1
+ import { InjectionKey, MaybeRefOrGetter } from 'vue';
2
2
  import { Props } from '../data-table.cjs';
3
3
  /**
4
4
  * DataTable のアプリ既定の設定。vueCoreOptionsKey の dataTable で渡す。
5
5
  * props のうちデータと表示の状態を除いた項目を持ち、DataTable の props に同じ名前の指定があればそちらが優先される
6
6
  */
7
7
  export type DataTableOptions = Partial<Omit<Props, 'dataList' | 'headers' | 'loading' | 'totalCount' | 'current' | 'limit'>>;
8
+ /** snackbar のアプリ既定の設定。vueCoreOptionsKey の snackbar で渡す */
9
+ export type SnackbarOptions = {
10
+ /**
11
+ * 時刻を表示するタイムゾーン(IANA名)。未指定か空文字なら UTC、false なら時刻を表示しない。
12
+ * ref や関数で渡すと表示するたびに読むため、利用者が選んだタイムゾーンの変化に追従する。
13
+ * showSnackbar() の timezone に指定があればそちらが優先される
14
+ */
15
+ timezone?: MaybeRefOrGetter<string | false | undefined>;
16
+ };
8
17
  /** アプリ全体の設定 */
9
18
  export type VueCoreOptions = {
10
19
  /** DataTable のアプリ既定の設定 */
11
20
  dataTable?: DataTableOptions;
21
+ /** snackbar のアプリ既定の設定 */
22
+ snackbar?: SnackbarOptions;
12
23
  };
13
24
  /**
14
25
  * アプリ全体の設定を provide/inject するためのキー
@@ -1,14 +1,25 @@
1
- import { InjectionKey } from 'vue';
1
+ import { InjectionKey, MaybeRefOrGetter } from 'vue';
2
2
  import { Props } from '../data-table';
3
3
  /**
4
4
  * DataTable のアプリ既定の設定。vueCoreOptionsKey の dataTable で渡す。
5
5
  * props のうちデータと表示の状態を除いた項目を持ち、DataTable の props に同じ名前の指定があればそちらが優先される
6
6
  */
7
7
  export type DataTableOptions = Partial<Omit<Props, 'dataList' | 'headers' | 'loading' | 'totalCount' | 'current' | 'limit'>>;
8
+ /** snackbar のアプリ既定の設定。vueCoreOptionsKey の snackbar で渡す */
9
+ export type SnackbarOptions = {
10
+ /**
11
+ * 時刻を表示するタイムゾーン(IANA名)。未指定か空文字なら UTC、false なら時刻を表示しない。
12
+ * ref や関数で渡すと表示するたびに読むため、利用者が選んだタイムゾーンの変化に追従する。
13
+ * showSnackbar() の timezone に指定があればそちらが優先される
14
+ */
15
+ timezone?: MaybeRefOrGetter<string | false | undefined>;
16
+ };
8
17
  /** アプリ全体の設定 */
9
18
  export type VueCoreOptions = {
10
19
  /** DataTable のアプリ既定の設定 */
11
20
  dataTable?: DataTableOptions;
21
+ /** snackbar のアプリ既定の設定 */
22
+ snackbar?: SnackbarOptions;
12
23
  };
13
24
  /**
14
25
  * アプリ全体の設定を provide/inject するためのキー
package/lib/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./warning-popper.vue_vue_type_style_index_0_lang-142lRixg.cjs"),e=require("vue"),E=require("@digitalwalletcorp/vue-svg-icons"),T=e.defineComponent({__name:"floating-component",props:{open:{type:Boolean},title:{},anchor:{},dragMode:{},loading:{type:Boolean},closeLabel:{},copyValue:{type:[String,Number,Function]},copyLabel:{},closeOnDblClick:{type:Boolean},lockScroll:{type:Boolean},initialSize:{},headerClass:{type:[Boolean,null,String,Object,Array]},headerStyle:{type:[Boolean,null,String,Object,Array]}},emits:["update:open","emit:close"],setup(n,{emit:t}){const o=n,l=t,s=e.ref(),i=e.ref(a.nextWindowOrder()),c=()=>{i.value=a.nextWindowOrder()},d=()=>{o.closeOnDblClick&&l("update:open",!1)},r=()=>{const u=s.value;if(!u?.element)return;const m=u.element.getBoundingClientRect();let p=o.initialSize?.width??m.width;window.innerWidth<p&&(p=window.innerWidth*.9);let f=o.initialSize?.height??-1;window.innerHeight<f&&(f=window.innerHeight*.9),u.size.width=p,u.size.height=f;const C=document.documentElement.scrollLeft,b=document.documentElement.scrollTop;if(o.anchor){const L={width:p,height:0<=f?f:m.height},D={width:document.documentElement.clientWidth,height:document.documentElement.clientHeight},k=a.computeAnchoredPosition(o.anchor.getBoundingClientRect(),L,D,{placement:"bottom-start",offset:0,margin:0,arrowMargin:0});u.position.x=k.left+C,u.position.y=k.top+b}else u.position.x=10+C,u.position.y=10+b};return e.onMounted(()=>{o.open&&r()}),(u,m)=>(e.openBlock(),e.createBlock(e.Transition,{name:"dwui-floating-component-fade",onAfterLeave:m[1]||(m[1]=p=>l("emit:close"))},{default:e.withCtx(()=>[o.open?(e.openBlock(),e.createBlock(a._sfc_main,{key:0,ref_key:"refWindow",ref:s,class:e.normalizeClass(["dwui-floating-component",{"dwui-lock-scroll":o.lockScroll}]),name:"dwui-floating-component",style:e.normalizeStyle({"--dwui-order-window":i.value}),"drag-mode":o.dragMode,loading:o.loading,"close-label":o.closeLabel,"clamp-bottom":!1,"header-class":o.headerClass,"header-style":o.headerStyle,onPointerdownCapture:c,onDblclick:d,"onEmit:close":m[0]||(m[0]=p=>l("update:open",!1))},e.createSlots({title:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(o.title),1)]),default:e.withCtx(()=>[e.renderSlot(u.$slots,"default")]),_:2},[o.copyValue!=null?{name:"actions",fn:e.withCtx(()=>[e.createVNode(a._sfc_main$1,{class:"dwui-floating-component-copy-button",value:o.copyValue,"aria-label":o.copyLabel},null,8,["value","aria-label"])]),key:"0"}:void 0]),1032,["class","style","drag-mode","loading","close-label","header-class","header-style"])):e.createCommentVNode("",!0)]),_:3}))}}),B=new Set,h=(n,t,o)=>{const{appContext:l,onClose:s,...i}=t??{};return a.mountWindow((c,d)=>e.h(T,{closeLabel:"Close",copyLabel:"Copy",closeOnDblClick:!1,lockScroll:!1,...i,...c},{default:()=>n(d)}),{appContext:l,onClose:s,onClosed:o},B)},S=(n,t)=>o=>e.h(n,{...t,...o}),$=(n,t)=>()=>t&&typeof n=="string"?e.h("div",{class:"dwui-floating-component-message",innerHTML:n}):e.h("div",{class:"dwui-floating-component-message"},a.toMessageText(n));function O(n,t,o){return h(S(n,t),o)}function M(n,t){const{html:o,...l}=t??{};return h($(n,o),{copyValue:a.toMessageText(n),...l})}function V(){for(const n of[...B])n.close()}function A(){const n=a.useWindowOwner("useFloatingComponent"),t=o=>({appContext:n.appContext,...o});return{showFloatingComponent:(o,l,s)=>n.own(i=>h(S(o,l),t(s),i)),showFloatingMessage:(o,l)=>{const{html:s,...i}=l??{};return n.own(c=>h($(o,s),t({copyValue:a.toMessageText(o),...i}),c))}}}function w(n,t){const{icon:o,appContext:l,...s}=t??{};return new Promise(i=>{const c=document.createElement("div");document.body.appendChild(c);const d=e.h(a._sfc_main$2,{...s,message:n,open:!0,"onEmit:close":r=>{e.render(null,c),c.remove(),i(r)}},o?{icon:()=>e.h(o)}:void 0);l&&(d.appContext=l),e.render(d,c)})}function F(n,t){return w(n,{...t,type:"info"})}function W(n,t){return w(n,{...t,type:"confirm"})}function z(n,t){return w(n,{...t,type:"warn"})}function N(n,t){return w(n,{...t,type:"error"})}function P(n){const t=document.createElement("div");document.body.appendChild(t);const o=()=>{e.render(null,t),t.remove()};return e.render(e.h(a._sfc_main$3,{...n,loading:!0}),t),{close:o}}const I=["aria-label","title"],H=["title","onClick"],R={key:0,class:"dwui-snackbar-header"},j={key:0,class:"dwui-snackbar-title"},q={key:1,class:"dwui-snackbar-label"},G={class:"dwui-snackbar-message"},K={key:1,class:"dwui-snackbar-timestamp"},J=e.defineComponent({__name:"snackbar-container",props:{placement:{},direction:{},items:{}},emits:["emit:close","emit:clear","emit:afterLeave"],setup(n,{emit:t}){const o=n,l=t,s=e.computed(()=>{const[c,d="center"]=o.placement.split("-");return[`dwui-snackbar-container-${c}`,`dwui-snackbar-container-${d}`,`dwui-snackbar-container-${o.direction}`]}),i=e.computed(()=>o.items.filter(c=>c.clearable).at(-1)?.clearLabel);return(c,d)=>(e.openBlock(),e.createBlock(e.TransitionGroup,{tag:"div",name:"dwui-snackbar-fade",class:e.normalizeClass(["dwui-snackbar-container",s.value]),role:"status",onAfterLeave:d[1]||(d[1]=r=>l("emit:afterLeave"))},{default:e.withCtx(()=>[i.value!=null?(e.openBlock(),e.createElementBlock("button",{key:"clear",type:"button",class:"dwui-snackbar-clear-button","aria-label":i.value,title:i.value,onClick:d[0]||(d[0]=r=>l("emit:clear"))},[e.createVNode(e.unref(E.SvgWastebasket))],8,I)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.items,r=>(e.openBlock(),e.createElementBlock("button",{key:r.id,type:"button",class:e.normalizeClass(["dwui-snackbar",r.class]),style:e.normalizeStyle(r.style),title:r.message,onClick:u=>l("emit:close",r.id)},[r.title||r.label?(e.openBlock(),e.createElementBlock("span",R,[r.title?(e.openBlock(),e.createElementBlock("span",j,e.toDisplayString(r.title),1)):e.createCommentVNode("",!0),r.label?(e.openBlock(),e.createElementBlock("span",q,e.toDisplayString(r.label),1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),e.createElementVNode("span",G,e.toDisplayString(r.message),1),r.timestamp?(e.openBlock(),e.createElementBlock("span",K,e.toDisplayString(r.timestamp),1)):e.createCommentVNode("",!0)],14,H))),128))]),_:1},8,["class"]))}}),Q=50,g=new Map,y=new Map;let v=0;const _=(n,t,o)=>{const l=n.findIndex(i=>i.id===t);if(l<0)return;n.splice(l,1);const s=y.get(t);y.delete(t),clearTimeout(s?.timer),s?.onClose?.(o)},x=n=>{const t=n.map(o=>o.id);for(let o=0;o<t.length;o++)setTimeout(()=>_(n,t[o],"clear"),Q*o)},U=(n,t)=>{const o=`${n} ${t}`,l=g.get(o);if(l)return l;const s=document.createElement("div");document.body.appendChild(s);const i=e.shallowReactive([]);return g.set(o,i),e.render(e.h(J,{placement:n,direction:t,items:i,"onEmit:close":c=>_(i,c,"click"),"onEmit:clear":()=>x(i),"onEmit:afterLeave":()=>{i.length===0&&g.get(o)===i&&(g.delete(o),e.render(null,s),s.remove())}}),s),i};function X(n,t){const{placement:o="bottom",direction:l="overlap",duration:s,clearable:i=!1,clearLabel:c="Clear all",onClose:d,...r}=t??{},u=U(o,l);v+=1;const m=v;return u.push({...r,id:m,message:n,clearable:i,clearLabel:c}),y.set(m,{timer:s?setTimeout(()=>_(u,m,"duration"),s):void 0,onClose:d}),{close:()=>_(u,m,"handle")}}function Y(){for(const n of g.values())x(n)}exports.AccordionFieldset=a._sfc_main$4;exports.AccordionSection=a._sfc_main$5;exports.CopyButton=a._sfc_main$1;exports.DarkModeSelector=a._sfc_main$6;exports.DataTable=a._sfc_main$7;exports.HelpButton=a._sfc_main$8;exports.HelpPopper=a._sfc_main$9;exports.HourglassLoading=a._sfc_main$10;exports.IntersectionLazyComponent=a._sfc_main$11;exports.LabelButton=a._sfc_main$12;exports.LabelIcon=a._sfc_main$13;exports.ModalDialog=a._sfc_main$2;exports.OverlayBox=a._sfc_main$14;exports.PageSection=a._sfc_main$15;exports.PageTitle=a._sfc_main$16;exports.ScreenLoading=a._sfc_main$3;exports.TabContent=a._sfc_main$17;exports.TabGroup=a._sfc_main$18;exports.WarningPopper=a._sfc_main$19;exports.closeAllOverlayBoxes=a.closeAllOverlayBoxes;exports.headersToCsvColumns=a.headersToCsvColumns;exports.rowToCsvColumns=a.rowToCsvColumns;exports.showOverlayBox=a.showOverlayBox;exports.useOverlayBox=a.useOverlayBox;exports.vueCoreOptionsKey=a.vueCoreOptionsKey;exports.closeAllFloatingComponents=V;exports.closeAllSnackbars=Y;exports.showConfirmationDialog=W;exports.showErrorDialog=N;exports.showFloatingComponent=O;exports.showFloatingMessage=M;exports.showInformationDialog=F;exports.showModalDialog=w;exports.showScreenLoading=P;exports.showSnackbar=X;exports.showWarningDialog=z;exports.useFloatingComponent=A;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./warning-popper.vue_vue_type_style_index_0_lang-BxdfpRXg.cjs"),t=require("vue"),$=t.defineComponent({__name:"floating-component",props:{open:{type:Boolean},title:{},anchor:{},dragMode:{},loading:{type:Boolean},closeLabel:{},copyValue:{type:[String,Number,Function]},copyLabel:{},closeOnDblClick:{type:Boolean},lockScroll:{type:Boolean},initialSize:{},headerClass:{type:[Boolean,null,String,Object,Array]},headerStyle:{type:[Boolean,null,String,Object,Array]}},emits:["update:open","emit:close"],setup(n,{emit:i}){const o=n,l=i,a=t.ref(),s=t.ref(e.nextWindowOrder()),r=()=>{s.value=e.nextWindowOrder()},u=()=>{o.closeOnDblClick&&l("update:open",!1)},w=()=>{const c=a.value;if(!c?.element)return;const d=c.element.getBoundingClientRect();let p=o.initialSize?.width??d.width;window.innerWidth<p&&(p=window.innerWidth*.9);let m=o.initialSize?.height??-1;window.innerHeight<m&&(m=window.innerHeight*.9),c.size.width=p,c.size.height=m;const h=document.documentElement.scrollLeft,_=document.documentElement.scrollTop;if(o.anchor){const S={width:p,height:0<=m?m:d.height},x={width:document.documentElement.clientWidth,height:document.documentElement.clientHeight},y=e.computeAnchoredPosition(o.anchor.getBoundingClientRect(),S,x,{placement:"bottom-start",offset:0,margin:0,arrowMargin:0});c.position.x=y.left+h,c.position.y=y.top+_}else c.position.x=10+h,c.position.y=10+_};return t.onMounted(()=>{o.open&&w()}),(c,d)=>(t.openBlock(),t.createBlock(t.Transition,{name:"dwui-floating-component-fade",onAfterLeave:d[1]||(d[1]=p=>l("emit:close"))},{default:t.withCtx(()=>[o.open?(t.openBlock(),t.createBlock(e._sfc_main,{key:0,ref_key:"refWindow",ref:a,class:t.normalizeClass(["dwui-floating-component",{"dwui-lock-scroll":o.lockScroll}]),name:"dwui-floating-component",style:t.normalizeStyle({"--dwui-order-window":s.value}),"drag-mode":o.dragMode,loading:o.loading,"close-label":o.closeLabel,"clamp-bottom":!1,"header-class":o.headerClass,"header-style":o.headerStyle,onPointerdownCapture:r,onDblclick:u,"onEmit:close":d[0]||(d[0]=p=>l("update:open",!1))},t.createSlots({title:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(o.title),1)]),default:t.withCtx(()=>[t.renderSlot(c.$slots,"default")]),_:2},[o.copyValue!=null?{name:"actions",fn:t.withCtx(()=>[t.createVNode(e._sfc_main$1,{class:"dwui-floating-component-copy-button",value:o.copyValue,"aria-label":o.copyLabel},null,8,["value","aria-label"])]),key:"0"}:void 0]),1032,["class","style","drag-mode","loading","close-label","header-class","header-style"])):t.createCommentVNode("",!0)]),_:3}))}}),C=new Set,g=(n,i,o)=>{const{appContext:l,onClose:a,...s}=i??{};return e.mountWindow((r,u)=>t.h($,{closeLabel:"Close",copyLabel:"Copy",closeOnDblClick:!1,lockScroll:!1,...s,...r},{default:()=>n(u)}),{appContext:l,onClose:a,onClosed:o},C)},b=(n,i)=>o=>t.h(n,{...i,...o}),v=(n,i)=>()=>i&&typeof n=="string"?t.h("div",{class:"dwui-floating-component-message",innerHTML:n}):t.h("div",{class:"dwui-floating-component-message"},e.toMessageText(n));function k(n,i,o){return g(b(n,i),o)}function B(n,i){const{html:o,...l}=i??{};return g(v(n,o),{copyValue:e.toMessageText(n),...l})}function O(){for(const n of[...C])n.close()}function D(){const n=e.useWindowOwner("useFloatingComponent"),i=o=>({appContext:n.appContext,...o});return{showFloatingComponent:(o,l,a)=>n.own(s=>g(b(o,l),i(a),s)),showFloatingMessage:(o,l)=>{const{html:a,...s}=l??{};return n.own(r=>g(v(o,a),i({copyValue:e.toMessageText(o),...s}),r))}}}function f(n,i){const{icon:o,appContext:l,...a}=i??{};return new Promise(s=>{const r=document.createElement("div");document.body.appendChild(r);const u=t.h(e._sfc_main$2,{...a,message:n,open:!0,"onEmit:close":w=>{t.render(null,r),r.remove(),s(w)}},o?{icon:()=>t.h(o)}:void 0);l&&(u.appContext=l),t.render(u,r)})}function L(n,i){return f(n,{...i,type:"info"})}function M(n,i){return f(n,{...i,type:"confirm"})}function T(n,i){return f(n,{...i,type:"warn"})}function F(n,i){return f(n,{...i,type:"error"})}function W(n){const i=document.createElement("div");document.body.appendChild(i);const o=()=>{t.render(null,i),i.remove()};return t.render(t.h(e._sfc_main$3,{...n,loading:!0}),i),{close:o}}exports.AccordionFieldset=e._sfc_main$4;exports.AccordionSection=e._sfc_main$5;exports.CopyButton=e._sfc_main$1;exports.DarkModeSelector=e._sfc_main$6;exports.DataTable=e._sfc_main$7;exports.HelpButton=e._sfc_main$8;exports.HelpPopper=e._sfc_main$9;exports.HourglassLoading=e._sfc_main$10;exports.IntersectionLazyComponent=e._sfc_main$11;exports.LabelButton=e._sfc_main$12;exports.LabelIcon=e._sfc_main$13;exports.ModalDialog=e._sfc_main$2;exports.OverlayBox=e._sfc_main$14;exports.PageSection=e._sfc_main$15;exports.PageTitle=e._sfc_main$16;exports.ScreenLoading=e._sfc_main$3;exports.TabContent=e._sfc_main$17;exports.TabGroup=e._sfc_main$18;exports.WarningPopper=e._sfc_main$19;exports.closeAllOverlayBoxes=e.closeAllOverlayBoxes;exports.closeAllSnackbars=e.closeAllSnackbars;exports.headersToCsvColumns=e.headersToCsvColumns;exports.rowToCsvColumns=e.rowToCsvColumns;exports.showOverlayBox=e.showOverlayBox;exports.showSnackbar=e.showSnackbar;exports.useOverlayBox=e.useOverlayBox;exports.useSnackbar=e.useSnackbar;exports.vueCoreOptionsKey=e.vueCoreOptionsKey;exports.closeAllFloatingComponents=O;exports.showConfirmationDialog=M;exports.showErrorDialog=F;exports.showFloatingComponent=k;exports.showFloatingMessage=B;exports.showInformationDialog=L;exports.showModalDialog=f;exports.showScreenLoading=W;exports.showWarningDialog=T;exports.useFloatingComponent=D;
package/lib/index.d.cts CHANGED
@@ -28,10 +28,10 @@ export { closeAllOverlayBoxes, showOverlayBox, useOverlayBox } from './helpers/o
28
28
  export type { OverlayBoxContentProps, OverlayBoxHandle, ShowOverlayBoxOptions } from './helpers/overlay-box.cjs';
29
29
  export { showScreenLoading } from './helpers/screen-loading.cjs';
30
30
  export type { ScreenLoadingHandle, ShowScreenLoadingOptions } from './helpers/screen-loading.cjs';
31
- export { closeAllSnackbars, showSnackbar } from './helpers/snackbar.cjs';
31
+ export { closeAllSnackbars, showSnackbar, useSnackbar } from './helpers/snackbar.cjs';
32
32
  export type { ShowSnackbarOptions, SnackbarCloseReason, SnackbarDirection, SnackbarHandle, SnackbarPlacement } from './helpers/snackbar.cjs';
33
33
  export type { MovableWindowContentProps, MovableWindowDragMode, MovableWindowHandle } from './internal/window-control.cjs';
34
34
  export type { TabContentStatus } from './internal/tab-group.cjs';
35
35
  export { vueCoreOptionsKey } from './helpers/vue-core-options.cjs';
36
- export type { DataTableOptions, VueCoreOptions } from './helpers/vue-core-options.cjs';
36
+ export type { DataTableOptions, SnackbarOptions, VueCoreOptions } from './helpers/vue-core-options.cjs';
37
37
  export type { PopoverPlacement } from './internal/anchored-position.cjs';
package/lib/index.d.ts CHANGED
@@ -28,10 +28,10 @@ export { closeAllOverlayBoxes, showOverlayBox, useOverlayBox } from './helpers/o
28
28
  export type { OverlayBoxContentProps, OverlayBoxHandle, ShowOverlayBoxOptions } from './helpers/overlay-box';
29
29
  export { showScreenLoading } from './helpers/screen-loading';
30
30
  export type { ScreenLoadingHandle, ShowScreenLoadingOptions } from './helpers/screen-loading';
31
- export { closeAllSnackbars, showSnackbar } from './helpers/snackbar';
31
+ export { closeAllSnackbars, showSnackbar, useSnackbar } from './helpers/snackbar';
32
32
  export type { ShowSnackbarOptions, SnackbarCloseReason, SnackbarDirection, SnackbarHandle, SnackbarPlacement } from './helpers/snackbar';
33
33
  export type { MovableWindowContentProps, MovableWindowDragMode, MovableWindowHandle } from './internal/window-control';
34
34
  export type { TabContentStatus } from './internal/tab-group';
35
35
  export { vueCoreOptionsKey } from './helpers/vue-core-options';
36
- export type { DataTableOptions, VueCoreOptions } from './helpers/vue-core-options';
36
+ export type { DataTableOptions, SnackbarOptions, VueCoreOptions } from './helpers/vue-core-options';
37
37
  export type { PopoverPlacement } from './internal/anchored-position';