@dou-ui/dashboard 0.0.0-stage → 0.1.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (188) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +10 -2
  3. package/dist/chart/chart-settings.js +6 -0
  4. package/dist/chart/chart-settings.js.map +1 -0
  5. package/dist/chart/chart-settings.vue_vue_type_script_setup_true_lang.js +122 -0
  6. package/dist/chart/chart-settings.vue_vue_type_script_setup_true_lang.js.map +1 -0
  7. package/dist/chart/chart.js +6 -0
  8. package/dist/chart/chart.js.map +1 -0
  9. package/dist/chart/chart.vue_vue_type_script_setup_true_lang.js +99 -0
  10. package/dist/chart/chart.vue_vue_type_script_setup_true_lang.js.map +1 -0
  11. package/dist/chart/index.js +33 -0
  12. package/dist/chart/index.js.map +1 -0
  13. package/dist/collaboration/index.js +281 -0
  14. package/dist/collaboration/index.js.map +1 -0
  15. package/dist/collaboration/order.js +88 -0
  16. package/dist/collaboration/order.js.map +1 -0
  17. package/dist/core/document.js +128 -0
  18. package/dist/core/document.js.map +1 -0
  19. package/dist/core/history.js +66 -0
  20. package/dist/core/history.js.map +1 -0
  21. package/dist/core/transaction.js +218 -0
  22. package/dist/core/transaction.js.map +1 -0
  23. package/dist/dashboard/dashboard.js +6 -0
  24. package/dist/dashboard/dashboard.js.map +1 -0
  25. package/dist/dashboard/dashboard.vue_vue_type_script_setup_true_lang.js +1072 -0
  26. package/dist/dashboard/dashboard.vue_vue_type_script_setup_true_lang.js.map +1 -0
  27. package/dist/dashboard/export.js +77 -0
  28. package/dist/dashboard/export.js.map +1 -0
  29. package/dist/dashboard/filter-bar.js +6 -0
  30. package/dist/dashboard/filter-bar.js.map +1 -0
  31. package/dist/dashboard/filter-bar.vue_vue_type_script_setup_true_lang.js +150 -0
  32. package/dist/dashboard/filter-bar.vue_vue_type_script_setup_true_lang.js.map +1 -0
  33. package/dist/dashboard/frame-context.js +5 -0
  34. package/dist/dashboard/frame-context.js.map +1 -0
  35. package/dist/dashboard/observers.js +48 -0
  36. package/dist/dashboard/observers.js.map +1 -0
  37. package/dist/dashboard/palette.js +6 -0
  38. package/dist/dashboard/palette.js.map +1 -0
  39. package/dist/dashboard/palette.vue_vue_type_script_setup_true_lang.js +54 -0
  40. package/dist/dashboard/palette.vue_vue_type_script_setup_true_lang.js.map +1 -0
  41. package/dist/dashboard/widget-body.js +6 -0
  42. package/dist/dashboard/widget-body.js.map +1 -0
  43. package/dist/dashboard/widget-body.vue_vue_type_script_setup_true_lang.js +96 -0
  44. package/dist/dashboard/widget-body.vue_vue_type_script_setup_true_lang.js.map +1 -0
  45. package/dist/dashboard/widget-frame.js +6 -0
  46. package/dist/dashboard/widget-frame.js.map +1 -0
  47. package/dist/dashboard/widget-frame.vue_vue_type_script_setup_true_lang.js +300 -0
  48. package/dist/dashboard/widget-frame.vue_vue_type_script_setup_true_lang.js.map +1 -0
  49. package/dist/dashboard/widget-settings.js +6 -0
  50. package/dist/dashboard/widget-settings.js.map +1 -0
  51. package/dist/dashboard/widget-settings.vue_vue_type_script_setup_true_lang.js +36 -0
  52. package/dist/dashboard/widget-settings.vue_vue_type_script_setup_true_lang.js.map +1 -0
  53. package/dist/data/context.js +5 -0
  54. package/dist/data/context.js.map +1 -0
  55. package/dist/data/filters.js +31 -0
  56. package/dist/data/filters.js.map +1 -0
  57. package/dist/data/store.js +214 -0
  58. package/dist/data/store.js.map +1 -0
  59. package/dist/grid/grid-handle.js +6 -0
  60. package/dist/grid/grid-handle.js.map +1 -0
  61. package/dist/grid/grid-handle.vue_vue_type_script_setup_true_lang.js +21 -0
  62. package/dist/grid/grid-handle.vue_vue_type_script_setup_true_lang.js.map +1 -0
  63. package/dist/grid/grid-item.js +80 -0
  64. package/dist/grid/grid-item.js.map +1 -0
  65. package/dist/grid/grid-layout.js +6 -0
  66. package/dist/grid/grid-layout.js.map +1 -0
  67. package/dist/grid/grid-layout.vue_vue_type_script_setup_true_lang.js +767 -0
  68. package/dist/grid/grid-layout.vue_vue_type_script_setup_true_lang.js.map +1 -0
  69. package/dist/grid/tiers.js +31 -0
  70. package/dist/grid/tiers.js.map +1 -0
  71. package/dist/index.js +23 -0
  72. package/dist/index.js.map +1 -0
  73. package/dist/layout/engine.js +284 -0
  74. package/dist/layout/engine.js.map +1 -0
  75. package/dist/layout/index.js +1 -0
  76. package/dist/locale.js +245 -0
  77. package/dist/locale.js.map +1 -0
  78. package/dist/pivot/index.js +47 -0
  79. package/dist/pivot/index.js.map +1 -0
  80. package/dist/pivot/pivot-settings.js +6 -0
  81. package/dist/pivot/pivot-settings.js.map +1 -0
  82. package/dist/pivot/pivot-settings.vue_vue_type_script_setup_true_lang.js +64 -0
  83. package/dist/pivot/pivot-settings.vue_vue_type_script_setup_true_lang.js.map +1 -0
  84. package/dist/pivot/pivot.js +6 -0
  85. package/dist/pivot/pivot.js.map +1 -0
  86. package/dist/pivot/pivot.vue_vue_type_script_setup_true_lang.js +76 -0
  87. package/dist/pivot/pivot.vue_vue_type_script_setup_true_lang.js.map +1 -0
  88. package/dist/style.css +1 -0
  89. package/dist/style.d.ts +1 -0
  90. package/dist/style.js +12 -0
  91. package/dist/types/chart/chart-settings.vue.d.ts +11 -0
  92. package/dist/types/chart/chart.vue.d.ts +3 -0
  93. package/dist/types/chart/index.d.ts +9 -0
  94. package/dist/types/chart/types.d.ts +23 -0
  95. package/dist/types/collaboration/index.d.ts +53 -0
  96. package/dist/types/collaboration/order.d.ts +20 -0
  97. package/dist/types/core/collaboration.d.ts +51 -0
  98. package/dist/types/core/document.d.ts +35 -0
  99. package/dist/types/core/history.d.ts +15 -0
  100. package/dist/types/core/transaction.d.ts +86 -0
  101. package/dist/types/core/types.d.ts +27 -0
  102. package/dist/types/dashboard/dashboard.vue.d.ts +33 -0
  103. package/dist/types/dashboard/export.d.ts +11 -0
  104. package/dist/types/dashboard/filter-bar.vue.d.ts +19 -0
  105. package/dist/types/dashboard/frame-context.d.ts +54 -0
  106. package/dist/types/dashboard/observers.d.ts +15 -0
  107. package/dist/types/dashboard/palette.vue.d.ts +20 -0
  108. package/dist/types/dashboard/types.d.ts +190 -0
  109. package/dist/types/dashboard/widget-body.vue.d.ts +19 -0
  110. package/dist/types/dashboard/widget-frame.vue.d.ts +6 -0
  111. package/dist/types/dashboard/widget-settings.vue.d.ts +16 -0
  112. package/dist/types/data/context.d.ts +18 -0
  113. package/dist/types/data/filters.d.ts +9 -0
  114. package/dist/types/data/store.d.ts +48 -0
  115. package/dist/types/data/types.d.ts +67 -0
  116. package/dist/types/grid/grid-handle.vue.d.ts +18 -0
  117. package/dist/types/grid/grid-item.d.ts +78 -0
  118. package/dist/types/grid/grid-layout.vue.d.ts +46 -0
  119. package/dist/types/grid/tiers.d.ts +12 -0
  120. package/dist/types/grid/types.d.ts +113 -0
  121. package/dist/types/index.d.ts +295 -0
  122. package/dist/types/layout/engine.d.ts +50 -0
  123. package/dist/types/layout/index.d.ts +2 -0
  124. package/dist/types/layout/types.d.ts +39 -0
  125. package/dist/types/locale.d.ts +117 -0
  126. package/dist/types/pivot/index.d.ts +14 -0
  127. package/dist/types/pivot/pivot-settings.vue.d.ts +16 -0
  128. package/dist/types/pivot/pivot.vue.d.ts +7 -0
  129. package/dist/types/pivot/types.d.ts +11 -0
  130. package/dist/types/widget/context.d.ts +91 -0
  131. package/dist/types/widget/define.d.ts +50 -0
  132. package/dist/types/widgets/field-select.vue.d.ts +18 -0
  133. package/dist/types/widgets/index.d.ts +15 -0
  134. package/dist/types/widgets/settings-field.vue.d.ts +17 -0
  135. package/dist/types/widgets/shared.d.ts +20 -0
  136. package/dist/types/widgets/source-field.vue.d.ts +15 -0
  137. package/dist/types/widgets/stat-settings.vue.d.ts +11 -0
  138. package/dist/types/widgets/stat.vue.d.ts +3 -0
  139. package/dist/types/widgets/table-settings.vue.d.ts +11 -0
  140. package/dist/types/widgets/table.vue.d.ts +3 -0
  141. package/dist/types/widgets/text-settings.vue.d.ts +11 -0
  142. package/dist/types/widgets/text.vue.d.ts +3 -0
  143. package/dist/types/widgets/types.d.ts +38 -0
  144. package/dist/widget/context.js +88 -0
  145. package/dist/widget/context.js.map +1 -0
  146. package/dist/widget/define.js +32 -0
  147. package/dist/widget/define.js.map +1 -0
  148. package/dist/widgets/field-select.js +6 -0
  149. package/dist/widgets/field-select.js.map +1 -0
  150. package/dist/widgets/field-select.vue_vue_type_script_setup_true_lang.js +54 -0
  151. package/dist/widgets/field-select.vue_vue_type_script_setup_true_lang.js.map +1 -0
  152. package/dist/widgets/index.js +74 -0
  153. package/dist/widgets/index.js.map +1 -0
  154. package/dist/widgets/settings-field.js +6 -0
  155. package/dist/widgets/settings-field.js.map +1 -0
  156. package/dist/widgets/settings-field.vue_vue_type_script_setup_true_lang.js +28 -0
  157. package/dist/widgets/settings-field.vue_vue_type_script_setup_true_lang.js.map +1 -0
  158. package/dist/widgets/shared.js +68 -0
  159. package/dist/widgets/shared.js.map +1 -0
  160. package/dist/widgets/source-field.js +6 -0
  161. package/dist/widgets/source-field.js.map +1 -0
  162. package/dist/widgets/source-field.vue_vue_type_script_setup_true_lang.js +47 -0
  163. package/dist/widgets/source-field.vue_vue_type_script_setup_true_lang.js.map +1 -0
  164. package/dist/widgets/stat-settings.js +6 -0
  165. package/dist/widgets/stat-settings.js.map +1 -0
  166. package/dist/widgets/stat-settings.vue_vue_type_script_setup_true_lang.js +107 -0
  167. package/dist/widgets/stat-settings.vue_vue_type_script_setup_true_lang.js.map +1 -0
  168. package/dist/widgets/stat.js +6 -0
  169. package/dist/widgets/stat.js.map +1 -0
  170. package/dist/widgets/stat.vue_vue_type_script_setup_true_lang.js +72 -0
  171. package/dist/widgets/stat.vue_vue_type_script_setup_true_lang.js.map +1 -0
  172. package/dist/widgets/table-settings.js +6 -0
  173. package/dist/widgets/table-settings.js.map +1 -0
  174. package/dist/widgets/table-settings.vue_vue_type_script_setup_true_lang.js +90 -0
  175. package/dist/widgets/table-settings.vue_vue_type_script_setup_true_lang.js.map +1 -0
  176. package/dist/widgets/table.js +6 -0
  177. package/dist/widgets/table.js.map +1 -0
  178. package/dist/widgets/table.vue_vue_type_script_setup_true_lang.js +91 -0
  179. package/dist/widgets/table.vue_vue_type_script_setup_true_lang.js.map +1 -0
  180. package/dist/widgets/text-settings.js +6 -0
  181. package/dist/widgets/text-settings.js.map +1 -0
  182. package/dist/widgets/text-settings.vue_vue_type_script_setup_true_lang.js +63 -0
  183. package/dist/widgets/text-settings.vue_vue_type_script_setup_true_lang.js.map +1 -0
  184. package/dist/widgets/text.js +6 -0
  185. package/dist/widgets/text.js.map +1 -0
  186. package/dist/widgets/text.vue_vue_type_script_setup_true_lang.js +16 -0
  187. package/dist/widgets/text.vue_vue_type_script_setup_true_lang.js.map +1 -0
  188. package/package.json +98 -4
@@ -0,0 +1,50 @@
1
+ import type { Component } from 'vue';
2
+ /** A new widget's size, and the limits a resize keeps to, in columns and rows. */
3
+ export interface DashboardWidgetSize {
4
+ w: number;
5
+ h: number;
6
+ minW?: number;
7
+ maxW?: number;
8
+ minH?: number;
9
+ maxH?: number;
10
+ }
11
+ /** A kind of widget a dashboard can hold, made with `defineDashboardWidget`. */
12
+ export interface DashboardWidgetType<P extends object = Record<string, unknown>> {
13
+ /** Stored in each widget's `type`. */
14
+ type: string;
15
+ /** Its name in the list of widgets to add, and the title of a widget without one. */
16
+ label: string;
17
+ /** Shown next to the label in the list of widgets to add. */
18
+ icon?: Component;
19
+ /** The size a new widget gets, and its limits. Defaults to 4 × 3. */
20
+ size?: DashboardWidgetSize;
21
+ /** The `props` a new widget starts with. */
22
+ defaultProps?: P | (() => P);
23
+ /** Draws the widget; it reads its settings and size with `useDashboardWidget()`. */
24
+ component: Component;
25
+ /**
26
+ * The settings form, shown in a drawer while editing. Bound with
27
+ * `v-model` to the widget's `props`; it also gets the `widget`.
28
+ */
29
+ settings?: Component;
30
+ /** Whether the widget can be viewed full screen. Defaults to `true`. */
31
+ fullscreen?: boolean;
32
+ }
33
+ /**
34
+ * Declares a kind of widget. Returns the definition as given, typed; pass
35
+ * it in the dashboard's `widgets` list.
36
+ *
37
+ * ```ts
38
+ * const stat = defineDashboardWidget({
39
+ * type: 'stat',
40
+ * label: '统计数字',
41
+ * size: { w: 3, h: 2, minW: 2 },
42
+ * defaultProps: { value: 0 },
43
+ * component: StatWidget,
44
+ * })
45
+ * ```
46
+ */
47
+ export declare function defineDashboardWidget<P extends object = Record<string, unknown>>(type: DashboardWidgetType<P>): DashboardWidgetType<P>;
48
+ export declare const DEFAULT_WIDGET_SIZE: DashboardWidgetSize;
49
+ /** A copy of a type's default props for a new widget. */
50
+ export declare function defaultPropsOf(type: DashboardWidgetType<any> | undefined): Record<string, unknown> | undefined;
@@ -0,0 +1,18 @@
1
+ type __VLS_Props = {
2
+ label: string;
3
+ hint?: string;
4
+ /** The fields of the data; a value not among them stays selectable. */
5
+ fields: string[];
6
+ multiple?: boolean;
7
+ };
8
+ type __VLS_ModelProps = {
9
+ modelValue?: string | string[] | undefined;
10
+ };
11
+ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
12
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
13
+ "update:modelValue": (value: string | string[] | undefined) => any;
14
+ }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
15
+ "onUpdate:modelValue"?: ((value: string | string[] | undefined) => any) | undefined;
16
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
17
+ declare const _default: typeof __VLS_export;
18
+ export default _default;
@@ -0,0 +1,15 @@
1
+ import type { DashboardWidgetType } from '../widget/define';
2
+ import type { StatWidgetProps, TableWidgetProps, TextWidgetProps } from './types';
3
+ export type { StatWidgetProps, TableWidgetColumn, TableWidgetProps, TextWidgetProps } from './types';
4
+ export { fieldsOf, filterValueOf, numberFieldsOf, rowsOf, valueAt } from './shared';
5
+ /** What a built-in widget's definition can change: its type, label, icon, size and more. */
6
+ export type WidgetOverrides<P extends object> = Partial<Omit<DashboardWidgetType<P>, 'component'>>;
7
+ /**
8
+ * A number, read from a source or given, with its change since the last
9
+ * period and a sparkline under it.
10
+ */
11
+ export declare function statWidget(overrides?: WidgetOverrides<StatWidgetProps>): DashboardWidgetType<StatWidgetProps>;
12
+ /** A note: plain text in three sizes, its line breaks kept. */
13
+ export declare function textWidget(overrides?: WidgetOverrides<TextWidgetProps>): DashboardWidgetType<TextWidgetProps>;
14
+ /** A source's rows in a table, with the columns picked in its settings. */
15
+ export declare function tableWidget(overrides?: WidgetOverrides<TableWidgetProps>): DashboardWidgetType<TableWidgetProps>;
@@ -0,0 +1,17 @@
1
+ type __VLS_Props = {
2
+ label: string;
3
+ hint?: string;
4
+ };
5
+ declare var __VLS_1: {};
6
+ type __VLS_Slots = {} & {
7
+ default?: (props: typeof __VLS_1) => any;
8
+ };
9
+ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
10
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
11
+ declare const _default: typeof __VLS_export;
12
+ export default _default;
13
+ type __VLS_WithSlots<T, S> = T & {
14
+ new (): {
15
+ $slots: S;
16
+ };
17
+ };
@@ -0,0 +1,20 @@
1
+ import type { SheetWorkbook } from '@dou-ui/sheet/core';
2
+ /** The value at a dotted path, e.g. `total.amount`; the data itself for an empty path. */
3
+ export declare function valueAt(data: unknown, path: string | undefined): unknown;
4
+ /** The rows of a source's data: the data when it is a list, or the list at `path`. */
5
+ export declare function rowsOf(data: unknown, path?: string): Record<string, unknown>[];
6
+ /** The keys of the first row of a list, or of an object: the fields to pick from in settings. */
7
+ export declare function fieldsOf(data: unknown): string[];
8
+ /** The keys whose value in the first row is a number. */
9
+ export declare function numberFieldsOf(data: unknown): string[];
10
+ export declare function filterValueOf(value: unknown): unknown;
11
+ /**
12
+ * Rows of data as a workbook, for the dashboard's export menu: one sheet,
13
+ * a bold head row with the columns' titles, a row per row of data. An
14
+ * empty `name` takes the widget's title.
15
+ */
16
+ export declare function rowsToWorkbook(name: string, columns: readonly {
17
+ key: string;
18
+ title: string;
19
+ width?: number;
20
+ }[], rows: readonly Record<string, unknown>[]): SheetWorkbook;
@@ -0,0 +1,15 @@
1
+ type __VLS_Props = {
2
+ optional?: boolean;
3
+ };
4
+ type __VLS_ModelProps = {
5
+ /** The source's name in the widget's `props.source`. */
6
+ modelValue?: string | undefined;
7
+ };
8
+ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
9
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
10
+ "update:modelValue": (value: string | undefined) => any;
11
+ }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
12
+ "onUpdate:modelValue"?: ((value: string | undefined) => any) | undefined;
13
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
14
+ declare const _default: typeof __VLS_export;
15
+ export default _default;
@@ -0,0 +1,11 @@
1
+ import type { StatWidgetProps } from './types';
2
+ type __VLS_ModelProps = {
3
+ modelValue: StatWidgetProps;
4
+ };
5
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_ModelProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
6
+ "update:modelValue": (value: StatWidgetProps) => any;
7
+ }, string, import("vue").PublicProps, Readonly<__VLS_ModelProps> & Readonly<{
8
+ "onUpdate:modelValue"?: ((value: StatWidgetProps) => any) | undefined;
9
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
10
+ declare const _default: typeof __VLS_export;
11
+ export default _default;
@@ -0,0 +1,3 @@
1
+ declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
2
+ declare const _default: typeof __VLS_export;
3
+ export default _default;
@@ -0,0 +1,11 @@
1
+ import type { TableWidgetProps } from './types';
2
+ type __VLS_ModelProps = {
3
+ modelValue: TableWidgetProps;
4
+ };
5
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_ModelProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
6
+ "update:modelValue": (value: TableWidgetProps) => any;
7
+ }, string, import("vue").PublicProps, Readonly<__VLS_ModelProps> & Readonly<{
8
+ "onUpdate:modelValue"?: ((value: TableWidgetProps) => any) | undefined;
9
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
10
+ declare const _default: typeof __VLS_export;
11
+ export default _default;
@@ -0,0 +1,3 @@
1
+ declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
2
+ declare const _default: typeof __VLS_export;
3
+ export default _default;
@@ -0,0 +1,11 @@
1
+ import type { TextWidgetProps } from './types';
2
+ type __VLS_ModelProps = {
3
+ modelValue: TextWidgetProps;
4
+ };
5
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_ModelProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
6
+ "update:modelValue": (value: TextWidgetProps) => any;
7
+ }, string, import("vue").PublicProps, Readonly<__VLS_ModelProps> & Readonly<{
8
+ "onUpdate:modelValue"?: ((value: TextWidgetProps) => any) | undefined;
9
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
10
+ declare const _default: typeof __VLS_export;
11
+ export default _default;
@@ -0,0 +1,3 @@
1
+ declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
2
+ declare const _default: typeof __VLS_export;
3
+ export default _default;
@@ -0,0 +1,38 @@
1
+ /** The `props` of a `stat` widget. */
2
+ export interface StatWidgetProps {
3
+ /** The source to read from; without it the widget shows `value`. */
4
+ source?: string;
5
+ /** Where the number is in the source's data, as a dotted path (`total.amount`). */
6
+ field?: string;
7
+ /** The number shown when there is no source. */
8
+ value?: number;
9
+ prefix?: string;
10
+ suffix?: string;
11
+ /** Decimal places. */
12
+ precision?: number;
13
+ /** Where a list of numbers is, drawn as a sparkline under the number. */
14
+ trend?: string;
15
+ /** Where the change since the last period is, as a ratio (`0.125` reads `+12.5%`). */
16
+ delta?: string;
17
+ }
18
+ /** The `props` of a `text` widget. */
19
+ export interface TextWidgetProps {
20
+ text?: string;
21
+ size?: 'sm' | 'md' | 'lg';
22
+ }
23
+ export interface TableWidgetColumn {
24
+ /** The row's key it shows. */
25
+ key: string;
26
+ /** The header; defaults to the key. */
27
+ title?: string;
28
+ }
29
+ /** The `props` of a `table` widget. */
30
+ export interface TableWidgetProps {
31
+ source?: string;
32
+ /** Where the rows are, when the data isn't the list itself. */
33
+ path?: string;
34
+ /** The columns, in order; defaults to every key of the first row. */
35
+ columns?: TableWidgetColumn[];
36
+ /** The field that tells rows apart; defaults to their place in the list. */
37
+ rowKey?: string;
38
+ }
@@ -0,0 +1,88 @@
1
+ import { dataContextKey } from "../data/context.js";
2
+ import { pickFilters } from "../data/filters.js";
3
+ import { computed, inject, onScopeDispose, provide, shallowRef, watch } from "vue";
4
+ // src/widget/context.ts
5
+ var widgetContextKey = Symbol("dou-dashboard-widget");
6
+ /** The widget a component is drawn in, for widget types' `component` and `settings`. */
7
+ function useDashboardWidget() {
8
+ const context = inject(widgetContextKey, null);
9
+ if (!context) throw new Error("[@dou-ui/dashboard] useDashboardWidget() must be called inside a dashboard widget");
10
+ return context;
11
+ }
12
+ var NONE = Object.freeze({});
13
+ /** Makes the context of one widget and provides it to the components below. */
14
+ function provideWidgetContext(source) {
15
+ const data = inject(dataContextKey, null);
16
+ const own = shallowRef({ state: "ready" });
17
+ const widget = computed(source.widget);
18
+ const id = computed(() => widget.value.id);
19
+ const filters = computed(() => data ? pickFilters(data.filters(), void 0, data.emitted(id.value)) : NONE);
20
+ const ownFilters = computed(() => {
21
+ const result = {};
22
+ for (const link of data?.linked(id.value) ?? []) result[link.key] = link.value;
23
+ return result;
24
+ });
25
+ const sourceName = computed(() => {
26
+ const name = widget.value.props?.source;
27
+ return typeof name === "string" && name ? name : void 0;
28
+ });
29
+ const entry = shallowRef();
30
+ let release;
31
+ const key = computed(() => data && sourceName.value ? data.store.keyOf(sourceName.value, filters.value).key : "");
32
+ watch(key, () => {
33
+ const next = data && sourceName.value ? data.store.use(sourceName.value, filters.value) : void 0;
34
+ release?.();
35
+ release = next?.release;
36
+ entry.value = next?.entry;
37
+ }, { immediate: true });
38
+ onScopeDispose(() => release?.());
39
+ const state = computed(() => entry.value?.state.value);
40
+ /** The last data loaded, kept while other data loads. */
41
+ const held = shallowRef();
42
+ watch(state, (next) => {
43
+ if (!entry.value) held.value = void 0;
44
+ else if (next?.status === "ready") held.value = next.data;
45
+ }, { immediate: true });
46
+ const error = computed(() => state.value?.status === "error" ? state.value.error : void 0);
47
+ const refresh = () => entry.value && data?.store.retry(entry.value);
48
+ const status = computed(() => {
49
+ const current = state.value;
50
+ if (current?.status === "loading" || current?.status === "idle") return { state: "loading" };
51
+ if (current?.status === "error") return {
52
+ state: "error",
53
+ retry: refresh
54
+ };
55
+ return own.value;
56
+ });
57
+ const context = {
58
+ widget,
59
+ props: computed(() => widget.value.props ?? {}),
60
+ editing: computed(source.editing),
61
+ fullscreen: computed(source.fullscreen),
62
+ size: source.size,
63
+ setProps: (patch, options) => source.setProps(id.value, patch, options),
64
+ status,
65
+ setStatus: (next, options) => own.value = {
66
+ state: next,
67
+ ...options
68
+ },
69
+ data: held,
70
+ error,
71
+ filters,
72
+ setFilter: (name, value, options) => data?.setFilter(id.value, name, value, options),
73
+ ownFilters,
74
+ refresh,
75
+ sources: computed(() => data?.sourceNames() ?? []),
76
+ setWorkbook: (get) => {
77
+ undoWorkbook?.();
78
+ undoWorkbook = get ? source.setWorkbook?.(id.value, get) : void 0;
79
+ }
80
+ };
81
+ let undoWorkbook;
82
+ onScopeDispose(() => undoWorkbook?.());
83
+ provide(widgetContextKey, context);
84
+ return context;
85
+ }
86
+ export { provideWidgetContext, useDashboardWidget, widgetContextKey };
87
+
88
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","names":[],"sources":["../../src/widget/context.ts"],"sourcesContent":["import { computed, inject, onScopeDispose, provide, shallowRef, watch } from 'vue'\nimport type { SheetWorkbook } from '@dou-ui/sheet/core'\nimport type { ComputedRef, InjectionKey, Ref } from 'vue'\nimport type { DashboardWidget } from '../core/types'\nimport { dataContextKey } from '../data/context'\nimport { pickFilters } from '../data/filters'\nimport type { SourceEntry } from '../data/store'\nimport type { DashboardFilters, DashboardSetFilterOptions } from '../data/types'\n\n/** What a widget shows instead of, or over, its content. */\nexport type DashboardWidgetState = 'ready' | 'loading' | 'error' | 'empty'\n\nexport interface DashboardWidgetStatus {\n state: DashboardWidgetState\n /** For `error` and `empty`: the line shown. */\n message?: string\n /** For `error`: what the retry button does; without it there is no button. */\n retry?: () => void\n}\n\nexport interface DashboardWidgetContext<P extends object = Record<string, unknown>, D = unknown> {\n /** The widget as stored in the document. */\n widget: ComputedRef<DashboardWidget<P>>\n /** Its `props`, `{}` when it has none. */\n props: ComputedRef<P>\n /** Whether the dashboard is being edited. */\n editing: ComputedRef<boolean>\n /** Whether this is the full-screen view of the widget. */\n fullscreen: ComputedRef<boolean>\n /** The size of the widget's content area, in px; updated once a frame at most. */\n size: { width: Ref<number>; height: Ref<number> }\n /**\n * Merges keys into the widget's `props`, as one undoable change. Changes\n * with the same `group` within a second undo together.\n */\n setProps: (patch: Partial<P>, options?: { group?: string }) => void\n /**\n * What the frame shows: a loading mark over the content, an error, or an\n * empty notice. Loading and failing to load `props.source` come first.\n */\n status: Readonly<Ref<DashboardWidgetStatus>>\n setStatus: (state: DashboardWidgetState, options?: Omit<DashboardWidgetStatus, 'state'>) => void\n /**\n * The data of the source named in `props.source`, loaded with the filters\n * in effect. While new data loads, the last data stays.\n */\n data: Readonly<Ref<D | undefined>>\n /** Why the source failed to load, if it did. */\n error: Readonly<Ref<unknown>>\n /** The filters in effect for this widget: all of them but those it set itself. */\n filters: ComputedRef<DashboardFilters>\n /**\n * Sets a filter for the other widgets, e.g. when a bar of a chart is\n * clicked; an empty value (`undefined`, `null`, `''`, `[]`) clears it.\n * The widget itself keeps showing everything, and its title bar shows\n * the filter with a button to clear it.\n */\n setFilter: (key: string, value: unknown, options?: DashboardSetFilterOptions) => void\n /** The filters this widget set itself and that are still in effect, e.g. to mark the picked bar. */\n ownFilters: ComputedRef<DashboardFilters>\n /** Loads the widget's source again. */\n refresh: () => void\n /** The names of the dashboard's sources, e.g. to pick one in a settings form. */\n sources: ComputedRef<string[]>\n /**\n * Gives the dashboard the widget's content as a workbook, read when it is\n * exported with one of the dashboard's `exporters`; a sheet without a\n * name takes the widget's title. Returning `undefined` fails the export\n * with \"no data to export\"; `null` takes the export menu away, such as\n * while the widget isn't set up. A widget that never calls it has no\n * export menu. Undone when the widget goes.\n */\n setWorkbook: (get: (() => SheetWorkbook | undefined) | null) => void\n}\n\nexport const widgetContextKey: InjectionKey<DashboardWidgetContext<any, any>> =\n Symbol('dou-dashboard-widget')\n\n/** The widget a component is drawn in, for widget types' `component` and `settings`. */\nexport function useDashboardWidget<\n P extends object = Record<string, unknown>,\n D = unknown,\n>(): DashboardWidgetContext<P, D> {\n const context = inject(widgetContextKey, null)\n if (!context)\n throw new Error(\n '[@dou-ui/dashboard] useDashboardWidget() must be called inside a dashboard widget',\n )\n return context as DashboardWidgetContext<P, D>\n}\n\ninterface ContextSource {\n widget: () => DashboardWidget\n editing: () => boolean\n fullscreen: () => boolean\n size: { width: Ref<number>; height: Ref<number> }\n setProps: (id: string, patch: Record<string, unknown>, options?: { group?: string }) => void\n setWorkbook?: (id: string, get: () => SheetWorkbook | undefined) => () => void\n}\n\nconst NONE: DashboardFilters = Object.freeze({}) as DashboardFilters\n\n/** Makes the context of one widget and provides it to the components below. */\nexport function provideWidgetContext(source: ContextSource): DashboardWidgetContext {\n const data = inject(dataContextKey, null)\n const own = shallowRef<DashboardWidgetStatus>({ state: 'ready' })\n const widget = computed(source.widget)\n const id = computed(() => widget.value.id)\n\n const filters = computed(() =>\n data ? pickFilters(data.filters(), undefined, data.emitted(id.value)) : NONE,\n )\n const ownFilters = computed(() => {\n const result: DashboardFilters = {}\n for (const link of data?.linked(id.value) ?? []) result[link.key] = link.value\n return result\n })\n const sourceName = computed(() => {\n const name = widget.value.props?.source\n return typeof name === 'string' && name ? name : undefined\n })\n\n // the widget shows the entry of its source and filters; another widget\n // with the same source and filters shows the same entry\n const entry = shallowRef<SourceEntry>()\n let release: (() => void) | undefined\n const key = computed(() =>\n data && sourceName.value ? data.store.keyOf(sourceName.value, filters.value).key : '',\n )\n watch(\n key,\n () => {\n const next =\n data && sourceName.value ? data.store.use(sourceName.value, filters.value) : undefined\n release?.()\n release = next?.release\n entry.value = next?.entry\n },\n { immediate: true },\n )\n onScopeDispose(() => release?.())\n\n const state = computed(() => entry.value?.state.value)\n /** The last data loaded, kept while other data loads. */\n const held = shallowRef<unknown>()\n watch(\n state,\n (next) => {\n if (!entry.value) held.value = undefined\n else if (next?.status === 'ready') held.value = next.data\n },\n { immediate: true },\n )\n const error = computed(() => (state.value?.status === 'error' ? state.value.error : undefined))\n const refresh = () => entry.value && data?.store.retry(entry.value)\n\n const status = computed<DashboardWidgetStatus>(() => {\n const current = state.value\n if (current?.status === 'loading' || current?.status === 'idle') return { state: 'loading' }\n if (current?.status === 'error') return { state: 'error', retry: refresh }\n return own.value\n })\n\n const context: DashboardWidgetContext = {\n widget,\n props: computed(() => widget.value.props ?? {}),\n editing: computed(source.editing),\n fullscreen: computed(source.fullscreen),\n size: source.size,\n setProps: (patch, options) => source.setProps(id.value, patch, options),\n status,\n setStatus: (next, options) => (own.value = { state: next, ...options }),\n data: held,\n error,\n filters,\n setFilter: (name, value, options) => data?.setFilter(id.value, name, value, options),\n ownFilters,\n refresh,\n sources: computed(() => data?.sourceNames() ?? []),\n setWorkbook: (get) => {\n undoWorkbook?.()\n undoWorkbook = get ? source.setWorkbook?.(id.value, get) : undefined\n },\n }\n let undoWorkbook: (() => void) | undefined\n onScopeDispose(() => undoWorkbook?.())\n provide(widgetContextKey, context)\n return context\n}\n"],"mappings":";;;;AA2EA,IAAa,mBACX,OAAO,sBAAsB;;AAG/B,SAAgB,qBAGkB;CAChC,MAAM,UAAU,OAAO,kBAAkB,IAAI;CAC7C,IAAI,CAAC,SACH,MAAM,IAAI,MACR,mFACF;CACF,OAAO;AACT;AAWA,IAAM,OAAyB,OAAO,OAAO,CAAC,CAAC;;AAG/C,SAAgB,qBAAqB,QAA+C;CAClF,MAAM,OAAO,OAAO,gBAAgB,IAAI;CACxC,MAAM,MAAM,WAAkC,EAAE,OAAO,QAAQ,CAAC;CAChE,MAAM,SAAS,SAAS,OAAO,MAAM;CACrC,MAAM,KAAK,eAAe,OAAO,MAAM,EAAE;CAEzC,MAAM,UAAU,eACd,OAAO,YAAY,KAAK,QAAQ,GAAG,KAAA,GAAW,KAAK,QAAQ,GAAG,KAAK,CAAC,IAAI,IAC1E;CACA,MAAM,aAAa,eAAe;EAChC,MAAM,SAA2B,CAAC;EAClC,KAAK,MAAM,QAAQ,MAAM,OAAO,GAAG,KAAK,KAAK,CAAC,GAAG,OAAO,KAAK,OAAO,KAAK;EACzE,OAAO;CACT,CAAC;CACD,MAAM,aAAa,eAAe;EAChC,MAAM,OAAO,OAAO,MAAM,OAAO;EACjC,OAAO,OAAO,SAAS,YAAY,OAAO,OAAO,KAAA;CACnD,CAAC;CAID,MAAM,QAAQ,WAAwB;CACtC,IAAI;CACJ,MAAM,MAAM,eACV,QAAQ,WAAW,QAAQ,KAAK,MAAM,MAAM,WAAW,OAAO,QAAQ,KAAK,CAAC,CAAC,MAAM,EACrF;CACA,MACE,WACM;EACJ,MAAM,OACJ,QAAQ,WAAW,QAAQ,KAAK,MAAM,IAAI,WAAW,OAAO,QAAQ,KAAK,IAAI,KAAA;EAC/E,UAAU;EACV,UAAU,MAAM;EAChB,MAAM,QAAQ,MAAM;CACtB,GACA,EAAE,WAAW,KAAK,CACpB;CACA,qBAAqB,UAAU,CAAC;CAEhC,MAAM,QAAQ,eAAe,MAAM,OAAO,MAAM,KAAK;;CAErD,MAAM,OAAO,WAAoB;CACjC,MACE,QACC,SAAS;EACR,IAAI,CAAC,MAAM,OAAO,KAAK,QAAQ,KAAA;OAC1B,IAAI,MAAM,WAAW,SAAS,KAAK,QAAQ,KAAK;CACvD,GACA,EAAE,WAAW,KAAK,CACpB;CACA,MAAM,QAAQ,eAAgB,MAAM,OAAO,WAAW,UAAU,MAAM,MAAM,QAAQ,KAAA,CAAU;CAC9F,MAAM,gBAAgB,MAAM,SAAS,MAAM,MAAM,MAAM,MAAM,KAAK;CAElE,MAAM,SAAS,eAAsC;EACnD,MAAM,UAAU,MAAM;EACtB,IAAI,SAAS,WAAW,aAAa,SAAS,WAAW,QAAQ,OAAO,EAAE,OAAO,UAAU;EAC3F,IAAI,SAAS,WAAW,SAAS,OAAO;GAAE,OAAO;GAAS,OAAO;EAAQ;EACzE,OAAO,IAAI;CACb,CAAC;CAED,MAAM,UAAkC;EACtC;EACA,OAAO,eAAe,OAAO,MAAM,SAAS,CAAC,CAAC;EAC9C,SAAS,SAAS,OAAO,OAAO;EAChC,YAAY,SAAS,OAAO,UAAU;EACtC,MAAM,OAAO;EACb,WAAW,OAAO,YAAY,OAAO,SAAS,GAAG,OAAO,OAAO,OAAO;EACtE;EACA,YAAY,MAAM,YAAa,IAAI,QAAQ;GAAE,OAAO;GAAM,GAAG;EAAQ;EACrE,MAAM;EACN;EACA;EACA,YAAY,MAAM,OAAO,YAAY,MAAM,UAAU,GAAG,OAAO,MAAM,OAAO,OAAO;EACnF;EACA;EACA,SAAS,eAAe,MAAM,YAAY,KAAK,CAAC,CAAC;EACjD,cAAc,QAAQ;GACpB,eAAe;GACf,eAAe,MAAM,OAAO,cAAc,GAAG,OAAO,GAAG,IAAI,KAAA;EAC7D;CACF;CACA,IAAI;CACJ,qBAAqB,eAAe,CAAC;CACrC,QAAQ,kBAAkB,OAAO;CACjC,OAAO;AACT"}
@@ -0,0 +1,32 @@
1
+ import { cloneJson } from "../core/transaction.js";
2
+ // src/widget/define.ts
3
+ /**
4
+ * Declares a kind of widget. Returns the definition as given, typed; pass
5
+ * it in the dashboard's `widgets` list.
6
+ *
7
+ * ```ts
8
+ * const stat = defineDashboardWidget({
9
+ * type: 'stat',
10
+ * label: '统计数字',
11
+ * size: { w: 3, h: 2, minW: 2 },
12
+ * defaultProps: { value: 0 },
13
+ * component: StatWidget,
14
+ * })
15
+ * ```
16
+ */
17
+ function defineDashboardWidget(type) {
18
+ return type;
19
+ }
20
+ var DEFAULT_WIDGET_SIZE = {
21
+ w: 4,
22
+ h: 3
23
+ };
24
+ /** A copy of a type's default props for a new widget. */
25
+ function defaultPropsOf(type) {
26
+ const value = type?.defaultProps;
27
+ const props = typeof value === "function" ? value() : value;
28
+ return props ? cloneJson(props) : void 0;
29
+ }
30
+ export { DEFAULT_WIDGET_SIZE, defaultPropsOf, defineDashboardWidget };
31
+
32
+ //# sourceMappingURL=define.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define.js","names":[],"sources":["../../src/widget/define.ts"],"sourcesContent":["import { cloneJson } from '../core/transaction'\nimport type { Component } from 'vue'\n\n/** A new widget's size, and the limits a resize keeps to, in columns and rows. */\nexport interface DashboardWidgetSize {\n w: number\n h: number\n minW?: number\n maxW?: number\n minH?: number\n maxH?: number\n}\n\n/** A kind of widget a dashboard can hold, made with `defineDashboardWidget`. */\nexport interface DashboardWidgetType<P extends object = Record<string, unknown>> {\n /** Stored in each widget's `type`. */\n type: string\n /** Its name in the list of widgets to add, and the title of a widget without one. */\n label: string\n /** Shown next to the label in the list of widgets to add. */\n icon?: Component\n /** The size a new widget gets, and its limits. Defaults to 4 × 3. */\n size?: DashboardWidgetSize\n /** The `props` a new widget starts with. */\n defaultProps?: P | (() => P)\n /** Draws the widget; it reads its settings and size with `useDashboardWidget()`. */\n component: Component\n /**\n * The settings form, shown in a drawer while editing. Bound with\n * `v-model` to the widget's `props`; it also gets the `widget`.\n */\n settings?: Component\n /** Whether the widget can be viewed full screen. Defaults to `true`. */\n fullscreen?: boolean\n}\n\n/**\n * Declares a kind of widget. Returns the definition as given, typed; pass\n * it in the dashboard's `widgets` list.\n *\n * ```ts\n * const stat = defineDashboardWidget({\n * type: 'stat',\n * label: '统计数字',\n * size: { w: 3, h: 2, minW: 2 },\n * defaultProps: { value: 0 },\n * component: StatWidget,\n * })\n * ```\n */\nexport function defineDashboardWidget<P extends object = Record<string, unknown>>(\n type: DashboardWidgetType<P>,\n): DashboardWidgetType<P> {\n return type\n}\n\nexport const DEFAULT_WIDGET_SIZE: DashboardWidgetSize = { w: 4, h: 3 }\n\n/** A copy of a type's default props for a new widget. */\nexport function defaultPropsOf(type: DashboardWidgetType<any> | undefined) {\n const value = type?.defaultProps\n const props = typeof value === 'function' ? value() : value\n return props ? (cloneJson(props) as Record<string, unknown>) : undefined\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAkDA,SAAgB,sBACd,MACwB;CACxB,OAAO;AACT;AAEA,IAAa,sBAA2C;CAAE,GAAG;CAAG,GAAG;AAAE;;AAGrE,SAAgB,eAAe,MAA4C;CACzE,MAAM,QAAQ,MAAM;CACpB,MAAM,QAAQ,OAAO,UAAU,aAAa,MAAM,IAAI;CACtD,OAAO,QAAS,UAAU,KAAK,IAAgC,KAAA;AACjE"}
@@ -0,0 +1,6 @@
1
+ import field_select_vue_vue_type_script_setup_true_lang_default from "./field-select.vue_vue_type_script_setup_true_lang.js";
2
+ // src/widgets/field-select.vue
3
+ var field_select_default = field_select_vue_vue_type_script_setup_true_lang_default;
4
+ export { field_select_default as default };
5
+
6
+ //# sourceMappingURL=field-select.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field-select.js","names":["_sfc_main"],"sources":["../../src/widgets/field-select.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { DouSelect } from 'dou-ui'\nimport { computed } from 'vue'\nimport SettingsField from './settings-field.vue'\n\ndefineOptions({ name: 'DouDashboardFieldSelect' })\n\nconst model = defineModel<string | string[] | undefined>()\nconst props = defineProps<{\n label: string\n hint?: string\n /** The fields of the data; a value not among them stays selectable. */\n fields: string[]\n multiple?: boolean\n}>()\n\nconst options = computed(() => {\n const list = [...props.fields]\n const current = Array.isArray(model.value) ? model.value : model.value ? [model.value] : []\n for (const field of current) if (!list.includes(field)) list.push(field)\n return list\n})\n</script>\n\n<template>\n <SettingsField :label=\"label\" :hint=\"hint\">\n <DouSelect\n :model-value=\"model ?? (multiple ? [] : null)\"\n :options=\"options\"\n :multiple=\"multiple\"\n :aria-label=\"label\"\n filterable\n creatable\n clearable\n @update:model-value=\"(value) => (model = (value as any) ?? undefined)\"\n />\n </SettingsField>\n</template>\n"],"mappings":""}
@@ -0,0 +1,54 @@
1
+ import settings_field_default from "./settings-field.js";
2
+ import { DouSelect } from "dou-ui";
3
+ import { computed, createBlock, createVNode, defineComponent, mergeModels, openBlock, unref, useModel, withCtx } from "vue";
4
+ // src/widgets/field-select.vue?vue&type=script&setup=true&lang.ts
5
+ var field_select_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent({
6
+ name: "DouDashboardFieldSelect",
7
+ __name: "field-select",
8
+ props: /*@__PURE__*/ mergeModels({
9
+ label: {},
10
+ hint: {},
11
+ fields: {},
12
+ multiple: { type: Boolean }
13
+ }, {
14
+ "modelValue": {},
15
+ "modelModifiers": {}
16
+ }),
17
+ emits: ["update:modelValue"],
18
+ setup(__props) {
19
+ const model = useModel(__props, "modelValue");
20
+ const props = __props;
21
+ const options = computed(() => {
22
+ const list = [...props.fields];
23
+ const current = Array.isArray(model.value) ? model.value : model.value ? [model.value] : [];
24
+ for (const field of current) if (!list.includes(field)) list.push(field);
25
+ return list;
26
+ });
27
+ return (_ctx, _cache) => {
28
+ return openBlock(), createBlock(settings_field_default, {
29
+ label: __props.label,
30
+ hint: __props.hint
31
+ }, {
32
+ default: withCtx(() => [createVNode(unref(DouSelect), {
33
+ "model-value": model.value ?? (__props.multiple ? [] : null),
34
+ options: options.value,
35
+ multiple: __props.multiple,
36
+ "aria-label": __props.label,
37
+ filterable: "",
38
+ creatable: "",
39
+ clearable: "",
40
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = (value) => model.value = value ?? void 0)
41
+ }, null, 8, [
42
+ "model-value",
43
+ "options",
44
+ "multiple",
45
+ "aria-label"
46
+ ])]),
47
+ _: 1
48
+ }, 8, ["label", "hint"]);
49
+ };
50
+ }
51
+ });
52
+ export { field_select_vue_vue_type_script_setup_true_lang_default as default };
53
+
54
+ //# sourceMappingURL=field-select.vue_vue_type_script_setup_true_lang.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field-select.vue_vue_type_script_setup_true_lang.js","names":["_useModel","_openBlock","_createBlock","SettingsField","_withCtx","_createVNode","_unref"],"sources":["../../src/widgets/field-select.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { DouSelect } from 'dou-ui'\nimport { computed } from 'vue'\nimport SettingsField from './settings-field.vue'\n\ndefineOptions({ name: 'DouDashboardFieldSelect' })\n\nconst model = defineModel<string | string[] | undefined>()\nconst props = defineProps<{\n label: string\n hint?: string\n /** The fields of the data; a value not among them stays selectable. */\n fields: string[]\n multiple?: boolean\n}>()\n\nconst options = computed(() => {\n const list = [...props.fields]\n const current = Array.isArray(model.value) ? model.value : model.value ? [model.value] : []\n for (const field of current) if (!list.includes(field)) list.push(field)\n return list\n})\n</script>\n\n<template>\n <SettingsField :label=\"label\" :hint=\"hint\">\n <DouSelect\n :model-value=\"model ?? (multiple ? [] : null)\"\n :options=\"options\"\n :multiple=\"multiple\"\n :aria-label=\"label\"\n filterable\n creatable\n clearable\n @update:model-value=\"(value) => (model = (value as any) ?? undefined)\"\n />\n </SettingsField>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;EAOA,MAAM,QAAQA,SAA0C,SAAA,YAAC;EACzD,MAAM,QAAQ;EAQd,MAAM,UAAU,eAAe;GAC7B,MAAM,OAAO,CAAC,GAAG,MAAM,MAAM;GAC7B,MAAM,UAAU,MAAM,QAAQ,MAAM,KAAK,IAAI,MAAM,QAAQ,MAAM,QAAQ,CAAC,MAAM,KAAK,IAAI,CAAC;GAC1F,KAAK,MAAM,SAAS,SAAS,IAAI,CAAC,KAAK,SAAS,KAAK,GAAG,KAAK,KAAK,KAAK;GACvE,OAAO;EACT,CAAC;;GAIC,OAAAC,UAAA,GAAAC,YAWgBC,wBAAA;IAXA,OAAO,QAAA;IAAQ,MAAM,QAAA;;IACnC,SAAAC,cASE,CATFC,YASEC,MAAA,SAAA,GAAA;KARC,eAAa,MAAA,UAAU,QAAA,WAAQ,CAAA,IAAA;KAC/B,SAAS,QAAA;KACT,UAAU,QAAA;KACV,cAAY,QAAA;KACb,YAAA;KACA,WAAA;KACA,WAAA;KACC,uBAAkB,OAAA,OAAA,OAAA,MAAG,UAAW,MAAA,QAAS,SAAiB,KAAA"}
@@ -0,0 +1,74 @@
1
+ import { defineDashboardWidget } from "../widget/define.js";
2
+ import { fieldsOf, filterValueOf, numberFieldsOf, rowsOf, valueAt } from "./shared.js";
3
+ import stat_default from "./stat.js";
4
+ import stat_settings_default from "./stat-settings.js";
5
+ import table_default from "./table.js";
6
+ import table_settings_default from "./table-settings.js";
7
+ import text_default from "./text.js";
8
+ import text_settings_default from "./text-settings.js";
9
+ import { HashIcon, TableIcon, TypeIcon } from "@dou-ui/icons";
10
+ // src/widgets/index.ts
11
+ /**
12
+ * A number, read from a source or given, with its change since the last
13
+ * period and a sparkline under it.
14
+ */
15
+ function statWidget(overrides = {}) {
16
+ return defineDashboardWidget({
17
+ type: "stat",
18
+ label: "统计数字",
19
+ icon: HashIcon,
20
+ size: {
21
+ w: 3,
22
+ h: 2,
23
+ minW: 2,
24
+ minH: 2
25
+ },
26
+ defaultProps: { value: 0 },
27
+ component: stat_default,
28
+ settings: stat_settings_default,
29
+ fullscreen: false,
30
+ ...overrides
31
+ });
32
+ }
33
+ /** A note: plain text in three sizes, its line breaks kept. */
34
+ function textWidget(overrides = {}) {
35
+ return defineDashboardWidget({
36
+ type: "text",
37
+ label: "文字",
38
+ icon: TypeIcon,
39
+ size: {
40
+ w: 4,
41
+ h: 2,
42
+ minW: 2,
43
+ minH: 1
44
+ },
45
+ defaultProps: {
46
+ text: "",
47
+ size: "md"
48
+ },
49
+ component: text_default,
50
+ settings: text_settings_default,
51
+ fullscreen: false,
52
+ ...overrides
53
+ });
54
+ }
55
+ /** A source's rows in a table, with the columns picked in its settings. */
56
+ function tableWidget(overrides = {}) {
57
+ return defineDashboardWidget({
58
+ type: "table",
59
+ label: "表格",
60
+ icon: TableIcon,
61
+ size: {
62
+ w: 6,
63
+ h: 4,
64
+ minW: 3,
65
+ minH: 3
66
+ },
67
+ component: table_default,
68
+ settings: table_settings_default,
69
+ ...overrides
70
+ });
71
+ }
72
+ export { fieldsOf, filterValueOf, numberFieldsOf, rowsOf, statWidget, tableWidget, textWidget, valueAt };
73
+
74
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["Stat","StatSettings","Text","TextSettings","Table","TableSettings"],"sources":["../../src/widgets/index.ts"],"sourcesContent":["import { HashIcon, TableIcon, TypeIcon } from '@dou-ui/icons'\nimport { defineDashboardWidget } from '../widget/define'\nimport type { DashboardWidgetType } from '../widget/define'\nimport Stat from './stat.vue'\nimport StatSettings from './stat-settings.vue'\nimport Table from './table.vue'\nimport TableSettings from './table-settings.vue'\nimport Text from './text.vue'\nimport TextSettings from './text-settings.vue'\nimport type { StatWidgetProps, TableWidgetProps, TextWidgetProps } from './types'\n\nexport type { StatWidgetProps, TableWidgetColumn, TableWidgetProps, TextWidgetProps } from './types'\nexport { fieldsOf, filterValueOf, numberFieldsOf, rowsOf, valueAt } from './shared'\n\n/** What a built-in widget's definition can change: its type, label, icon, size and more. */\nexport type WidgetOverrides<P extends object> = Partial<Omit<DashboardWidgetType<P>, 'component'>>\n\n/**\n * A number, read from a source or given, with its change since the last\n * period and a sparkline under it.\n */\nexport function statWidget(overrides: WidgetOverrides<StatWidgetProps> = {}) {\n return defineDashboardWidget<StatWidgetProps>({\n type: 'stat',\n label: '统计数字',\n icon: HashIcon,\n size: { w: 3, h: 2, minW: 2, minH: 2 },\n defaultProps: { value: 0 },\n component: Stat,\n settings: StatSettings,\n fullscreen: false,\n ...overrides,\n })\n}\n\n/** A note: plain text in three sizes, its line breaks kept. */\nexport function textWidget(overrides: WidgetOverrides<TextWidgetProps> = {}) {\n return defineDashboardWidget<TextWidgetProps>({\n type: 'text',\n label: '文字',\n icon: TypeIcon,\n size: { w: 4, h: 2, minW: 2, minH: 1 },\n defaultProps: { text: '', size: 'md' },\n component: Text,\n settings: TextSettings,\n fullscreen: false,\n ...overrides,\n })\n}\n\n/** A source's rows in a table, with the columns picked in its settings. */\nexport function tableWidget(overrides: WidgetOverrides<TableWidgetProps> = {}) {\n return defineDashboardWidget<TableWidgetProps>({\n type: 'table',\n label: '表格',\n icon: TableIcon,\n size: { w: 6, h: 4, minW: 3, minH: 3 },\n component: Table,\n settings: TableSettings,\n ...overrides,\n })\n}\n"],"mappings":";;;;;;;;;;;;;;AAqBA,SAAgB,WAAW,YAA8C,CAAC,GAAG;CAC3E,OAAO,sBAAuC;EAC5C,MAAM;EACN,OAAO;EACP,MAAM;EACN,MAAM;GAAE,GAAG;GAAG,GAAG;GAAG,MAAM;GAAG,MAAM;EAAE;EACrC,cAAc,EAAE,OAAO,EAAE;EACzB,WAAWA;EACX,UAAUC;EACV,YAAY;EACZ,GAAG;CACL,CAAC;AACH;;AAGA,SAAgB,WAAW,YAA8C,CAAC,GAAG;CAC3E,OAAO,sBAAuC;EAC5C,MAAM;EACN,OAAO;EACP,MAAM;EACN,MAAM;GAAE,GAAG;GAAG,GAAG;GAAG,MAAM;GAAG,MAAM;EAAE;EACrC,cAAc;GAAE,MAAM;GAAI,MAAM;EAAK;EACrC,WAAWC;EACX,UAAUC;EACV,YAAY;EACZ,GAAG;CACL,CAAC;AACH;;AAGA,SAAgB,YAAY,YAA+C,CAAC,GAAG;CAC7E,OAAO,sBAAwC;EAC7C,MAAM;EACN,OAAO;EACP,MAAM;EACN,MAAM;GAAE,GAAG;GAAG,GAAG;GAAG,MAAM;GAAG,MAAM;EAAE;EACrC,WAAWC;EACX,UAAUC;EACV,GAAG;CACL,CAAC;AACH"}
@@ -0,0 +1,6 @@
1
+ import settings_field_vue_vue_type_script_setup_true_lang_default from "./settings-field.vue_vue_type_script_setup_true_lang.js";
2
+ // src/widgets/settings-field.vue
3
+ var settings_field_default = settings_field_vue_vue_type_script_setup_true_lang_default;
4
+ export { settings_field_default as default };
5
+
6
+ //# sourceMappingURL=settings-field.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settings-field.js","names":["_sfc_main"],"sources":["../../src/widgets/settings-field.vue"],"sourcesContent":["<script setup lang=\"ts\">\ndefineOptions({ name: 'DouDashboardSettingsField' })\n\ndefineProps<{ label: string; hint?: string }>()\n</script>\n\n<template>\n <div class=\"dou-dashboard__field\">\n <span class=\"dou-dashboard__field-label\">{{ label }}</span>\n <slot />\n <span v-if=\"hint\" class=\"dou-dashboard__field-hint\">{{ hint }}</span>\n </div>\n</template>\n"],"mappings":""}
@@ -0,0 +1,28 @@
1
+ import { createCommentVNode, createElementBlock, createElementVNode, defineComponent, openBlock, renderSlot, toDisplayString } from "vue";
2
+ // src/widgets/settings-field.vue?vue&type=script&setup=true&lang.ts
3
+ var _hoisted_1 = { class: "dou-dashboard__field" };
4
+ var _hoisted_2 = { class: "dou-dashboard__field-label" };
5
+ var _hoisted_3 = {
6
+ key: 0,
7
+ class: "dou-dashboard__field-hint"
8
+ };
9
+ var settings_field_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent({
10
+ name: "DouDashboardSettingsField",
11
+ __name: "settings-field",
12
+ props: {
13
+ label: {},
14
+ hint: {}
15
+ },
16
+ setup(__props) {
17
+ return (_ctx, _cache) => {
18
+ return openBlock(), createElementBlock("div", _hoisted_1, [
19
+ createElementVNode("span", _hoisted_2, toDisplayString(__props.label), 1),
20
+ renderSlot(_ctx.$slots, "default"),
21
+ __props.hint ? (openBlock(), createElementBlock("span", _hoisted_3, toDisplayString(__props.hint), 1)) : createCommentVNode("", true)
22
+ ]);
23
+ };
24
+ }
25
+ });
26
+ export { settings_field_vue_vue_type_script_setup_true_lang_default as default };
27
+
28
+ //# sourceMappingURL=settings-field.vue_vue_type_script_setup_true_lang.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settings-field.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createElementBlock","_createElementVNode","_toDisplayString","_renderSlot","_createCommentVNode"],"sources":["../../src/widgets/settings-field.vue"],"sourcesContent":["<script setup lang=\"ts\">\ndefineOptions({ name: 'DouDashboardSettingsField' })\n\ndefineProps<{ label: string; hint?: string }>()\n</script>\n\n<template>\n <div class=\"dou-dashboard__field\">\n <span class=\"dou-dashboard__field-label\">{{ label }}</span>\n <slot />\n <span v-if=\"hint\" class=\"dou-dashboard__field-hint\">{{ hint }}</span>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;GAOE,OAAAA,UAAA,GAAAC,mBAIM,OAJN,YAIM;IAHJC,mBAA2D,QAA3D,YAA2DC,gBAAf,QAAA,KAAK,GAAA,CAAA;IACjDC,WAAQ,KAAA,QAAA,SAAA;IACI,QAAA,QAAZJ,UAAA,GAAAC,mBAAqE,QAArE,YAAqEE,gBAAd,QAAA,IAAI,GAAA,CAAA,K"}