vira 28.19.6 → 28.20.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.
- package/dist/elements/define-vira-element.d.ts +18 -0
- package/dist/elements/define-vira-element.js +19 -0
- package/dist/elements/form/vira-form-fields.d.ts +100 -0
- package/dist/elements/form/vira-form-fields.js +60 -0
- package/dist/elements/form/vira-form.element.d.ts +35 -0
- package/dist/elements/form/vira-form.element.js +151 -0
- package/dist/elements/index.js +25 -0
- package/dist/elements/pop-up/pop-up-helpers.d.ts +33 -0
- package/dist/elements/pop-up/pop-up-helpers.js +58 -0
- package/{src/elements/pop-up/pop-up-menu-item.ts → dist/elements/pop-up/pop-up-menu-item.d.ts} +3 -4
- package/dist/elements/pop-up/pop-up-menu-item.js +1 -0
- package/dist/elements/pop-up/vira-menu-item.element.d.ts +19 -0
- package/{src/elements/pop-up/vira-menu-item.element.ts → dist/elements/pop-up/vira-menu-item.element.js} +11 -28
- package/dist/elements/pop-up/vira-menu-trigger.element.d.ts +41 -0
- package/dist/elements/pop-up/vira-menu-trigger.element.js +121 -0
- package/dist/elements/pop-up/vira-menu.element.d.ts +38 -0
- package/{src/elements/pop-up/vira-menu.element.ts → dist/elements/pop-up/vira-menu.element.js} +49 -76
- package/dist/elements/pop-up/vira-pop-up-menu.element.d.ts +35 -0
- package/{src/elements/pop-up/vira-pop-up-menu.element.ts → dist/elements/pop-up/vira-pop-up-menu.element.js} +22 -34
- package/dist/elements/pop-up/vira-pop-up-trigger.element.d.ts +105 -0
- package/{src/elements/pop-up/vira-pop-up-trigger.element.ts → dist/elements/pop-up/vira-pop-up-trigger.element.js} +104 -199
- package/dist/elements/shared-text-input-logic.d.ts +63 -0
- package/dist/elements/shared-text-input-logic.js +101 -0
- package/dist/elements/vira-bold-text.element.d.ts +9 -0
- package/{src/elements/vira-bold-text.element.ts → dist/elements/vira-bold-text.element.js} +7 -8
- package/dist/elements/vira-button.element.d.ts +31 -0
- package/{src/elements/vira-button.element.ts → dist/elements/vira-button.element.js} +35 -66
- package/dist/elements/vira-card.element.d.ts +18 -0
- package/{src/elements/vira-card.element.ts → dist/elements/vira-card.element.js} +13 -16
- package/dist/elements/vira-checkbox.element.d.ts +34 -0
- package/{src/elements/vira-checkbox.element.ts → dist/elements/vira-checkbox.element.js} +28 -71
- package/dist/elements/vira-collapsible-wrapper.element.d.ts +16 -0
- package/{src/elements/vira-collapsible-wrapper.element.ts → dist/elements/vira-collapsible-wrapper.element.js} +26 -18
- package/dist/elements/vira-dropdown.element.d.ts +46 -0
- package/{src/elements/vira-dropdown.element.ts → dist/elements/vira-dropdown.element.js} +48 -94
- package/dist/elements/vira-error.element.d.ts +7 -0
- package/{src/elements/vira-error.element.ts → dist/elements/vira-error.element.js} +5 -6
- package/dist/elements/vira-icon.element.d.ts +13 -0
- package/{src/elements/vira-icon.element.ts → dist/elements/vira-icon.element.js} +6 -13
- package/dist/elements/vira-image.element.d.ts +45 -0
- package/{src/elements/vira-image.element.ts → dist/elements/vira-image.element.js} +43 -63
- package/dist/elements/vira-input.element.d.ts +62 -0
- package/{src/elements/vira-input.element.ts → dist/elements/vira-input.element.js} +85 -151
- package/dist/elements/vira-link.element.d.ts +73 -0
- package/{src/elements/vira-link.element.ts → dist/elements/vira-link.element.js} +11 -62
- package/dist/elements/vira-modal.element.d.ts +39 -0
- package/{src/elements/vira-modal.element.ts → dist/elements/vira-modal.element.js} +50 -89
- package/dist/elements/vira-overflow-switch.element.d.ts +21 -0
- package/dist/elements/vira-overflow-switch.element.js +110 -0
- package/dist/elements/vira-progress.element.d.ts +18 -0
- package/{src/elements/vira-progress.element.ts → dist/elements/vira-progress.element.js} +11 -26
- package/dist/elements/vira-select.element.d.ts +48 -0
- package/{src/elements/vira-select.element.ts → dist/elements/vira-select.element.js} +41 -96
- package/dist/icons/icon-color.test-helper.d.ts +6 -0
- package/dist/icons/icon-color.test-helper.js +9 -0
- package/dist/icons/icon-css-vars.d.ts +14 -0
- package/{src/icons/icon-css-vars.ts → dist/icons/icon-css-vars.js} +1 -2
- package/dist/icons/icon-svg.d.ts +27 -0
- package/dist/icons/icon-svg.js +48 -0
- package/dist/icons/icon-svgs/bell-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/bell-24.icon.ts → dist/icons/icon-svgs/bell-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/chat-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/chat-24.icon.ts → dist/icons/icon-svgs/chat-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/check-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/check-24.icon.ts → dist/icons/icon-svgs/check-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/chevron-down-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/chevron-down-24.icon.ts → dist/icons/icon-svgs/chevron-down-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/chevron-up-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/chevron-up-24.icon.ts → dist/icons/icon-svgs/chevron-up-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/close-x-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/close-x-24.icon.ts → dist/icons/icon-svgs/close-x-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/commit-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/commit-24.icon.ts → dist/icons/icon-svgs/commit-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/copy-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/copy-24.icon.ts → dist/icons/icon-svgs/copy-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/document-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/document-24.icon.ts → dist/icons/icon-svgs/document-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/document-search-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/document-search-24.icon.ts → dist/icons/icon-svgs/document-search-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/double-chevron-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/double-chevron-24.icon.ts → dist/icons/icon-svgs/double-chevron-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/element-16.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/element-16.icon.ts → dist/icons/icon-svgs/element-16.icon.js} +4 -5
- package/dist/icons/icon-svgs/element-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/element-24.icon.ts → dist/icons/icon-svgs/element-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/external-link-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/external-link-24.icon.ts → dist/icons/icon-svgs/external-link-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/eye-closed-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/eye-closed-24.icon.ts → dist/icons/icon-svgs/eye-closed-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/eye-open-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/eye-open-24.icon.ts → dist/icons/icon-svgs/eye-open-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/filter-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/filter-24.icon.ts → dist/icons/icon-svgs/filter-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/link-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/link-24.icon.ts → dist/icons/icon-svgs/link-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/loader-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/loader-24.icon.ts → dist/icons/icon-svgs/loader-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/loader-animated-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/loader-animated-24.icon.ts → dist/icons/icon-svgs/loader-animated-24.icon.js} +6 -8
- package/dist/icons/icon-svgs/lock-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/lock-24.icon.ts → dist/icons/icon-svgs/lock-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/options-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/options-24.icon.ts → dist/icons/icon-svgs/options-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/pencil-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/pencil-24.icon.ts → dist/icons/icon-svgs/pencil-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/shield-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/shield-24.icon.ts → dist/icons/icon-svgs/shield-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/sort-ascending-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/sort-ascending-24.icon.ts → dist/icons/icon-svgs/sort-ascending-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/sort-descending-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/sort-descending-24.icon.ts → dist/icons/icon-svgs/sort-descending-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/speaker-loud-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/speaker-loud-24.icon.ts → dist/icons/icon-svgs/speaker-loud-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/speaker-medium-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/speaker-medium-24.icon.ts → dist/icons/icon-svgs/speaker-medium-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/speaker-muted-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/speaker-muted-24.icon.ts → dist/icons/icon-svgs/speaker-muted-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/speaker-quiet-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/speaker-quiet-24.icon.ts → dist/icons/icon-svgs/speaker-quiet-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/star-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/star-24.icon.ts → dist/icons/icon-svgs/star-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/status-failure-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/status-failure-24.icon.ts → dist/icons/icon-svgs/status-failure-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/status-in-progress-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/status-in-progress-24.icon.ts → dist/icons/icon-svgs/status-in-progress-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/status-success-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/status-success-24.icon.ts → dist/icons/icon-svgs/status-success-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/status-unknown-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/status-unknown-24.icon.ts → dist/icons/icon-svgs/status-unknown-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/status-warning-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/status-warning-24.icon.ts → dist/icons/icon-svgs/status-warning-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/upload-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/upload-24.icon.ts → dist/icons/icon-svgs/upload-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/x-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/x-24.icon.ts → dist/icons/icon-svgs/x-24.icon.js} +4 -5
- package/dist/icons/index.d.ts +86 -0
- package/{src/icons/index.ts → dist/icons/index.js} +39 -43
- package/dist/index.js +4 -0
- package/dist/styles/border.d.ts +9 -0
- package/{src/styles/border.ts → dist/styles/border.js} +1 -2
- package/dist/styles/disabled.d.ts +6 -0
- package/{src/styles/disabled.ts → dist/styles/disabled.js} +2 -3
- package/dist/styles/durations.d.ts +22 -0
- package/{src/styles/durations.ts → dist/styles/durations.js} +1 -2
- package/dist/styles/focus.d.ts +34 -0
- package/{src/styles/focus.ts → dist/styles/focus.js} +8 -29
- package/dist/styles/font.d.ts +9 -0
- package/{src/styles/font.ts → dist/styles/font.js} +1 -2
- package/dist/styles/form-styles.d.ts +20 -0
- package/{src/styles/form-styles.ts → dist/styles/form-styles.js} +1 -6
- package/{src/styles/index.ts → dist/styles/index.d.ts} +0 -1
- package/dist/styles/index.js +13 -0
- package/dist/styles/native-styles.d.ts +13 -0
- package/{src/styles/native-styles.ts → dist/styles/native-styles.js} +3 -5
- package/dist/styles/scrollbar.d.ts +6 -0
- package/{src/styles/scrollbar.ts → dist/styles/scrollbar.js} +3 -4
- package/dist/styles/shadows.d.ts +20 -0
- package/{src/styles/shadows.ts → dist/styles/shadows.js} +6 -8
- package/dist/styles/user-select.d.ts +6 -0
- package/{src/styles/user-select.ts → dist/styles/user-select.js} +2 -3
- package/dist/styles/vira-color-palette.d.ts +95 -0
- package/{src/styles/vira-color-palette.ts → dist/styles/vira-color-palette.js} +1 -11
- package/dist/styles/vira-color-theme.d.ts +1184 -0
- package/dist/styles/vira-color-theme.js +1138 -0
- package/dist/util/define-table.d.ts +110 -0
- package/dist/util/define-table.js +115 -0
- package/dist/util/dynamic-element.d.ts +63 -0
- package/dist/util/dynamic-element.js +61 -0
- package/dist/util/index.js +3 -0
- package/dist/util/pop-up-manager.d.ts +186 -0
- package/dist/util/pop-up-manager.js +214 -0
- package/package.json +6 -6
- package/src/elements/define-vira-element.ts +0 -29
- package/src/elements/form/vira-form-fields.ts +0 -140
- package/src/elements/form/vira-form.element.ts +0 -204
- package/src/elements/pop-up/pop-up-helpers.ts +0 -85
- package/src/elements/pop-up/vira-menu-trigger.element.ts +0 -158
- package/src/elements/shared-text-input-logic.ts +0 -173
- package/src/elements/vira-overflow-switch.element.ts +0 -137
- package/src/icons/icon-color.test-helper.ts +0 -9
- package/src/icons/icon-svg.ts +0 -71
- package/src/styles/vira-color-theme.ts +0 -1142
- package/src/util/define-table.ts +0 -279
- package/src/util/dynamic-element.ts +0 -129
- package/src/util/pop-up-manager.ts +0 -380
- /package/{src/elements/index.ts → dist/elements/index.d.ts} +0 -0
- /package/{src/index.ts → dist/index.d.ts} +0 -0
- /package/{src/util/index.ts → dist/util/index.d.ts} +0 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { type ArrayElement, type PartialWithUndefined } from '@augment-vir/common';
|
|
2
|
+
import { type HtmlInterpolation } from 'element-vir';
|
|
3
|
+
/**
|
|
4
|
+
* An individual key definition in {@link ViraTableHeaders}.
|
|
5
|
+
*
|
|
6
|
+
* @category Internal
|
|
7
|
+
*/
|
|
8
|
+
export type ViraTableKey = Readonly<{
|
|
9
|
+
/** The key that cells must set a value to. */
|
|
10
|
+
key: string | number;
|
|
11
|
+
} & PartialWithUndefined<{
|
|
12
|
+
/** If this is not provided, `key` will be used directly. */
|
|
13
|
+
content: HtmlInterpolation;
|
|
14
|
+
/** If set to `true`, this header (and it's column) won't be rendered. */
|
|
15
|
+
disabled: boolean;
|
|
16
|
+
}>>;
|
|
17
|
+
/**
|
|
18
|
+
* All header definitions for a {@link ViraTable} instance.
|
|
19
|
+
*
|
|
20
|
+
* @category Internal
|
|
21
|
+
*/
|
|
22
|
+
export type ViraTableHeaders = ReadonlyArray<ViraTableKey>;
|
|
23
|
+
/**
|
|
24
|
+
* An individual entry in {@link ViraTable}. In default table orientation, this will be a row. In
|
|
25
|
+
* horizontal orientation, this will be a column.
|
|
26
|
+
*
|
|
27
|
+
* @category Internal
|
|
28
|
+
*/
|
|
29
|
+
export type ViraTableEntry<Headers extends ViraTableHeaders | undefined = undefined> = Record<HeaderKey<Headers>, HtmlInterpolation>;
|
|
30
|
+
/**
|
|
31
|
+
* An individual cell in {@link ViraTableRow}.
|
|
32
|
+
*
|
|
33
|
+
* @category Internal
|
|
34
|
+
*/
|
|
35
|
+
export type ViraTableCell<Headers extends ViraTableHeaders | undefined = undefined, CellData = any> = {
|
|
36
|
+
content: HtmlInterpolation;
|
|
37
|
+
key: HeaderKey<Headers>;
|
|
38
|
+
/**
|
|
39
|
+
* The original entry that created this row (in default or vertical table orientation) or column
|
|
40
|
+
* (in horizontal table orientation). This is `undefined` in header cells.
|
|
41
|
+
*/
|
|
42
|
+
data: CellData;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* An individual row in {@link ViraTable}.
|
|
46
|
+
*
|
|
47
|
+
* @category Internal
|
|
48
|
+
*/
|
|
49
|
+
export type ViraTableRow<Headers extends ViraTableHeaders | undefined = undefined, CellData = any, RowData = CellData> = {
|
|
50
|
+
cells: ViraTableCell<Headers, CellData>[];
|
|
51
|
+
data: RowData;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* All keys for the given headers.
|
|
55
|
+
*
|
|
56
|
+
* @category Internal
|
|
57
|
+
*/
|
|
58
|
+
export type HeaderKey<Headers extends ViraTableHeaders | undefined = undefined> = undefined extends Headers ? string | number : ArrayElement<Exclude<Headers, undefined>>['key'];
|
|
59
|
+
/**
|
|
60
|
+
* Table information that can easily be mapped into a `<table>` element.
|
|
61
|
+
*
|
|
62
|
+
* @category Internal
|
|
63
|
+
*/
|
|
64
|
+
export type ViraTable<Headers extends ViraTableHeaders | undefined = undefined, Orientation extends ViraTableOrientation = ViraTableOrientation.Vertical, OriginalData extends ReadonlyArray<any> = any[]> = Orientation extends ViraTableOrientation.Horizontal ? {
|
|
65
|
+
headerRow: undefined;
|
|
66
|
+
orientation: Orientation;
|
|
67
|
+
rows: ViraTableRow<Headers, ArrayElement<OriginalData> | undefined, undefined>[];
|
|
68
|
+
} : {
|
|
69
|
+
headerRow: ViraTableCell<Headers, undefined>[];
|
|
70
|
+
orientation: Orientation;
|
|
71
|
+
rows: ViraTableRow<Headers, ArrayElement<OriginalData>>[];
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Orientation options for {@link ViraTable}.
|
|
75
|
+
*
|
|
76
|
+
* @category Internal
|
|
77
|
+
*/
|
|
78
|
+
export declare enum ViraTableOrientation {
|
|
79
|
+
/**
|
|
80
|
+
* This corresponds to a _vertical_ entry sequence (as you move from entry to entry, you move
|
|
81
|
+
* across the table vertically). This is the default table layout. Each entry becomes a new row.
|
|
82
|
+
* Headers are in a separate row.
|
|
83
|
+
*/
|
|
84
|
+
Vertical = "vertical",
|
|
85
|
+
/**
|
|
86
|
+
* This corresponds to a _horizontal_ entry sequence (as you move from entry to entry, you move
|
|
87
|
+
* across the table horizontally). Each entry becomes a column. Headers are the left most
|
|
88
|
+
* column.
|
|
89
|
+
*/
|
|
90
|
+
Horizontal = "horizontal"
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Options for {@link defineTable}.
|
|
94
|
+
*
|
|
95
|
+
* @category Internal
|
|
96
|
+
*/
|
|
97
|
+
export type ViraTableOptions<Orientation extends ViraTableOrientation = ViraTableOrientation> = PartialWithUndefined<{
|
|
98
|
+
orientation: Orientation;
|
|
99
|
+
hideHeaders: boolean;
|
|
100
|
+
}>;
|
|
101
|
+
/**
|
|
102
|
+
* Accepts headers and entries and lays them out into rows according to the given
|
|
103
|
+
* `options.orientation` (defaulting to vertical). This does not itself create a `<table>` element,
|
|
104
|
+
* but makes it easy to loop over rows to (with `.map()`) to generate rows in a table.
|
|
105
|
+
*
|
|
106
|
+
* @category Table
|
|
107
|
+
*/
|
|
108
|
+
export declare function defineTable<const Headers extends ViraTableHeaders, OriginalData extends ReadonlyArray<any>, const Orientation extends ViraTableOrientation = ViraTableOrientation.Vertical>(
|
|
109
|
+
/** The order of these keys determines the order that they render in. */
|
|
110
|
+
headers: Readonly<Headers>, originalData: OriginalData, dataMap: (entry: ArrayElement<OriginalData>, entryIndex: number) => ViraTableEntry<Headers> | undefined, options?: ViraTableOptions<Orientation>): ViraTable<Headers, Orientation, OriginalData>;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { check } from '@augment-vir/assert';
|
|
2
|
+
import { filterMap } from '@augment-vir/common';
|
|
3
|
+
/**
|
|
4
|
+
* Orientation options for {@link ViraTable}.
|
|
5
|
+
*
|
|
6
|
+
* @category Internal
|
|
7
|
+
*/
|
|
8
|
+
export var ViraTableOrientation;
|
|
9
|
+
(function (ViraTableOrientation) {
|
|
10
|
+
/**
|
|
11
|
+
* This corresponds to a _vertical_ entry sequence (as you move from entry to entry, you move
|
|
12
|
+
* across the table vertically). This is the default table layout. Each entry becomes a new row.
|
|
13
|
+
* Headers are in a separate row.
|
|
14
|
+
*/
|
|
15
|
+
ViraTableOrientation["Vertical"] = "vertical";
|
|
16
|
+
/**
|
|
17
|
+
* This corresponds to a _horizontal_ entry sequence (as you move from entry to entry, you move
|
|
18
|
+
* across the table horizontally). Each entry becomes a column. Headers are the left most
|
|
19
|
+
* column.
|
|
20
|
+
*/
|
|
21
|
+
ViraTableOrientation["Horizontal"] = "horizontal";
|
|
22
|
+
})(ViraTableOrientation || (ViraTableOrientation = {}));
|
|
23
|
+
/**
|
|
24
|
+
* Accepts headers and entries and lays them out into rows according to the given
|
|
25
|
+
* `options.orientation` (defaulting to vertical). This does not itself create a `<table>` element,
|
|
26
|
+
* but makes it easy to loop over rows to (with `.map()`) to generate rows in a table.
|
|
27
|
+
*
|
|
28
|
+
* @category Table
|
|
29
|
+
*/
|
|
30
|
+
export function defineTable(
|
|
31
|
+
/** The order of these keys determines the order that they render in. */
|
|
32
|
+
headers, originalData, dataMap, options = {}) {
|
|
33
|
+
const mappedData = originalData.map((dataRow, rowIndex) => {
|
|
34
|
+
return {
|
|
35
|
+
cells: dataMap(dataRow, rowIndex),
|
|
36
|
+
data: dataRow,
|
|
37
|
+
};
|
|
38
|
+
});
|
|
39
|
+
if (options.orientation === ViraTableOrientation.Horizontal) {
|
|
40
|
+
const rows = filterMap(headers, (header) => {
|
|
41
|
+
if (header.disabled) {
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
const headerCellArray = options.hideHeaders
|
|
45
|
+
? []
|
|
46
|
+
: [
|
|
47
|
+
{
|
|
48
|
+
content: header.content ?? header.key,
|
|
49
|
+
key: header.key,
|
|
50
|
+
data: undefined,
|
|
51
|
+
},
|
|
52
|
+
];
|
|
53
|
+
const cells = filterMap(mappedData, ({ data, cells, }) => {
|
|
54
|
+
if (!cells) {
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
content: cells[header.key],
|
|
59
|
+
key: header.key,
|
|
60
|
+
data,
|
|
61
|
+
};
|
|
62
|
+
}, check.isTruthy);
|
|
63
|
+
const allCells = [
|
|
64
|
+
...headerCellArray,
|
|
65
|
+
...cells,
|
|
66
|
+
];
|
|
67
|
+
return {
|
|
68
|
+
cells: allCells,
|
|
69
|
+
data: undefined,
|
|
70
|
+
};
|
|
71
|
+
}, check.isTruthy);
|
|
72
|
+
return {
|
|
73
|
+
headerRow: undefined,
|
|
74
|
+
rows,
|
|
75
|
+
orientation: ViraTableOrientation.Horizontal,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
const headerRow = options.hideHeaders
|
|
80
|
+
? []
|
|
81
|
+
: filterMap(headers, (header) => {
|
|
82
|
+
if (header.disabled) {
|
|
83
|
+
return undefined;
|
|
84
|
+
}
|
|
85
|
+
return {
|
|
86
|
+
content: header.content ?? header.key,
|
|
87
|
+
key: header.key,
|
|
88
|
+
data: undefined,
|
|
89
|
+
};
|
|
90
|
+
}, check.isTruthy);
|
|
91
|
+
const rows = filterMap(mappedData, ({ cells, data }) => {
|
|
92
|
+
if (!cells) {
|
|
93
|
+
return undefined;
|
|
94
|
+
}
|
|
95
|
+
return {
|
|
96
|
+
cells: filterMap(headers, (header) => {
|
|
97
|
+
if (header.disabled) {
|
|
98
|
+
return undefined;
|
|
99
|
+
}
|
|
100
|
+
return {
|
|
101
|
+
content: cells[header.key],
|
|
102
|
+
key: header.key,
|
|
103
|
+
data,
|
|
104
|
+
};
|
|
105
|
+
}, check.isTruthy),
|
|
106
|
+
data,
|
|
107
|
+
};
|
|
108
|
+
}, check.isTruthy);
|
|
109
|
+
return {
|
|
110
|
+
headerRow,
|
|
111
|
+
rows,
|
|
112
|
+
orientation: ViraTableOrientation.Vertical,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { type Values } from '@augment-vir/common';
|
|
2
|
+
import { type AsyncProp, type DeclarativeElementDefinition } from 'element-vir';
|
|
3
|
+
import { type RequireExactlyOne } from 'type-fest';
|
|
4
|
+
/**
|
|
5
|
+
* Base type for loaders passed to {@link createDynamicElementLoader}.
|
|
6
|
+
*
|
|
7
|
+
* @category Internal
|
|
8
|
+
*/
|
|
9
|
+
export type BaseDynamicElementLoaders = Record<string, () => Promise<DeclarativeElementDefinition>>;
|
|
10
|
+
/**
|
|
11
|
+
* Create a dynamic element loader. This should go in your element state. This makes deferring
|
|
12
|
+
* element importing convenient and allows parts of your app to be placed in separate bundles. Make
|
|
13
|
+
* sure to also use {@link renderDynamicElement} to use the output of this loader.
|
|
14
|
+
*
|
|
15
|
+
* @category Util
|
|
16
|
+
* @see {@link renderDynamicElement}
|
|
17
|
+
* @see [example usage](https://github.com/electrovir/vira/blob/dev/packages/vira-book/src/element-book/entries/dynamic-elements.book.ts)
|
|
18
|
+
*/
|
|
19
|
+
export declare function createDynamicElementLoader<const Loaders extends Readonly<BaseDynamicElementLoaders>>(loaders: Readonly<Loaders>): DynamicElementAsyncProp<Loaders>;
|
|
20
|
+
/**
|
|
21
|
+
* The value for the async prop {@link DynamicElementAsyncProp}.
|
|
22
|
+
*
|
|
23
|
+
* @category Internal
|
|
24
|
+
*/
|
|
25
|
+
export type DynamicElementValue<Loaders extends BaseDynamicElementLoaders> = {
|
|
26
|
+
cache: Partial<Record<keyof Loaders, DeclarativeElementDefinition>>;
|
|
27
|
+
element: Awaited<ReturnType<Values<Loaders>>>;
|
|
28
|
+
key: keyof Loaders;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* An async prop for dynamic loading elements. This is the output from
|
|
32
|
+
* {@link createDynamicElementLoader}.
|
|
33
|
+
*
|
|
34
|
+
* @category Internal
|
|
35
|
+
*/
|
|
36
|
+
export type DynamicElementAsyncProp<Loaders extends BaseDynamicElementLoaders> = AsyncProp<DynamicElementValue<Loaders>, keyof Loaders>;
|
|
37
|
+
/**
|
|
38
|
+
* Params for the `ready` callback in {@link renderDynamicElement}.
|
|
39
|
+
*
|
|
40
|
+
* @category Internal
|
|
41
|
+
*/
|
|
42
|
+
export type ReadyParams<Loaders extends Readonly<BaseDynamicElementLoaders>> = RequireExactlyOne<{
|
|
43
|
+
[Key in keyof Loaders]: Awaited<ReturnType<Loaders[Key]>>;
|
|
44
|
+
}>;
|
|
45
|
+
/**
|
|
46
|
+
* Renders the current state of a dynamic element loader. This should go in your render function.
|
|
47
|
+
* Make sure to also use {@link createDynamicElementLoader} to create a dynamic loader in your
|
|
48
|
+
* element's state.
|
|
49
|
+
*
|
|
50
|
+
* @category Util
|
|
51
|
+
* @see {@link createDynamicElementLoader}
|
|
52
|
+
* @see [example usage](https://github.com/electrovir/vira/blob/dev/packages/vira-book/src/element-book/entries/dynamic-elements.book.ts)
|
|
53
|
+
*/
|
|
54
|
+
export declare function renderDynamicElement<const Loaders extends BaseDynamicElementLoaders, const LoadingReturnValue, const ReadyReturnValue, const ErrorReturnValue>(asyncProp: DynamicElementAsyncProp<Loaders>, { ready, loading, error, key, }: {
|
|
55
|
+
/**
|
|
56
|
+
* If this is left undefined (or falsy), the current key will not be set, whatever the
|
|
57
|
+
* existing key is will continue to be used.
|
|
58
|
+
*/
|
|
59
|
+
key?: keyof NoInfer<Loaders> | undefined;
|
|
60
|
+
loading(this: void, params: Promise<ReadyParams<NoInfer<Loaders>>>): LoadingReturnValue;
|
|
61
|
+
ready(this: void, params: ReadyParams<NoInfer<Loaders>>): ReadyReturnValue;
|
|
62
|
+
error(this: void, error: Error): ErrorReturnValue;
|
|
63
|
+
}): ReadyReturnValue | LoadingReturnValue | ErrorReturnValue;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { asyncProp } from 'element-vir';
|
|
2
|
+
/**
|
|
3
|
+
* Create a dynamic element loader. This should go in your element state. This makes deferring
|
|
4
|
+
* element importing convenient and allows parts of your app to be placed in separate bundles. Make
|
|
5
|
+
* sure to also use {@link renderDynamicElement} to use the output of this loader.
|
|
6
|
+
*
|
|
7
|
+
* @category Util
|
|
8
|
+
* @see {@link renderDynamicElement}
|
|
9
|
+
* @see [example usage](https://github.com/electrovir/vira/blob/dev/packages/vira-book/src/element-book/entries/dynamic-elements.book.ts)
|
|
10
|
+
*/
|
|
11
|
+
export function createDynamicElementLoader(loaders) {
|
|
12
|
+
return asyncProp({
|
|
13
|
+
async updateCallback(elementKey, previousResolvedValue) {
|
|
14
|
+
if (previousResolvedValue && elementKey in previousResolvedValue.cache) {
|
|
15
|
+
return {
|
|
16
|
+
cache: previousResolvedValue.cache,
|
|
17
|
+
element: previousResolvedValue.cache[elementKey],
|
|
18
|
+
key: elementKey,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
const imported = await loaders[elementKey]();
|
|
22
|
+
return {
|
|
23
|
+
cache: {
|
|
24
|
+
...previousResolvedValue?.cache,
|
|
25
|
+
[elementKey]: imported,
|
|
26
|
+
},
|
|
27
|
+
element: imported,
|
|
28
|
+
key: elementKey,
|
|
29
|
+
};
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Renders the current state of a dynamic element loader. This should go in your render function.
|
|
35
|
+
* Make sure to also use {@link createDynamicElementLoader} to create a dynamic loader in your
|
|
36
|
+
* element's state.
|
|
37
|
+
*
|
|
38
|
+
* @category Util
|
|
39
|
+
* @see {@link createDynamicElementLoader}
|
|
40
|
+
* @see [example usage](https://github.com/electrovir/vira/blob/dev/packages/vira-book/src/element-book/entries/dynamic-elements.book.ts)
|
|
41
|
+
*/
|
|
42
|
+
export function renderDynamicElement(asyncProp, { ready, loading, error, key, }) {
|
|
43
|
+
if (key) {
|
|
44
|
+
asyncProp.update(key);
|
|
45
|
+
}
|
|
46
|
+
if (asyncProp.value instanceof Error) {
|
|
47
|
+
return error(asyncProp.value);
|
|
48
|
+
}
|
|
49
|
+
else if (asyncProp.value instanceof Promise) {
|
|
50
|
+
return loading(asyncProp.value.then((value) => {
|
|
51
|
+
return {
|
|
52
|
+
[value.key]: value.element,
|
|
53
|
+
};
|
|
54
|
+
}));
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
return ready({
|
|
58
|
+
[asyncProp.value.key]: asyncProp.value.element,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { type MaybePromise } from '@augment-vir/common';
|
|
2
|
+
import { type Coords, type NavController } from 'device-navigation';
|
|
3
|
+
import { type ExtractEventByType, type ExtractEventTypes, type ListenOptions, type RemoveListenerCallback } from 'typed-event-target';
|
|
4
|
+
/**
|
|
5
|
+
* Used to prevent pop-ups from closing when a text input is active.
|
|
6
|
+
*
|
|
7
|
+
* @category Internal
|
|
8
|
+
*/
|
|
9
|
+
export declare function isInputLikeElement(element: Element): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* A type used for representing a rectangle's position.
|
|
12
|
+
*
|
|
13
|
+
* @category Internal
|
|
14
|
+
*/
|
|
15
|
+
export type PositionRect = {
|
|
16
|
+
top: number;
|
|
17
|
+
left: number;
|
|
18
|
+
right: number;
|
|
19
|
+
bottom: number;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* The default empty {@link PositionRect}, with all values set to 0.
|
|
23
|
+
*
|
|
24
|
+
* @category Internal
|
|
25
|
+
*/
|
|
26
|
+
export declare const emptyPositionRect: PositionRect;
|
|
27
|
+
/**
|
|
28
|
+
* Options for {@link PopUpManager}.
|
|
29
|
+
*
|
|
30
|
+
* @category PopUp
|
|
31
|
+
*/
|
|
32
|
+
export type PopUpManagerOptions = {
|
|
33
|
+
/**
|
|
34
|
+
* The minimum number of pixels for allowing the pop-up to go downwards. If the downward
|
|
35
|
+
* available space is less than this, and if the upwards available space is
|
|
36
|
+
* `verticalDiffThreshold` more than the downwards space, the pop-up will be directed upwards.
|
|
37
|
+
*
|
|
38
|
+
* Equation:
|
|
39
|
+
*
|
|
40
|
+
* const directUpwards =
|
|
41
|
+
* downwardsSpace < minDownSpace &&
|
|
42
|
+
* upwardsSpace > DownwardsSpace + verticalDiffThreshold;
|
|
43
|
+
*
|
|
44
|
+
* @default 200
|
|
45
|
+
*/
|
|
46
|
+
minDownSpace: number;
|
|
47
|
+
/**
|
|
48
|
+
* The minimum number of pixels for allowing the pop-up to go rightwards. If the rightward
|
|
49
|
+
* available space is less than this, and if the leftwards available space is
|
|
50
|
+
* `horizontalDiffThreshold` more than the rightwards space, the pop-up will be directed
|
|
51
|
+
* leftwards.
|
|
52
|
+
*
|
|
53
|
+
* Equation:
|
|
54
|
+
*
|
|
55
|
+
* const directLeftwards =
|
|
56
|
+
* rightwardsSpace < minRightSpace &&
|
|
57
|
+
* leftwardsSpace > rightwardsSpace + horizontalDiffThreshold;
|
|
58
|
+
*
|
|
59
|
+
* @default 400
|
|
60
|
+
*/
|
|
61
|
+
minRightSpace: number;
|
|
62
|
+
/**
|
|
63
|
+
* The number of pixels required for the upwards available space to be bigger than the downwards
|
|
64
|
+
* available space before directing the pop-up upwards.
|
|
65
|
+
*
|
|
66
|
+
* Equation:
|
|
67
|
+
*
|
|
68
|
+
* const directUpwards =
|
|
69
|
+
* downwardsSpace < minDownSpace &&
|
|
70
|
+
* upwardsSpace > DownwardsSpace + verticalDiffThreshold;
|
|
71
|
+
*
|
|
72
|
+
* @default 20
|
|
73
|
+
*/
|
|
74
|
+
verticalDiffThreshold: number;
|
|
75
|
+
/**
|
|
76
|
+
* The number of pixels required for the leftwards available space to be bigger than the
|
|
77
|
+
* rightwards available space before directing the pop-up leftwards.
|
|
78
|
+
*
|
|
79
|
+
* Equation:
|
|
80
|
+
*
|
|
81
|
+
* const directLeftwards =
|
|
82
|
+
* rightwardsSpace < minRightSpace &&
|
|
83
|
+
* leftwardsSpace > rightwardsSpace + horizontalDiffThreshold;
|
|
84
|
+
*
|
|
85
|
+
* @default 100
|
|
86
|
+
*/
|
|
87
|
+
horizontalDiffThreshold: number;
|
|
88
|
+
/**
|
|
89
|
+
* Supports navigation of the pop up via the `device-navigation` package.
|
|
90
|
+
*
|
|
91
|
+
* @default true
|
|
92
|
+
*/
|
|
93
|
+
supportNavigation: boolean;
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Output type from `PopUpManager.showPopUp`
|
|
97
|
+
*
|
|
98
|
+
* @category PopUp
|
|
99
|
+
*/
|
|
100
|
+
export type ShowPopUpResult = {
|
|
101
|
+
/**
|
|
102
|
+
* Indicates if the "pop up" should pop in the downwards direction or not. If not, it should pop
|
|
103
|
+
* in the upwards direction. This is determined by how much space is available on either side of
|
|
104
|
+
* the root element.
|
|
105
|
+
*/
|
|
106
|
+
popDown: boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Indicates if the "pop up" should pop in the rightwards direction or not. If not, it should
|
|
109
|
+
* pop in the leftwards direction. This is determined by how much space is available on either
|
|
110
|
+
* side of the root element.
|
|
111
|
+
*/
|
|
112
|
+
popRight: boolean;
|
|
113
|
+
positions: Record<'root' | 'container' | 'diff', PositionRect>;
|
|
114
|
+
};
|
|
115
|
+
declare const HidePopUpEvent_base: (new (eventInitDict?: EventInit) => import("typed-event-target").TypedEvent<"hide-pop-up">) & Pick<{
|
|
116
|
+
new (type: string, eventInitDict?: EventInit): Event;
|
|
117
|
+
prototype: Event;
|
|
118
|
+
readonly NONE: 0;
|
|
119
|
+
readonly CAPTURING_PHASE: 1;
|
|
120
|
+
readonly AT_TARGET: 2;
|
|
121
|
+
readonly BUBBLING_PHASE: 3;
|
|
122
|
+
}, "prototype" | "NONE" | "CAPTURING_PHASE" | "AT_TARGET" | "BUBBLING_PHASE"> & Pick<import("typed-event-target").TypedEvent<"hide-pop-up">, "type">;
|
|
123
|
+
/**
|
|
124
|
+
* An event fired from {@link PopUpManager} when the pop up should be hidden.
|
|
125
|
+
*
|
|
126
|
+
* @category PopUp
|
|
127
|
+
*/
|
|
128
|
+
export declare class HidePopUpEvent extends HidePopUpEvent_base {
|
|
129
|
+
}
|
|
130
|
+
declare const NavSelectEvent_base: (new (eventInitDict: {
|
|
131
|
+
bubbles?: boolean;
|
|
132
|
+
cancelable?: boolean;
|
|
133
|
+
composed?: boolean;
|
|
134
|
+
detail: Coords;
|
|
135
|
+
}) => import("typed-event-target").TypedCustomEvent<Coords, "nav-select">) & Pick<{
|
|
136
|
+
new (type: string, eventInitDict?: EventInit): Event;
|
|
137
|
+
prototype: Event;
|
|
138
|
+
readonly NONE: 0;
|
|
139
|
+
readonly CAPTURING_PHASE: 1;
|
|
140
|
+
readonly AT_TARGET: 2;
|
|
141
|
+
readonly BUBBLING_PHASE: 3;
|
|
142
|
+
}, "prototype" | "NONE" | "CAPTURING_PHASE" | "AT_TARGET" | "BUBBLING_PHASE"> & Pick<import("typed-event-target").TypedCustomEvent<Coords, "nav-select">, "type">;
|
|
143
|
+
/**
|
|
144
|
+
* An event fired from {@link PopUpManager} when an individual item in the pop up has been selected
|
|
145
|
+
* by the user.
|
|
146
|
+
*
|
|
147
|
+
* @category PopUp
|
|
148
|
+
*/
|
|
149
|
+
export declare class NavSelectEvent extends NavSelectEvent_base {
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* All events that can be emitted by {@link PopUpManager}.
|
|
153
|
+
*
|
|
154
|
+
* @category Internal
|
|
155
|
+
*/
|
|
156
|
+
export type PopUpManagerEvents = HidePopUpEvent | NavSelectEvent;
|
|
157
|
+
/**
|
|
158
|
+
* A "pop up" manager for items that pop up from the HTML page, like dropdowns or menus.
|
|
159
|
+
*
|
|
160
|
+
* @category PopUp
|
|
161
|
+
*/
|
|
162
|
+
export declare class PopUpManager {
|
|
163
|
+
readonly navController: NavController;
|
|
164
|
+
private listenTarget;
|
|
165
|
+
options: PopUpManagerOptions;
|
|
166
|
+
private cleanupCallbacks;
|
|
167
|
+
private lastRootElement;
|
|
168
|
+
constructor(navController: NavController, options?: Partial<PopUpManagerOptions> | undefined);
|
|
169
|
+
private attachGlobalListeners;
|
|
170
|
+
/** Listen to events emitted from a {@link PopUpManager} instance. */
|
|
171
|
+
listen<const EventDefinition extends Readonly<{
|
|
172
|
+
type: ExtractEventTypes<PopUpManagerEvents>;
|
|
173
|
+
}>>(event: EventDefinition, listener: (event: ExtractEventByType<PopUpManagerEvents, EventDefinition['type']>) => MaybePromise<void>, options?: ListenOptions | undefined): RemoveListenerCallback;
|
|
174
|
+
/** Trigger removal or hiding of the pop up. */
|
|
175
|
+
removePopUp(): void;
|
|
176
|
+
/** Trigger showing the pop up. */
|
|
177
|
+
showPopUp(rootElement: HTMLElement, options?: Partial<PopUpManagerOptions> | undefined): ShowPopUpResult;
|
|
178
|
+
/**
|
|
179
|
+
* Cleanup and destroy the {@link PopUpManager} instance. This:
|
|
180
|
+
*
|
|
181
|
+
* - Removes the existing pop up
|
|
182
|
+
* - Cleans up all internal and external listeners
|
|
183
|
+
*/
|
|
184
|
+
destroy(): void;
|
|
185
|
+
}
|
|
186
|
+
export {};
|