@qnc/qnc_data_tables 1.0.4 → 1.0.6-a

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 (66) hide show
  1. package/README.md +36 -0
  2. package/dist/bound_stored_value.d.ts +39 -0
  3. package/dist/bound_stored_value.js +134 -0
  4. package/dist/bound_stored_value.ts +158 -0
  5. package/dist/column_manager.d.ts +43 -0
  6. package/dist/column_manager.js +124 -0
  7. package/dist/column_manager.ts +158 -0
  8. package/dist/column_resizing.d.ts +3 -0
  9. package/dist/column_resizing.js +30 -0
  10. package/dist/column_resizing.ts +52 -0
  11. package/dist/column_sorting.d.ts +11 -0
  12. package/dist/column_sorting.js +53 -0
  13. package/dist/column_sorting.ts +63 -0
  14. package/dist/conditionally_wrapped_element.d.ts +5 -0
  15. package/dist/conditionally_wrapped_element.js +14 -0
  16. package/dist/conditionally_wrapped_element.ts +17 -0
  17. package/dist/create_mithril_app.d.ts +3 -0
  18. package/dist/create_mithril_app.js +25 -0
  19. package/dist/create_mithril_app.ts +35 -0
  20. package/dist/create_style.d.ts +4 -0
  21. package/dist/create_style.js +9 -0
  22. package/dist/create_style.ts +10 -0
  23. package/dist/custom_element.d.ts +23 -0
  24. package/dist/custom_element.js +63 -0
  25. package/dist/custom_element.ts +71 -0
  26. package/dist/event_names.d.ts +1 -0
  27. package/dist/event_names.js +1 -0
  28. package/dist/event_names.ts +1 -0
  29. package/dist/index.d.ts +5 -0
  30. package/dist/index.js +4 -0
  31. package/dist/index.ts +5 -0
  32. package/dist/mithril_view.d.ts +16 -0
  33. package/dist/mithril_view.js +484 -0
  34. package/dist/mithril_view.ts +1014 -0
  35. package/dist/optional_storage.d.ts +6 -0
  36. package/dist/optional_storage.js +18 -0
  37. package/dist/optional_storage.ts +23 -0
  38. package/dist/overflow_class_manager.d.ts +20 -0
  39. package/dist/overflow_class_manager.js +30 -0
  40. package/dist/overflow_class_manager.ts +40 -0
  41. package/dist/renderer.d.ts +16 -0
  42. package/dist/renderer.js +51 -0
  43. package/dist/renderer.ts +86 -0
  44. package/dist/selection_fieldset_controller.d.ts +9 -0
  45. package/dist/selection_fieldset_controller.js +85 -0
  46. package/dist/selection_fieldset_controller.ts +104 -0
  47. package/dist/state_machine.d.ts +67 -0
  48. package/dist/state_machine.js +316 -0
  49. package/dist/state_machine.ts +434 -0
  50. package/dist/state_types.d.ts +62 -0
  51. package/dist/state_types.js +1 -0
  52. package/dist/state_types.ts +84 -0
  53. package/dist/table_manager.d.ts +9 -0
  54. package/dist/table_manager.js +16 -0
  55. package/dist/table_manager.ts +28 -0
  56. package/dist/table_options.d.ts +164 -0
  57. package/dist/table_options.js +97 -0
  58. package/dist/table_options.ts +132 -0
  59. package/dist/tsconfig.tsbuildinfo +1 -1
  60. package/dist/watched_mutable_value.d.ts +15 -0
  61. package/dist/watched_mutable_value.js +23 -0
  62. package/dist/watched_mutable_value.ts +23 -0
  63. package/package.json +12 -5
  64. package/dist/qnc_data_tables.d.ts +0 -57
  65. package/dist/qnc_data_tables.js +0 -1136
  66. package/dist/qnc_data_tables_inline_css.js +0 -8
@@ -0,0 +1,164 @@
1
+ import * as ss from "superstruct";
2
+ declare const ColumnStruct: ss.Struct<{
3
+ key: string;
4
+ fixed: boolean;
5
+ display: string;
6
+ help_text: string;
7
+ enabled: boolean;
8
+ width: number;
9
+ sortable: boolean;
10
+ }, {
11
+ /** used to persist settings in Storage; must be unique across a table */
12
+ key: ss.Struct<string, null>;
13
+ /** column title */
14
+ display: ss.Struct<string, null>;
15
+ help_text: ss.Struct<string, null>;
16
+ /** whether the column is _initially_ shown; user can enable/disable */
17
+ enabled: ss.Struct<boolean, null>;
18
+ /** if true, the column cannot be reordered or enabled/disabled by the user, and is "sticky" when scrolling horizontally */
19
+ fixed: ss.Struct<boolean, null>;
20
+ /** sets the _initial_ with, in px; it's user-resizable */
21
+ width: ss.Struct<number, null>;
22
+ /** whether or not the user can click the column header to sort by this column */
23
+ /** when the user is sorting by this column, we will automatically set sort key to column_asc-KEY or column-desc-KEY */
24
+ sortable: ss.Struct<boolean, null>;
25
+ }>;
26
+ export type Column = ss.Infer<typeof ColumnStruct>;
27
+ declare const OptionalStorageStruct: ss.Struct<"localStorage" | "sessionStorage" | null, null>;
28
+ export type OptionalStorageChoice = ss.Infer<typeof OptionalStorageStruct>;
29
+ export declare function get_storage(type: OptionalStorageChoice): Storage | null;
30
+ /**
31
+ "ExtraSortFunctions" are NOT js functions.
32
+ They are DESCRIPTIONS of sort functions implemented by the backend.
33
+ The only thing the front-end does with them is display some kind of sort-picker.
34
+ */
35
+ declare const ExtraSortFunctionStruct: ss.Struct<{
36
+ key: string;
37
+ display: string;
38
+ help_text: string;
39
+ }, {
40
+ /** will be submitted to back-end */
41
+ key: ss.Struct<string, null>;
42
+ /** what to display in sort-picker */
43
+ display: ss.Struct<string, null>;
44
+ /** help text, in case `display` is not self-explanatory */
45
+ help_text: ss.Struct<string, null>;
46
+ }>;
47
+ export type ExtraSortFunction = ss.Infer<typeof ExtraSortFunctionStruct>;
48
+ declare const TableOptionsStruct: ss.Struct<{
49
+ columns: {
50
+ key: string;
51
+ fixed: boolean;
52
+ display: string;
53
+ help_text: string;
54
+ enabled: boolean;
55
+ width: number;
56
+ sortable: boolean;
57
+ }[];
58
+ allow_selection: boolean;
59
+ api_url: string;
60
+ filter_form_id: string;
61
+ key_prefix: string;
62
+ refresh_on_change: boolean;
63
+ page_size: number;
64
+ page_limit: number;
65
+ table_limit: number;
66
+ fill_last_page: boolean;
67
+ default_sort_key: string;
68
+ layout_storage: "localStorage" | "sessionStorage" | null;
69
+ navigation_storage: "localStorage" | "sessionStorage" | null;
70
+ selection_storage: "localStorage" | "sessionStorage" | null;
71
+ sort_storage: "localStorage" | "sessionStorage" | null;
72
+ extra_sort_functions: {
73
+ key: string;
74
+ display: string;
75
+ help_text: string;
76
+ }[];
77
+ default_sort: {
78
+ type: "column";
79
+ column_key: string;
80
+ direction: "reverse" | "forward";
81
+ } | {
82
+ type: "function";
83
+ function_key: string;
84
+ } | null;
85
+ }, {
86
+ columns: ss.Struct<{
87
+ key: string;
88
+ fixed: boolean;
89
+ display: string;
90
+ help_text: string;
91
+ enabled: boolean;
92
+ width: number;
93
+ sortable: boolean;
94
+ }[], ss.Struct<{
95
+ key: string;
96
+ fixed: boolean;
97
+ display: string;
98
+ help_text: string;
99
+ enabled: boolean;
100
+ width: number;
101
+ sortable: boolean;
102
+ }, {
103
+ /** used to persist settings in Storage; must be unique across a table */
104
+ key: ss.Struct<string, null>;
105
+ /** column title */
106
+ display: ss.Struct<string, null>;
107
+ help_text: ss.Struct<string, null>;
108
+ /** whether the column is _initially_ shown; user can enable/disable */
109
+ enabled: ss.Struct<boolean, null>;
110
+ /** if true, the column cannot be reordered or enabled/disabled by the user, and is "sticky" when scrolling horizontally */
111
+ fixed: ss.Struct<boolean, null>;
112
+ /** sets the _initial_ with, in px; it's user-resizable */
113
+ width: ss.Struct<number, null>;
114
+ /** whether or not the user can click the column header to sort by this column */
115
+ /** when the user is sorting by this column, we will automatically set sort key to column_asc-KEY or column-desc-KEY */
116
+ sortable: ss.Struct<boolean, null>;
117
+ }>>;
118
+ allow_selection: ss.Struct<boolean, null>;
119
+ api_url: ss.Struct<string, null>;
120
+ filter_form_id: ss.Struct<string, null>;
121
+ key_prefix: ss.Struct<string, null>;
122
+ refresh_on_change: ss.Struct<boolean, null>;
123
+ page_size: ss.Struct<number, null>;
124
+ page_limit: ss.Struct<number, null>;
125
+ table_limit: ss.Struct<number, null>;
126
+ fill_last_page: ss.Struct<boolean, null>;
127
+ default_sort_key: ss.Struct<string, null>;
128
+ /** Where table layout preferences (columns, column widths) are stored */
129
+ layout_storage: ss.Struct<"localStorage" | "sessionStorage" | null, null>;
130
+ /** where page number is stored */
131
+ navigation_storage: ss.Struct<"localStorage" | "sessionStorage" | null, null>;
132
+ /** where selection is stored */
133
+ selection_storage: ss.Struct<"localStorage" | "sessionStorage" | null, null>;
134
+ /** where sort order is stored */
135
+ sort_storage: ss.Struct<"localStorage" | "sessionStorage" | null, null>;
136
+ /** when non-empty, will cause a "sort widget" to be displayed in the paginator */
137
+ extra_sort_functions: ss.Struct<{
138
+ key: string;
139
+ display: string;
140
+ help_text: string;
141
+ }[], ss.Struct<{
142
+ key: string;
143
+ display: string;
144
+ help_text: string;
145
+ }, {
146
+ /** will be submitted to back-end */
147
+ key: ss.Struct<string, null>;
148
+ /** what to display in sort-picker */
149
+ display: ss.Struct<string, null>;
150
+ /** help text, in case `display` is not self-explanatory */
151
+ help_text: ss.Struct<string, null>;
152
+ }>>;
153
+ default_sort: ss.Struct<{
154
+ type: "column";
155
+ column_key: string;
156
+ direction: "reverse" | "forward";
157
+ } | {
158
+ type: "function";
159
+ function_key: string;
160
+ } | null, null>;
161
+ }>;
162
+ export type TableOptions = ss.Infer<typeof TableOptionsStruct>;
163
+ export declare function read_options_from_json_string(json: string): TableOptions;
164
+ export {};
@@ -0,0 +1,97 @@
1
+ import * as ss from "superstruct";
2
+ import { assert_never } from "@qnc/type_utils";
3
+ function css_class_component() {
4
+ return ss.define("css_class_component", (value) => (typeof value == "string" && value.match(/^[\w-]*$/) !== null) ||
5
+ `Expected a string, but received: ${value}`);
6
+ }
7
+ const ColumnStruct = ss.object({
8
+ /** used to persist settings in Storage; must be unique across a table */
9
+ key: css_class_component(),
10
+ /** column title */
11
+ display: ss.string(),
12
+ help_text: ss.string(),
13
+ /** whether the column is _initially_ shown; user can enable/disable */
14
+ enabled: ss.boolean(),
15
+ /** if true, the column cannot be reordered or enabled/disabled by the user, and is "sticky" when scrolling horizontally */
16
+ fixed: ss.boolean(),
17
+ /** sets the _initial_ with, in px; it's user-resizable */
18
+ width: ss.number(),
19
+ /** whether or not the user can click the column header to sort by this column */
20
+ /** when the user is sorting by this column, we will automatically set sort key to column_asc-KEY or column-desc-KEY */
21
+ sortable: ss.boolean(),
22
+ });
23
+ const OptionalStorageStruct = ss.union([
24
+ ss.literal("localStorage"),
25
+ ss.literal("sessionStorage"),
26
+ ss.literal(null),
27
+ ]);
28
+ export function get_storage(type) {
29
+ if (type == "localStorage")
30
+ return localStorage;
31
+ if (type == "sessionStorage")
32
+ return sessionStorage;
33
+ if (type == null)
34
+ return null;
35
+ assert_never(type);
36
+ }
37
+ const SortStateStruct = ss.union([
38
+ ss.object({
39
+ type: ss.literal("column"),
40
+ column_key: ss.string(),
41
+ direction: ss.union([ss.literal("forward"), ss.literal("reverse")]),
42
+ }),
43
+ ss.object({
44
+ type: ss.literal("function"),
45
+ function_key: ss.string(),
46
+ }),
47
+ ]);
48
+ /**
49
+ "ExtraSortFunctions" are NOT js functions.
50
+ They are DESCRIPTIONS of sort functions implemented by the backend.
51
+ The only thing the front-end does with them is display some kind of sort-picker.
52
+ */
53
+ const ExtraSortFunctionStruct = ss.object({
54
+ /** will be submitted to back-end */
55
+ key: ss.string(),
56
+ /** what to display in sort-picker */
57
+ display: ss.string(),
58
+ /** help text, in case `display` is not self-explanatory */
59
+ help_text: ss.defaulted(ss.string(), ""),
60
+ });
61
+ const TableOptionsStruct = ss.object({
62
+ columns: ss.array(ColumnStruct),
63
+ allow_selection: ss.defaulted(ss.boolean(), false),
64
+ api_url: ss.defaulted(ss.string(), "."),
65
+ // If non-empty, MUST reference a <form> element on the page
66
+ filter_form_id: ss.defaulted(ss.string(), ""),
67
+ // Must be unique across all data tables on a given page (used in constructing CSS classes and Storage keys)
68
+ // Must be unique across all tables submitting to same api_url (used in constructing keys for backend communication)
69
+ // Must contain only alphanumerics, underscores, and hyphens
70
+ key_prefix: ss.defaulted(css_class_component(), "table-manager"),
71
+ // if the table is associated with a filter form, it will refresh on submit events
72
+ // additionally, if this is set, the table will refresh on any change event on the form
73
+ refresh_on_change: ss.defaulted(ss.boolean(), true),
74
+ page_size: ss.integer(),
75
+ page_limit: ss.integer(),
76
+ table_limit: ss.integer(),
77
+ // If last page of data has fewer rows than page_size and this is set, we'll add empty rows
78
+ // keeps layout/height more consistent, regardless of data
79
+ fill_last_page: ss.defaulted(ss.boolean(), true),
80
+ // Initial sort key to pass to backend, if user has not chosen something else
81
+ // Empty string means "use first enabled sortable column"
82
+ default_sort_key: ss.defaulted(ss.string(), ""),
83
+ /** Where table layout preferences (columns, column widths) are stored */
84
+ layout_storage: ss.defaulted(OptionalStorageStruct, "localStorage"),
85
+ /** where page number is stored */
86
+ navigation_storage: ss.defaulted(OptionalStorageStruct, "sessionStorage"),
87
+ /** where selection is stored */
88
+ selection_storage: ss.defaulted(OptionalStorageStruct, "sessionStorage"),
89
+ /** where sort order is stored */
90
+ sort_storage: ss.defaulted(OptionalStorageStruct, "localStorage"),
91
+ /** when non-empty, will cause a "sort widget" to be displayed in the paginator */
92
+ extra_sort_functions: ss.defaulted(ss.array(ExtraSortFunctionStruct), []),
93
+ default_sort: ss.defaulted(ss.union([SortStateStruct, ss.literal(null)]), null),
94
+ });
95
+ export function read_options_from_json_string(json) {
96
+ return ss.create(JSON.parse(json), TableOptionsStruct);
97
+ }
@@ -0,0 +1,132 @@
1
+ import * as ss from "superstruct";
2
+ import { assert_never } from "@qnc/type_utils";
3
+
4
+ function css_class_component(): ss.Struct<string, null> {
5
+ return ss.define(
6
+ "css_class_component",
7
+ (value) =>
8
+ (typeof value == "string" && value.match(/^[\w-]*$/) !== null) ||
9
+ `Expected a string, but received: ${value}`,
10
+ );
11
+ }
12
+
13
+ const ColumnStruct = ss.object({
14
+ /** used to persist settings in Storage; must be unique across a table */
15
+ key: css_class_component(),
16
+
17
+ /** column title */
18
+ display: ss.string(),
19
+
20
+ help_text: ss.string(),
21
+
22
+ /** whether the column is _initially_ shown; user can enable/disable */
23
+ enabled: ss.boolean(),
24
+
25
+ /** if true, the column cannot be reordered or enabled/disabled by the user, and is "sticky" when scrolling horizontally */
26
+ fixed: ss.boolean(),
27
+
28
+ /** sets the _initial_ with, in px; it's user-resizable */
29
+ width: ss.number(),
30
+
31
+ /** whether or not the user can click the column header to sort by this column */
32
+ /** when the user is sorting by this column, we will automatically set sort key to column_asc-KEY or column-desc-KEY */
33
+ sortable: ss.boolean(),
34
+ });
35
+ export type Column = ss.Infer<typeof ColumnStruct>;
36
+
37
+ const OptionalStorageStruct = ss.union([
38
+ ss.literal("localStorage"),
39
+ ss.literal("sessionStorage"),
40
+ ss.literal(null),
41
+ ]);
42
+ export type OptionalStorageChoice = ss.Infer<typeof OptionalStorageStruct>;
43
+
44
+ export function get_storage(type: OptionalStorageChoice): Storage | null {
45
+ if (type == "localStorage") return localStorage;
46
+ if (type == "sessionStorage") return sessionStorage;
47
+ if (type == null) return null;
48
+ assert_never(type);
49
+ }
50
+
51
+ const SortStateStruct = ss.union([
52
+ ss.object({
53
+ type: ss.literal("column"),
54
+ column_key: ss.string(),
55
+ direction: ss.union([ss.literal("forward"), ss.literal("reverse")]),
56
+ }),
57
+ ss.object({
58
+ type: ss.literal("function"),
59
+ function_key: ss.string(),
60
+ }),
61
+ ]);
62
+
63
+ /**
64
+ "ExtraSortFunctions" are NOT js functions.
65
+ They are DESCRIPTIONS of sort functions implemented by the backend.
66
+ The only thing the front-end does with them is display some kind of sort-picker.
67
+ */
68
+ const ExtraSortFunctionStruct = ss.object({
69
+ /** will be submitted to back-end */
70
+ key: ss.string(),
71
+ /** what to display in sort-picker */
72
+ display: ss.string(),
73
+ /** help text, in case `display` is not self-explanatory */
74
+ help_text: ss.defaulted(ss.string(), ""),
75
+ });
76
+ export type ExtraSortFunction = ss.Infer<typeof ExtraSortFunctionStruct>;
77
+
78
+ const TableOptionsStruct = ss.object({
79
+ columns: ss.array(ColumnStruct),
80
+ allow_selection: ss.defaulted(ss.boolean(), false),
81
+ api_url: ss.defaulted(ss.string(), "."),
82
+
83
+ // If non-empty, MUST reference a <form> element on the page
84
+ filter_form_id: ss.defaulted(ss.string(), ""),
85
+
86
+ // Must be unique across all data tables on a given page (used in constructing CSS classes and Storage keys)
87
+ // Must be unique across all tables submitting to same api_url (used in constructing keys for backend communication)
88
+ // Must contain only alphanumerics, underscores, and hyphens
89
+ key_prefix: ss.defaulted(css_class_component(), "table-manager"),
90
+
91
+ // if the table is associated with a filter form, it will refresh on submit events
92
+ // additionally, if this is set, the table will refresh on any change event on the form
93
+ refresh_on_change: ss.defaulted(ss.boolean(), true),
94
+
95
+ page_size: ss.integer(),
96
+ page_limit: ss.integer(),
97
+ table_limit: ss.integer(),
98
+
99
+ // If last page of data has fewer rows than page_size and this is set, we'll add empty rows
100
+ // keeps layout/height more consistent, regardless of data
101
+ fill_last_page: ss.defaulted(ss.boolean(), true),
102
+
103
+ // Initial sort key to pass to backend, if user has not chosen something else
104
+ // Empty string means "use first enabled sortable column"
105
+ default_sort_key: ss.defaulted(ss.string(), ""),
106
+
107
+ /** Where table layout preferences (columns, column widths) are stored */
108
+ layout_storage: ss.defaulted(OptionalStorageStruct, "localStorage"),
109
+
110
+ /** where page number is stored */
111
+ navigation_storage: ss.defaulted(OptionalStorageStruct, "sessionStorage"),
112
+
113
+ /** where selection is stored */
114
+ selection_storage: ss.defaulted(OptionalStorageStruct, "sessionStorage"),
115
+
116
+ /** where sort order is stored */
117
+ sort_storage: ss.defaulted(OptionalStorageStruct, "localStorage"),
118
+
119
+ /** when non-empty, will cause a "sort widget" to be displayed in the paginator */
120
+ extra_sort_functions: ss.defaulted(ss.array(ExtraSortFunctionStruct), []),
121
+
122
+ default_sort: ss.defaulted(
123
+ ss.union([SortStateStruct, ss.literal(null)]),
124
+ null,
125
+ ),
126
+ });
127
+
128
+ export type TableOptions = ss.Infer<typeof TableOptionsStruct>;
129
+
130
+ export function read_options_from_json_string(json: string): TableOptions {
131
+ return ss.create(JSON.parse(json), TableOptionsStruct);
132
+ }
@@ -1 +1 @@
1
- {"fileNames":["../../../../.nvm/versions/node/v22.16.0/lib/node_modules/typescript/lib/lib.es6.d.ts","../../../../.nvm/versions/node/v22.16.0/lib/node_modules/typescript/lib/lib.es5.d.ts","../../../../.nvm/versions/node/v22.16.0/lib/node_modules/typescript/lib/lib.es2015.d.ts","../../../../.nvm/versions/node/v22.16.0/lib/node_modules/typescript/lib/lib.dom.d.ts","../../../../.nvm/versions/node/v22.16.0/lib/node_modules/typescript/lib/lib.dom.iterable.d.ts","../../../../.nvm/versions/node/v22.16.0/lib/node_modules/typescript/lib/lib.webworker.importscripts.d.ts","../../../../.nvm/versions/node/v22.16.0/lib/node_modules/typescript/lib/lib.scripthost.d.ts","../../../../.nvm/versions/node/v22.16.0/lib/node_modules/typescript/lib/lib.es2015.core.d.ts","../../../../.nvm/versions/node/v22.16.0/lib/node_modules/typescript/lib/lib.es2015.collection.d.ts","../../../../.nvm/versions/node/v22.16.0/lib/node_modules/typescript/lib/lib.es2015.generator.d.ts","../../../../.nvm/versions/node/v22.16.0/lib/node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../../../.nvm/versions/node/v22.16.0/lib/node_modules/typescript/lib/lib.es2015.promise.d.ts","../../../../.nvm/versions/node/v22.16.0/lib/node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../../../.nvm/versions/node/v22.16.0/lib/node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../../../.nvm/versions/node/v22.16.0/lib/node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../../../.nvm/versions/node/v22.16.0/lib/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../../../.nvm/versions/node/v22.16.0/lib/node_modules/typescript/lib/lib.decorators.d.ts","../../../../.nvm/versions/node/v22.16.0/lib/node_modules/typescript/lib/lib.decorators.legacy.d.ts","../node_modules/@types/mithril/index.d.ts","../node_modules/@qnc/drag_sorter/dist/npm/drag_sorter.d.ts","../src/qnc_data_tables_inline_css.d.ts","../src/qnc_data_tables.ts"],"fileIdsList":[[19,20,21]],"fileInfos":[{"version":"df039a67536fe2acc3affdcbfb645892f842db36fe599e8e652e2f0c640a90d1","impliedFormat":1},{"version":"69684132aeb9b5642cbcd9e22dff7818ff0ee1aa831728af0ecf97d3364d5546","affectsGlobalScope":true,"impliedFormat":1},{"version":"45b7ab580deca34ae9729e97c13cfd999df04416a79116c3bfb483804f85ded4","impliedFormat":1},{"version":"092c2bfe125ce69dbb1223c85d68d4d2397d7d8411867b5cc03cec902c233763","affectsGlobalScope":true,"impliedFormat":1},{"version":"07f073f19d67f74d732b1adea08e1dc66b1b58d77cb5b43931dee3d798a2fd53","affectsGlobalScope":true,"impliedFormat":1},{"version":"80e18897e5884b6723488d4f5652167e7bb5024f946743134ecc4aa4ee731f89","affectsGlobalScope":true,"impliedFormat":1},{"version":"cd034f499c6cdca722b60c04b5b1b78e058487a7085a8e0d6fb50809947ee573","affectsGlobalScope":true,"impliedFormat":1},{"version":"c57796738e7f83dbc4b8e65132f11a377649c00dd3eee333f672b8f0a6bea671","affectsGlobalScope":true,"impliedFormat":1},{"version":"dc2df20b1bcdc8c2d34af4926e2c3ab15ffe1160a63e58b7e09833f616efff44","affectsGlobalScope":true,"impliedFormat":1},{"version":"515d0b7b9bea2e31ea4ec968e9edd2c39d3eebf4a2d5cbd04e88639819ae3b71","affectsGlobalScope":true,"impliedFormat":1},{"version":"0559b1f683ac7505ae451f9a96ce4c3c92bdc71411651ca6ddb0e88baaaad6a3","affectsGlobalScope":true,"impliedFormat":1},{"version":"0dc1e7ceda9b8b9b455c3a2d67b0412feab00bd2f66656cd8850e8831b08b537","affectsGlobalScope":true,"impliedFormat":1},{"version":"ce691fb9e5c64efb9547083e4a34091bcbe5bdb41027e310ebba8f7d96a98671","affectsGlobalScope":true,"impliedFormat":1},{"version":"8d697a2a929a5fcb38b7a65594020fcef05ec1630804a33748829c5ff53640d0","affectsGlobalScope":true,"impliedFormat":1},{"version":"4ff2a353abf8a80ee399af572debb8faab2d33ad38c4b4474cff7f26e7653b8d","affectsGlobalScope":true,"impliedFormat":1},{"version":"936e80ad36a2ee83fc3caf008e7c4c5afe45b3cf3d5c24408f039c1d47bdc1df","affectsGlobalScope":true,"impliedFormat":1},{"version":"8e7f8264d0fb4c5339605a15daadb037bf238c10b654bb3eee14208f860a32ea","affectsGlobalScope":true,"impliedFormat":1},{"version":"782dec38049b92d4e85c1585fbea5474a219c6984a35b004963b00beb1aab538","affectsGlobalScope":true,"impliedFormat":1},{"version":"7c4f7cb8a662bd8b8eec4a712d2bfc40cb2efc3248292dcd2a7fa80d5935c85e","affectsGlobalScope":true,"impliedFormat":1},{"version":"ebdfbfedbd3b85bb714d114c948f30e6ff0991a6162d3b01cd18a2d9c8aa0bb7","impliedFormat":99},{"version":"6112bc1341c6e1a3f072a934b0de0e26982a18cac9b97944f4cb86158ee58f00","impliedFormat":99},{"version":"f50a035fc22774601148adadc2658fb6eadfe75e61a9f47a1de9ad5484297636","signature":"900aedb381fbbe59ae8934a6dddc2da285002ae61980f11b71ec73dd5690f488","impliedFormat":99}],"root":[21,22],"options":{"declaration":true,"esModuleInterop":true,"module":199,"noImplicitAny":true,"noUncheckedIndexedAccess":true,"outDir":"./","strict":true,"target":2},"referencedMap":[[22,1]],"version":"5.8.3"}
1
+ {"fileNames":["../../../../.nvm/versions/node/v22.16.0/lib/node_modules/typescript/lib/lib.es6.d.ts","../../../../.nvm/versions/node/v22.16.0/lib/node_modules/typescript/lib/lib.es5.d.ts","../../../../.nvm/versions/node/v22.16.0/lib/node_modules/typescript/lib/lib.es2015.d.ts","../../../../.nvm/versions/node/v22.16.0/lib/node_modules/typescript/lib/lib.dom.d.ts","../../../../.nvm/versions/node/v22.16.0/lib/node_modules/typescript/lib/lib.dom.iterable.d.ts","../../../../.nvm/versions/node/v22.16.0/lib/node_modules/typescript/lib/lib.webworker.importscripts.d.ts","../../../../.nvm/versions/node/v22.16.0/lib/node_modules/typescript/lib/lib.scripthost.d.ts","../../../../.nvm/versions/node/v22.16.0/lib/node_modules/typescript/lib/lib.es2015.core.d.ts","../../../../.nvm/versions/node/v22.16.0/lib/node_modules/typescript/lib/lib.es2015.collection.d.ts","../../../../.nvm/versions/node/v22.16.0/lib/node_modules/typescript/lib/lib.es2015.generator.d.ts","../../../../.nvm/versions/node/v22.16.0/lib/node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../../../.nvm/versions/node/v22.16.0/lib/node_modules/typescript/lib/lib.es2015.promise.d.ts","../../../../.nvm/versions/node/v22.16.0/lib/node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../../../.nvm/versions/node/v22.16.0/lib/node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../../../.nvm/versions/node/v22.16.0/lib/node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../../../.nvm/versions/node/v22.16.0/lib/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../../../.nvm/versions/node/v22.16.0/lib/node_modules/typescript/lib/lib.decorators.d.ts","../../../../.nvm/versions/node/v22.16.0/lib/node_modules/typescript/lib/lib.decorators.legacy.d.ts","../node_modules/@qnc/type_utils/build/index.d.ts","../src/bound_stored_value.ts","../node_modules/superstruct/dist/error.d.ts","../node_modules/superstruct/dist/utils.d.ts","../node_modules/superstruct/dist/struct.d.ts","../node_modules/superstruct/dist/structs/coercions.d.ts","../node_modules/superstruct/dist/structs/refinements.d.ts","../node_modules/superstruct/dist/structs/types.d.ts","../node_modules/superstruct/dist/structs/utilities.d.ts","../node_modules/superstruct/dist/index.d.ts","../src/table_options.ts","../src/column_manager.ts","../src/column_resizing.ts","../src/watched_mutable_value.ts","../src/state_types.ts","../src/column_sorting.ts","../src/conditionally_wrapped_element.ts","../src/event_names.ts","../src/state_machine.ts","../node_modules/@types/mithril/index.d.ts","../src/renderer.ts","../node_modules/@qnc/drag_sorter/dist/npm/drag_sorter.d.ts","../src/mithril_view.ts","../src/create_mithril_app.ts","../intermediate/qnc_data_tables_inline_css.d.ts","../src/create_style.ts","../src/table_manager.ts","../src/custom_element.ts","../src/selection_fieldset_controller.ts","../src/index.ts","../src/optional_storage.ts","../src/overflow_class_manager.ts"],"fileIdsList":[[21,23,24,25,26,27],[21,22],[23],[22,23],[21,23],[19],[19,28,29],[19,33],[37,38,39,41],[43],[29,33,35,37,38,39,42,45],[29,39,44,46,47],[29,30,31,32,33,38,39,40],[38],[45,46],[19,20,29,30,32,33,34,36],[29,30,32],[36,37],[19,28]],"fileInfos":[{"version":"df039a67536fe2acc3affdcbfb645892f842db36fe599e8e652e2f0c640a90d1","impliedFormat":1},{"version":"69684132aeb9b5642cbcd9e22dff7818ff0ee1aa831728af0ecf97d3364d5546","affectsGlobalScope":true,"impliedFormat":1},{"version":"45b7ab580deca34ae9729e97c13cfd999df04416a79116c3bfb483804f85ded4","impliedFormat":1},{"version":"092c2bfe125ce69dbb1223c85d68d4d2397d7d8411867b5cc03cec902c233763","affectsGlobalScope":true,"impliedFormat":1},{"version":"07f073f19d67f74d732b1adea08e1dc66b1b58d77cb5b43931dee3d798a2fd53","affectsGlobalScope":true,"impliedFormat":1},{"version":"80e18897e5884b6723488d4f5652167e7bb5024f946743134ecc4aa4ee731f89","affectsGlobalScope":true,"impliedFormat":1},{"version":"cd034f499c6cdca722b60c04b5b1b78e058487a7085a8e0d6fb50809947ee573","affectsGlobalScope":true,"impliedFormat":1},{"version":"c57796738e7f83dbc4b8e65132f11a377649c00dd3eee333f672b8f0a6bea671","affectsGlobalScope":true,"impliedFormat":1},{"version":"dc2df20b1bcdc8c2d34af4926e2c3ab15ffe1160a63e58b7e09833f616efff44","affectsGlobalScope":true,"impliedFormat":1},{"version":"515d0b7b9bea2e31ea4ec968e9edd2c39d3eebf4a2d5cbd04e88639819ae3b71","affectsGlobalScope":true,"impliedFormat":1},{"version":"0559b1f683ac7505ae451f9a96ce4c3c92bdc71411651ca6ddb0e88baaaad6a3","affectsGlobalScope":true,"impliedFormat":1},{"version":"0dc1e7ceda9b8b9b455c3a2d67b0412feab00bd2f66656cd8850e8831b08b537","affectsGlobalScope":true,"impliedFormat":1},{"version":"ce691fb9e5c64efb9547083e4a34091bcbe5bdb41027e310ebba8f7d96a98671","affectsGlobalScope":true,"impliedFormat":1},{"version":"8d697a2a929a5fcb38b7a65594020fcef05ec1630804a33748829c5ff53640d0","affectsGlobalScope":true,"impliedFormat":1},{"version":"4ff2a353abf8a80ee399af572debb8faab2d33ad38c4b4474cff7f26e7653b8d","affectsGlobalScope":true,"impliedFormat":1},{"version":"936e80ad36a2ee83fc3caf008e7c4c5afe45b3cf3d5c24408f039c1d47bdc1df","affectsGlobalScope":true,"impliedFormat":1},{"version":"8e7f8264d0fb4c5339605a15daadb037bf238c10b654bb3eee14208f860a32ea","affectsGlobalScope":true,"impliedFormat":1},{"version":"782dec38049b92d4e85c1585fbea5474a219c6984a35b004963b00beb1aab538","affectsGlobalScope":true,"impliedFormat":1},{"version":"c3ac004344cd885a3e9900c9c791da896c6c19c2fea8812a3196694b18624058","impliedFormat":99},{"version":"b9655fec9e804d1a5c0c982f078c2727c1df6ade35c415f7134d04257d39b792","signature":"f50456435236fdfb4bdb108b048c001ad3f963ec72593f90f6a50c62dfa3d953","impliedFormat":99},{"version":"56e933722bc0b995aa96a7d023497871ce07d1500d9dae9e95875b3208b23169","impliedFormat":99},{"version":"ce84cd04b7ff2a0935c34d426d049a4738dc1d32300f713e8f674b2fea83520b","impliedFormat":99},{"version":"1431e40edac4e9251b18760a8b7e294a3be538d15ec1bac6e90ea84efbd75434","impliedFormat":99},{"version":"6cc836c7185e9763e11d373e166b1f6f523b3b2de800af03cc8db68583ce6c03","impliedFormat":99},{"version":"ce4399c8e23cd32b5e9c245b57bf86bcf07773ff0fce06435520afd9e36ce511","impliedFormat":99},{"version":"b11eab7b532862de69b97b30ff6f4ea177573f017dc9177fe463e20fa8e8f3af","impliedFormat":99},{"version":"e9340584b4b5ee347c65b1f6db1b83c6e77a68db39b078780abdc076711eb815","impliedFormat":99},{"version":"70d9e74d5210f57d00925ce312dd29c7ae3ef49b8d0a7f896fb28ed1578b17c3","impliedFormat":99},{"version":"f260b75cccb7aeb744c918383f0802439edd489456eaf19cb881596edd6a28df","signature":"3a1376592753ac25aa0e5be921f708c10c92dda0038d4c532898dcdde80669ea","impliedFormat":99},{"version":"fb269872ac1ad5670145cf17c5dc6e6a260a45851bad0a25626a0b99ee343178","signature":"c39f3f0217ba6ffb4f99d5bba8035d0a7053008349fbc40ddee4c7cf0aa4a305","impliedFormat":99},{"version":"3f282694019489510ad94603a83fef03d0c4f3eb87b0e9acea0bd10bf0e5fbad","signature":"08430a86a223b1c96c83759fce45b89c3f4eb3fad5789ac3b16abd84f676d801","impliedFormat":99},{"version":"0fa88d7f497c6be699c7f0c1a5df29d3c831b6224d142cb13c706bece49a7964","signature":"49c05a47e0d95561844f886a410b4f9b37e938b208caa410a4a953ef94231be3","impliedFormat":99},{"version":"cc97bcbb9491923679fcaddd7ea4693fb51240205d36687ee03e6d4349065383","signature":"317d9fe91e003b8bd007841a22a18ccd3638ff472ee11c62fa658a23b6e69949","impliedFormat":99},{"version":"37b3a75065dd4328ab07a74e437c9bf9db9596e8a4b95d5b97118d699eca8a36","signature":"19da0d94fde1c3d8b2d184b20c1dcc27773c9e36f8448733f958f57f7bd0ccef","impliedFormat":99},{"version":"9b73eafa6c6ce2e98429a7a875c1efe2f53f10e2980671b8f4759d97cd112992","signature":"1ef769db3b1a03d9d69e9b6c7ade7a713b44d8e7d7beaf43a0b0f376a3433d04","impliedFormat":99},{"version":"cdb540d13c6ff674fb817cd1731f1cd5e841b213486f3f039d81993be9bb7c83","signature":"a874d76d20f351b70787a2ce6bcfa50aa8e09a18a0f566fa7e50a116b60e3927","impliedFormat":99},{"version":"d738ec3d508305b8c751c3df13651c65b9e3bc7167b9a02eb6788e96586bd84e","signature":"ab39ff0da30c9b6089a0fb9c188b4297ce8d91694d37d8f578f09150f0fcbf1c","impliedFormat":99},{"version":"7c4f7cb8a662bd8b8eec4a712d2bfc40cb2efc3248292dcd2a7fa80d5935c85e","affectsGlobalScope":true,"impliedFormat":1},{"version":"c958694cb815759fdbb55f2c17c57014907cbe871b488dfe4afb95bbd1377f07","signature":"54198656fece9670c3f97e3e6b19d4835c8a8e1aac1c5d654dd7d08167d223ce","impliedFormat":99},{"version":"ebdfbfedbd3b85bb714d114c948f30e6ff0991a6162d3b01cd18a2d9c8aa0bb7","impliedFormat":99},{"version":"9d6ee454201e564f5719ef4c93ee2c0848e29e9d43b3b8fe3612b6f5e97b31b5","signature":"eec30d355fadbcd5517512b0eb4d6f254a0740c68f00cf5e8d92cf2c7395b2a3","impliedFormat":99},{"version":"1fe29a6585ba8e801b8039bc1b38a2906ae6c0992d228d10052ee2dce0734572","signature":"01d66077fab5a605168eda3d63521b9c18273ac6f24c338bcb8cadb5bea0429a","impliedFormat":99},{"version":"6112bc1341c6e1a3f072a934b0de0e26982a18cac9b97944f4cb86158ee58f00","impliedFormat":99},{"version":"c7fc1faa87da67e586529a23efa3619028f3410844031d37602d30e7ec455390","signature":"a32c781b7e8666951242aa77a3594db0bcc809435a3aa4fc753043c1d3d05359","impliedFormat":99},{"version":"eb398eee10130c7ae74100afb8e6767cc67511c5060bfdff9ba82d57717493a7","signature":"937e6463557ae49ed5ff5bcde2741a9a88e3bc4a60e00a3671277aa9200e8607","impliedFormat":99},{"version":"c43e6d54a9a425a1256e5756611c5f4c7c0180dda198712de6df78c8fb80764f","signature":"7b2fe70181cc14d801e496ebe57931d9a162e928d36d5e92d171ac9b0b1d5102","impliedFormat":99},{"version":"6f099c7a3ac41d6f7b048dc12fa8b0ca987d471cb18b5fabcce10304e11e42ed","signature":"98f165bc8a33ea7a96bcc6521bef9fa1e0f6cc6ad17eb22065817338cdd0384e","impliedFormat":99},{"version":"99ff6f4f0316abce4aba84f8ad1fa8fcda70bb634611167fd137e20f09be687a","impliedFormat":99},{"version":"639d09070bc5a1a6712e0dc0c9ca0c85713474b95142b6f04f20af07d1cb5e41","signature":"eb9159adc2c9f22f2ede632b4bdd2625b76b28a8907700c7701c4f28b5834530","impliedFormat":99},{"version":"e11c3816af66cef18033102beb8116f978648b99abbbd5a5af46cae507ed642d","signature":"0e1b5dda8ed10831fc1a25a7b6cee85cc6a3810d2afafda84712d485c4d60594","impliedFormat":99}],"root":[20,[29,37],39,41,42,[44,50]],"options":{"declaration":true,"esModuleInterop":true,"module":199,"noImplicitAny":true,"noUncheckedIndexedAccess":true,"outDir":"./","strict":true,"target":2},"referencedMap":[[28,1],[23,2],[24,3],[25,3],[26,4],[27,4],[22,5],[20,6],[30,7],[34,8],[42,9],[44,10],[46,11],[48,12],[41,13],[39,14],[47,15],[37,16],[33,17],[45,18],[29,19]],"version":"5.8.3"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ Intended to hold values which must be determined by the view layer (ie. which depend on rendered layout)
3
+ and which affect other aspects of the UI.
4
+
5
+ Example: the UI renders an element, then checks if that element has overflow, then wants to toggle a class on that element in response to the check.
6
+
7
+ Your state machine / "data store" should own/create the WatchedMutableValue. It can pass it directly to the view layer, which is free to update it.
8
+ */
9
+ export declare class WatchedMutableValue<T> {
10
+ private value;
11
+ private onchange;
12
+ constructor(value: T, onchange: () => void);
13
+ get(): T;
14
+ set(value: T): void;
15
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ Intended to hold values which must be determined by the view layer (ie. which depend on rendered layout)
3
+ and which affect other aspects of the UI.
4
+
5
+ Example: the UI renders an element, then checks if that element has overflow, then wants to toggle a class on that element in response to the check.
6
+
7
+ Your state machine / "data store" should own/create the WatchedMutableValue. It can pass it directly to the view layer, which is free to update it.
8
+ */
9
+ export class WatchedMutableValue {
10
+ constructor(value, onchange) {
11
+ this.value = value;
12
+ this.onchange = onchange;
13
+ }
14
+ get() {
15
+ return this.value;
16
+ }
17
+ set(value) {
18
+ const changed = this.value != value;
19
+ this.value = value;
20
+ if (changed)
21
+ this.onchange();
22
+ }
23
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ Intended to hold values which must be determined by the view layer (ie. which depend on rendered layout)
3
+ and which affect other aspects of the UI.
4
+
5
+ Example: the UI renders an element, then checks if that element has overflow, then wants to toggle a class on that element in response to the check.
6
+
7
+ Your state machine / "data store" should own/create the WatchedMutableValue. It can pass it directly to the view layer, which is free to update it.
8
+ */
9
+ export class WatchedMutableValue<T> {
10
+ constructor(
11
+ private value: T,
12
+ private onchange: () => void,
13
+ ) {}
14
+
15
+ get() {
16
+ return this.value;
17
+ }
18
+ set(value: T) {
19
+ const changed = this.value != value;
20
+ this.value = value;
21
+ if (changed) this.onchange();
22
+ }
23
+ }
package/package.json CHANGED
@@ -1,13 +1,16 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@qnc/qnc_data_tables",
4
- "files": ["dist/*"],
5
- "version": "1.0.4",
4
+ "files": [
5
+ "dist/*",
6
+ "README.md"
7
+ ],
8
+ "version": "1.0.6-a",
6
9
  "description": "Work-in-progress",
7
- "main": "dist/qnc_data_tables.js",
10
+ "main": "dist/index.js",
8
11
  "scripts": {
9
12
  "watch_css": "when-changed src/qnc_data_tables.css -c \"node inline_css.js\"",
10
- "watch_typescript": "tsc -w",
13
+ "watch_typescript": "tsc -w --sourceMap",
11
14
  "start": "node inline_css.js && npm-run-all -pr watch_css watch_typescript"
12
15
  },
13
16
  "type": "module",
@@ -19,8 +22,12 @@
19
22
  "npm-run-all": "^4.1.5"
20
23
  },
21
24
  "peerDependencies": {
22
- "@types/mithril": "^2.2.7",
23
25
  "@qnc/drag_sorter": "^0.1.0",
26
+ "@qnc/type_utils": "^1.2.0",
27
+ "@types/mithril": "^2.2.7",
24
28
  "mithril": "^2.3.0"
29
+ },
30
+ "dependencies": {
31
+ "superstruct": "^2.0.2"
25
32
  }
26
33
  }
@@ -1,57 +0,0 @@
1
- import m from "mithril";
2
- /**
3
- * Create a <style> element that users should inject into their document somewhere.
4
- */
5
- export declare function make_style(): HTMLStyleElement;
6
- export declare function require_array(value: unknown): unknown[];
7
- export declare function require_array_of<T>(value: unknown, element_validator: (value: unknown) => T): T[];
8
- export type HeaderRendererArgs = {
9
- text: string;
10
- help_text: string | null | m.Children;
11
- sortable: boolean;
12
- sorted: boolean;
13
- sorted_reverse: boolean;
14
- sort: () => void;
15
- sort_reverse: () => void;
16
- };
17
- export type FormRendererArgs = {
18
- result_count_loading: boolean;
19
- result_count: null | number;
20
- /** Indicates result set is truncated because it's too big */
21
- results_limited: boolean;
22
- /** Will be set when results_limited is set. Indicates max number of rows we allow accessing. */
23
- results_limited_to: null | number;
24
- table_data_loading: boolean;
25
- table: m.Children;
26
- current_page: number;
27
- total_pages: number;
28
- set_page: (page_number: number) => void;
29
- page_size: number;
30
- set_page_size: (row_count: number) => void;
31
- editable_columns_list: m.Children;
32
- /** how many rows are selected */
33
- selected_row_count: number;
34
- /** true iff all results (on all pages) are selected */
35
- all_results_selected: boolean;
36
- /** true iff all results on the current page are selected */
37
- entire_page_selected: boolean;
38
- selection_buttons: m.Children[];
39
- /** select all results on the current page */
40
- select_page: () => void;
41
- /** deselect all results on the current page */
42
- clear_page: () => void;
43
- /** select all of the currently included results on all pages */
44
- select_table: () => void;
45
- /** deselect all of the currently included results on all pages */
46
- clear_table: () => void;
47
- /** clear all rows from the selection, whether they are matched by current filters or not */
48
- clear_selection: () => void;
49
- };
50
- type Renderer = {
51
- help_text: (text: string) => m.Children;
52
- header: (args: HeaderRendererArgs) => m.Children;
53
- form_content: (args: FormRendererArgs) => m.Children;
54
- };
55
- export declare function register_renderer(name: string, renderer: Partial<Renderer>): void;
56
- export declare function define(tag_name: string): void;
57
- export {};