@k2b/ui 0.65.0 → 0.66.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/README.md +47 -0
- package/dist/browser/v2/button.js +180 -0
- package/dist/browser/v2/button.js.map +1 -0
- package/dist/browser/v2/components.js +763 -0
- package/dist/browser/v2/components.js.map +1 -0
- package/dist/browser/v2/content.js +1107 -0
- package/dist/browser/v2/content.js.map +1 -0
- package/dist/browser/v2/controls.js +568 -0
- package/dist/browser/v2/controls.js.map +1 -0
- package/dist/browser/v2/describe.js +397 -0
- package/dist/browser/v2/describe.js.map +1 -0
- package/dist/browser/v2/index.js +25 -0
- package/dist/browser/v2/index.js.map +1 -0
- package/dist/browser/v2/layout.js +578 -0
- package/dist/browser/v2/layout.js.map +1 -0
- package/dist/browser/v2/link.js +9 -0
- package/dist/browser/v2/link.js.map +1 -0
- package/dist/browser/v2/marks.js +211 -0
- package/dist/browser/v2/marks.js.map +1 -0
- package/dist/browser/v2/states.js +180 -0
- package/dist/browser/v2/states.js.map +1 -0
- package/dist/browser/v2/structure.js +328 -0
- package/dist/browser/v2/structure.js.map +1 -0
- package/dist/browser/v2/testing/index.js +23 -0
- package/dist/browser/v2/testing/index.js.map +1 -0
- package/dist/browser/v2/testing/measure-v2-layout.js +762 -0
- package/dist/browser/v2/testing/measure-v2-layout.js.map +1 -0
- package/dist/browser/v2/testing/settled.js +52 -0
- package/dist/browser/v2/testing/settled.js.map +1 -0
- package/dist/browser/v2/tokens.js +83 -0
- package/dist/browser/v2/tokens.js.map +1 -0
- package/dist/browser/v2/types.js +24 -0
- package/dist/browser/v2/types.js.map +1 -0
- package/dist/ssr/v2/button.js +177 -0
- package/dist/ssr/v2/button.js.map +1 -0
- package/dist/ssr/v2/components.js +518 -0
- package/dist/ssr/v2/components.js.map +1 -0
- package/dist/ssr/v2/content.js +727 -0
- package/dist/ssr/v2/content.js.map +1 -0
- package/dist/ssr/v2/controls.js +268 -0
- package/dist/ssr/v2/controls.js.map +1 -0
- package/dist/ssr/v2/describe.js +397 -0
- package/dist/ssr/v2/describe.js.map +1 -0
- package/dist/ssr/v2/index.js +25 -0
- package/dist/ssr/v2/index.js.map +1 -0
- package/dist/ssr/v2/layout.js +377 -0
- package/dist/ssr/v2/layout.js.map +1 -0
- package/dist/ssr/v2/link.js +9 -0
- package/dist/ssr/v2/link.js.map +1 -0
- package/dist/ssr/v2/marks.js +126 -0
- package/dist/ssr/v2/marks.js.map +1 -0
- package/dist/ssr/v2/states.js +128 -0
- package/dist/ssr/v2/states.js.map +1 -0
- package/dist/ssr/v2/structure.js +229 -0
- package/dist/ssr/v2/structure.js.map +1 -0
- package/dist/ssr/v2/testing/index.js +23 -0
- package/dist/ssr/v2/testing/index.js.map +1 -0
- package/dist/ssr/v2/testing/measure-v2-layout.js +762 -0
- package/dist/ssr/v2/testing/measure-v2-layout.js.map +1 -0
- package/dist/ssr/v2/testing/settled.js +52 -0
- package/dist/ssr/v2/testing/settled.js.map +1 -0
- package/dist/ssr/v2/tokens.js +83 -0
- package/dist/ssr/v2/tokens.js.map +1 -0
- package/dist/ssr/v2/types.js +24 -0
- package/dist/ssr/v2/types.js.map +1 -0
- package/dist/types/v2/button.d.ts +54 -0
- package/dist/types/v2/components.d.ts +173 -0
- package/dist/types/v2/content.d.ts +233 -0
- package/dist/types/v2/controls.d.ts +118 -0
- package/dist/types/v2/describe.d.ts +18 -0
- package/dist/types/v2/index.d.ts +22 -0
- package/dist/types/v2/layout.d.ts +124 -0
- package/dist/types/v2/link.d.ts +7 -0
- package/dist/types/v2/marks.d.ts +90 -0
- package/dist/types/v2/states.d.ts +45 -0
- package/dist/types/v2/structure.d.ts +47 -0
- package/dist/types/v2/testing/index.d.ts +16 -0
- package/dist/types/v2/testing/measure-v2-layout.d.ts +99 -0
- package/dist/types/v2/testing/settled.d.ts +13 -0
- package/dist/types/v2/tokens.d.ts +77 -0
- package/dist/types/v2/types.d.ts +44 -0
- package/dist/v2.css +3072 -0
- package/package.json +23 -4
- package/skills/k2b-ui/SKILL.md +201 -0
- package/skills/k2b-ui/images/form-1440.png +0 -0
- package/skills/k2b-ui/images/form-390.png +0 -0
- package/skills/k2b-ui/images/list-detail-1440.png +0 -0
- package/skills/k2b-ui/images/list-detail-390.png +0 -0
- package/skills/k2b-ui/images/mail-1440.png +0 -0
- package/skills/k2b-ui/images/mail-390.png +0 -0
- package/skills/k2b-ui/images/record-1440.png +0 -0
- package/skills/k2b-ui/images/record-390.png +0 -0
- package/skills/k2b-ui/images/record-groups-1440.png +0 -0
- package/skills/k2b-ui/images/record-groups-390.png +0 -0
- package/skills/k2b-ui/images/table-1440.png +0 -0
- package/skills/k2b-ui/images/table-390.png +0 -0
- package/skills/k2b-ui/recipes/form.tsx +54 -0
- package/skills/k2b-ui/recipes/list-detail.tsx +105 -0
- package/skills/k2b-ui/recipes/mail.tsx +193 -0
- package/skills/k2b-ui/recipes/record-groups.tsx +115 -0
- package/skills/k2b-ui/recipes/record.tsx +163 -0
- package/skills/k2b-ui/recipes/table.tsx +68 -0
- package/skills/k2b-ui/references/mistakes.md +162 -0
- package/skills/k2b-ui/references/primitives.md +310 -0
- package/skills/k2b-ui/references/recipes.md +101 -0
- package/skills/k2b-ui/references/seeing.md +94 -0
|
@@ -0,0 +1,1107 @@
|
|
|
1
|
+
import { template as _$template } from "solid-js/web";
|
|
2
|
+
import { delegateEvents as _$delegateEvents } from "solid-js/web";
|
|
3
|
+
import { addEventListener as _$addEventListener } from "solid-js/web";
|
|
4
|
+
import { mergeProps as _$mergeProps } from "solid-js/web";
|
|
5
|
+
import { style as _$style } from "solid-js/web";
|
|
6
|
+
import { runHydrationEvents as _$runHydrationEvents } from "solid-js/web";
|
|
7
|
+
import { use as _$use } from "solid-js/web";
|
|
8
|
+
import { getNextMarker as _$getNextMarker } from "solid-js/web";
|
|
9
|
+
import { setAttribute as _$setAttribute } from "solid-js/web";
|
|
10
|
+
import { insert as _$insert } from "solid-js/web";
|
|
11
|
+
import { setProperty as _$setProperty } from "solid-js/web";
|
|
12
|
+
import { effect as _$effect } from "solid-js/web";
|
|
13
|
+
import { getNextElement as _$getNextElement } from "solid-js/web";
|
|
14
|
+
import { createComponent as _$createComponent } from "solid-js/web";
|
|
15
|
+
import { memo as _$memo } from "solid-js/web";
|
|
16
|
+
var _tmpl$ = /*#__PURE__*/_$template(`<div class=k2-prose data-k2-part=Prose data-k2-prose>`),
|
|
17
|
+
_tmpl$2 = /*#__PURE__*/_$template(`<div class=k2-inline data-k2-part=Inline>`),
|
|
18
|
+
_tmpl$3 = /*#__PURE__*/_$template(`<dl class=k2-facts>`),
|
|
19
|
+
_tmpl$4 = /*#__PURE__*/_$template(`<small>`),
|
|
20
|
+
_tmpl$5 = /*#__PURE__*/_$template(`<div class=k2-fact-pair><dt></dt><dd><span class=k2-fact-value><!$><!/><!$><!/></span><!$><!/>`),
|
|
21
|
+
_tmpl$6 = /*#__PURE__*/_$template(`<div class=k2-facts-line data-k2-part=Facts><!$><!/><div class=k2-facts-end>`),
|
|
22
|
+
_tmpl$7 = /*#__PURE__*/_$template(`<div class=k2-list data-k2-part=List role=list>`),
|
|
23
|
+
_tmpl$8 = /*#__PURE__*/_$template(`<button type=button class=k2-row-open>`),
|
|
24
|
+
_tmpl$9 = /*#__PURE__*/_$template(`<span class=k2-row-meta>`),
|
|
25
|
+
_tmpl$0 = /*#__PURE__*/_$template(`<span class=k2-row-l2>`),
|
|
26
|
+
_tmpl$1 = /*#__PURE__*/_$template(`<span class=k2-row-l3>`),
|
|
27
|
+
_tmpl$10 = /*#__PURE__*/_$template(`<span class=k2-row-time>`),
|
|
28
|
+
_tmpl$11 = /*#__PURE__*/_$template(`<span class=k2-row-end><!$><!/><!$><!/>`),
|
|
29
|
+
_tmpl$12 = /*#__PURE__*/_$template(`<span class=k2-row-marks>`),
|
|
30
|
+
_tmpl$13 = /*#__PURE__*/_$template(`<div class=k2-row data-k2-part=Row><!$><!/><span class=k2-row-lead></span><span class=k2-row-l1><span class=k2-row-title></span><!$><!/></span><!$><!/><!$><!/><!$><!/><!$><!/><!$><!/>`),
|
|
31
|
+
_tmpl$14 = /*#__PURE__*/_$template(`<span class=k2-cell-line>`),
|
|
32
|
+
_tmpl$15 = /*#__PURE__*/_$template(`<col style=width:44px>`),
|
|
33
|
+
_tmpl$16 = /*#__PURE__*/_$template(`<colgroup><!$><!/><!$><!/>`),
|
|
34
|
+
_tmpl$17 = /*#__PURE__*/_$template(`<div class=k2-table-scroll data-k2-part=Table><!$><!/><table class=k2-table><!$><!/><thead><tr><!$><!/><!$><!/></tr></thead><tbody><!$><!/><!$><!/>`),
|
|
35
|
+
_tmpl$18 = /*#__PURE__*/_$template(`<col>`),
|
|
36
|
+
_tmpl$19 = /*#__PURE__*/_$template(`<th scope=col data-select>`),
|
|
37
|
+
_tmpl$20 = /*#__PURE__*/_$template(`<span class=k2-cgrip role=separator aria-orientation=vertical tabindex=0>`),
|
|
38
|
+
_tmpl$21 = /*#__PURE__*/_$template(`<th scope=col><!$><!/><!$><!/><!$><!/>`),
|
|
39
|
+
_tmpl$22 = /*#__PURE__*/_$template(`<td data-select><span class=k2-skel data-box>`),
|
|
40
|
+
_tmpl$23 = /*#__PURE__*/_$template(`<tr data-loading aria-hidden=true><!$><!/><!$><!/>`),
|
|
41
|
+
_tmpl$24 = /*#__PURE__*/_$template(`<span class=k2-cell-line data-second><span class=k2-skel>`),
|
|
42
|
+
_tmpl$25 = /*#__PURE__*/_$template(`<td><span class=k2-cell-line><span class=k2-skel></span></span><!$><!/>`),
|
|
43
|
+
_tmpl$26 = /*#__PURE__*/_$template(`<span class=k2-group-row-meta>`),
|
|
44
|
+
_tmpl$27 = /*#__PURE__*/_$template(`<tr data-group><td><span class=k2-group-row><!$><!/><!$><!/>`),
|
|
45
|
+
_tmpl$28 = /*#__PURE__*/_$template(`<tr><!$><!/><!$><!/>`),
|
|
46
|
+
_tmpl$29 = /*#__PURE__*/_$template(`<td data-select>`),
|
|
47
|
+
_tmpl$30 = /*#__PURE__*/_$template(`<td>`),
|
|
48
|
+
_tmpl$31 = /*#__PURE__*/_$template(`<div class=k2-table-phone>`),
|
|
49
|
+
_tmpl$32 = /*#__PURE__*/_$template(`<span class=k2-t-meta>`),
|
|
50
|
+
_tmpl$33 = /*#__PURE__*/_$template(`<div class=k2-bar role=presentation><div class=k2-bar-start><!$><!/><!$><!/>`);
|
|
51
|
+
import { Link } from "@k2b/ssr/nav";
|
|
52
|
+
import { createContext, createMemo, createUniqueId, For, onCleanup, onMount, children as resolveChildren, Show, useContext } from "solid-js";
|
|
53
|
+
import { Dynamic } from "solid-js/web";
|
|
54
|
+
import { renderSafeMarkdown } from "../content/MarkdownView";
|
|
55
|
+
import { useLocale } from "../intl/locale";
|
|
56
|
+
import { ActionButton, CopyButton } from "./button";
|
|
57
|
+
import { MarkCheck } from "./controls";
|
|
58
|
+
import { Avatar, custom, Dot, Icon } from "./marks";
|
|
59
|
+
import { Empty, Loading, LoadingStatus } from "./states";
|
|
60
|
+
|
|
61
|
+
// ── Text ─────────────────────────────────────────────────────────────────────────────────────────────────────────
|
|
62
|
+
|
|
63
|
+
const typeClass = {
|
|
64
|
+
meta: "k2-t-meta",
|
|
65
|
+
row: "k2-t-row",
|
|
66
|
+
body: "k2-t-body",
|
|
67
|
+
lead: "k2-t-lead"
|
|
68
|
+
};
|
|
69
|
+
const weightClass = {
|
|
70
|
+
medium: "k2-medium",
|
|
71
|
+
strong: "k2-strong"
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Text in one of the four type roles. Standing in the flow of a column (a pane, a band, a section, a group) it is a
|
|
76
|
+
* block that carries the text edge itself; anywhere else (a bar, a row, a sentence) it runs inline, and in a bar it is
|
|
77
|
+
* cut to one line with "…". The stylesheet decides by place, so text passed as data behaves the same.
|
|
78
|
+
*/
|
|
79
|
+
export const Text = props => _$createComponent(Dynamic, {
|
|
80
|
+
get component() {
|
|
81
|
+
return props.href ? "a" : "span";
|
|
82
|
+
},
|
|
83
|
+
get href() {
|
|
84
|
+
return props.href;
|
|
85
|
+
},
|
|
86
|
+
get ["class"]() {
|
|
87
|
+
return `k2-text${props.type ? ` ${typeClass[props.type]}` : ""}${props.weight ? ` ${weightClass[props.weight]}` : ""}${props.muted ? " k2-muted" : ""}${props.href ? " k2-link" : ""}`;
|
|
88
|
+
},
|
|
89
|
+
"data-k2-part": "Text",
|
|
90
|
+
get ["data-type"]() {
|
|
91
|
+
return props.type;
|
|
92
|
+
},
|
|
93
|
+
get ["data-tone"]() {
|
|
94
|
+
return props.tone;
|
|
95
|
+
},
|
|
96
|
+
get children() {
|
|
97
|
+
return props.children;
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
/** The links reading text may carry; any other target shows as text. */
|
|
102
|
+
const proseLinks = ["https:", "http:", "mailto:"];
|
|
103
|
+
/** Reading text: 14/22, a measure of 720 px, headings at 16 and 18. It carries the text edge itself. */
|
|
104
|
+
export const Prose = props => {
|
|
105
|
+
const locale = useLocale();
|
|
106
|
+
return _$createComponent(Show, {
|
|
107
|
+
get when() {
|
|
108
|
+
return props.markdown !== undefined;
|
|
109
|
+
},
|
|
110
|
+
get fallback() {
|
|
111
|
+
return (() => {
|
|
112
|
+
var _el$2 = _$getNextElement(_tmpl$);
|
|
113
|
+
_$insert(_el$2, () => props.children);
|
|
114
|
+
return _el$2;
|
|
115
|
+
})();
|
|
116
|
+
},
|
|
117
|
+
get children() {
|
|
118
|
+
var _el$ = _$getNextElement(_tmpl$);
|
|
119
|
+
_$effect(() => _$setProperty(_el$, "innerHTML", renderSafeMarkdown(props.markdown ?? "", {
|
|
120
|
+
locale: locale(),
|
|
121
|
+
allowImages: false,
|
|
122
|
+
linkProtocols: proseLinks
|
|
123
|
+
})));
|
|
124
|
+
return _el$;
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
};
|
|
128
|
+
/**
|
|
129
|
+
* One line of things with the one fixed gap of 8 px. In a column it carries the text edge itself. In a column narrower
|
|
130
|
+
* than 480 px it wraps onto more lines instead of cutting a thing; in a bar it flows together with the bar's end.
|
|
131
|
+
*/
|
|
132
|
+
export const Inline = props => (() => {
|
|
133
|
+
var _el$3 = _$getNextElement(_tmpl$2);
|
|
134
|
+
_$insert(_el$3, () => props.children);
|
|
135
|
+
return _el$3;
|
|
136
|
+
})();
|
|
137
|
+
|
|
138
|
+
// ── Facts ────────────────────────────────────────────────────────────────────────────────────────────────────────
|
|
139
|
+
|
|
140
|
+
/** Values with their labels: label 12 quiet, value 13, 32 px a row, copy at the value. */
|
|
141
|
+
export const Facts = props => {
|
|
142
|
+
// A list of pairs (dt, dd); a copy button stands inside its value, the end of an inline line beside the list.
|
|
143
|
+
const list = part => (() => {
|
|
144
|
+
var _el$4 = _$getNextElement(_tmpl$3);
|
|
145
|
+
_$setAttribute(_el$4, "data-k2-part", part);
|
|
146
|
+
_$insert(_el$4, _$createComponent(For, {
|
|
147
|
+
get each() {
|
|
148
|
+
return props.items;
|
|
149
|
+
},
|
|
150
|
+
children: item => (() => {
|
|
151
|
+
var _el$5 = _$getNextElement(_tmpl$5),
|
|
152
|
+
_el$6 = _el$5.firstChild,
|
|
153
|
+
_el$7 = _el$6.nextSibling,
|
|
154
|
+
_el$8 = _el$7.firstChild,
|
|
155
|
+
_el$0 = _el$8.firstChild,
|
|
156
|
+
[_el$1, _co$] = _$getNextMarker(_el$0.nextSibling),
|
|
157
|
+
_el$10 = _el$1.nextSibling,
|
|
158
|
+
[_el$11, _co$2] = _$getNextMarker(_el$10.nextSibling),
|
|
159
|
+
_el$12 = _el$8.nextSibling,
|
|
160
|
+
[_el$13, _co$3] = _$getNextMarker(_el$12.nextSibling);
|
|
161
|
+
_$insert(_el$6, () => item.label);
|
|
162
|
+
_$insert(_el$8, () => item.value, _el$1, _co$);
|
|
163
|
+
_$insert(_el$8, _$createComponent(Show, {
|
|
164
|
+
get when() {
|
|
165
|
+
return item.hint;
|
|
166
|
+
},
|
|
167
|
+
get children() {
|
|
168
|
+
var _el$9 = _$getNextElement(_tmpl$4);
|
|
169
|
+
_$insert(_el$9, () => item.hint);
|
|
170
|
+
return _el$9;
|
|
171
|
+
}
|
|
172
|
+
}), _el$11, _co$2);
|
|
173
|
+
_$insert(_el$7, _$createComponent(Show, {
|
|
174
|
+
get when() {
|
|
175
|
+
return _$memo(() => !!!props.inline)() && item.copy;
|
|
176
|
+
},
|
|
177
|
+
children: value => _$createComponent(CopyButton, {
|
|
178
|
+
get label() {
|
|
179
|
+
return item.label;
|
|
180
|
+
},
|
|
181
|
+
get value() {
|
|
182
|
+
return value();
|
|
183
|
+
}
|
|
184
|
+
})
|
|
185
|
+
}), _el$13, _co$3);
|
|
186
|
+
return _el$5;
|
|
187
|
+
})()
|
|
188
|
+
}));
|
|
189
|
+
_$effect(() => _$setAttribute(_el$4, "data-inline", props.inline ? "" : undefined));
|
|
190
|
+
return _el$4;
|
|
191
|
+
})();
|
|
192
|
+
const end = resolveChildren(() => props.end);
|
|
193
|
+
return _$createComponent(Show, {
|
|
194
|
+
get when() {
|
|
195
|
+
return _$memo(() => !!props.inline)() && end() !== undefined;
|
|
196
|
+
},
|
|
197
|
+
get fallback() {
|
|
198
|
+
return list("Facts");
|
|
199
|
+
},
|
|
200
|
+
get children() {
|
|
201
|
+
var _el$14 = _$getNextElement(_tmpl$6),
|
|
202
|
+
_el$16 = _el$14.firstChild,
|
|
203
|
+
[_el$17, _co$4] = _$getNextMarker(_el$16.nextSibling),
|
|
204
|
+
_el$15 = _el$17.nextSibling;
|
|
205
|
+
_$insert(_el$14, list, _el$17, _co$4);
|
|
206
|
+
_$insert(_el$15, end);
|
|
207
|
+
return _el$14;
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
// ── Row and List ─────────────────────────────────────────────────────────────────────────────────────────────────
|
|
213
|
+
|
|
214
|
+
const ListContext = createContext(false);
|
|
215
|
+
/**
|
|
216
|
+
* Rows that come or go above the place someone works on (a new mail on top) leave that place where it was: the
|
|
217
|
+
* focused row, else the first visible one, keeps its distance to the top of the column. When that row goes itself,
|
|
218
|
+
* the row after it takes its place, else the row before it keeps its own. Browsers with CSS scroll anchoring already
|
|
219
|
+
* hold the place, so nothing moves twice there; Safari ships none. At the very top nothing is held, so a new row shows
|
|
220
|
+
* up there. (As v1's `MailConversationList`.)
|
|
221
|
+
*/
|
|
222
|
+
const keepPlace = list => {
|
|
223
|
+
const scroller = list.closest(".k2-scroll");
|
|
224
|
+
if (!scroller || typeof MutationObserver === "undefined") return;
|
|
225
|
+
let held = null;
|
|
226
|
+
const isRow = node => node instanceof HTMLElement && node.matches(".k2-row");
|
|
227
|
+
const hold = () => {
|
|
228
|
+
const view = scroller.getBoundingClientRect();
|
|
229
|
+
const placeOf = row => ({
|
|
230
|
+
row,
|
|
231
|
+
top: row.getBoundingClientRect().top - view.top
|
|
232
|
+
});
|
|
233
|
+
const visible = row => {
|
|
234
|
+
const box = row.getBoundingClientRect();
|
|
235
|
+
return box.bottom > view.top && box.top < view.bottom;
|
|
236
|
+
};
|
|
237
|
+
const focused = document.activeElement?.closest(".k2-row");
|
|
238
|
+
const row = scroller.scrollTop <= 0 ? undefined : focused && focused.parentElement === list && visible(focused) ? focused : Array.from(list.children).find(each => isRow(each) && each.getBoundingClientRect().top >= view.top);
|
|
239
|
+
if (!row || !isRow(row)) {
|
|
240
|
+
held = null;
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
const next = row.nextElementSibling;
|
|
244
|
+
const previous = row.previousElementSibling;
|
|
245
|
+
held = {
|
|
246
|
+
place: placeOf(row),
|
|
247
|
+
// the row after it would take its place, the row before it keeps its own
|
|
248
|
+
next: isRow(next) ? {
|
|
249
|
+
row: next,
|
|
250
|
+
top: placeOf(row).top
|
|
251
|
+
} : undefined,
|
|
252
|
+
previous: isRow(previous) ? placeOf(previous) : undefined
|
|
253
|
+
};
|
|
254
|
+
};
|
|
255
|
+
const changed = records => {
|
|
256
|
+
if (!records.some(record => [...record.addedNodes, ...record.removedNodes].some(isRow))) return;
|
|
257
|
+
const place = [held?.place, held?.next, held?.previous].find(each => each?.row.isConnected);
|
|
258
|
+
if (place) {
|
|
259
|
+
const moved = place.row.getBoundingClientRect().top - scroller.getBoundingClientRect().top - place.top;
|
|
260
|
+
if (Math.abs(moved) >= 1) scroller.scrollTop += moved;
|
|
261
|
+
}
|
|
262
|
+
hold();
|
|
263
|
+
};
|
|
264
|
+
const rows = new MutationObserver(changed);
|
|
265
|
+
rows.observe(list, {
|
|
266
|
+
childList: true
|
|
267
|
+
});
|
|
268
|
+
scroller.addEventListener("scroll", hold, {
|
|
269
|
+
passive: true
|
|
270
|
+
});
|
|
271
|
+
scroller.addEventListener("focusin", hold);
|
|
272
|
+
hold();
|
|
273
|
+
onCleanup(() => {
|
|
274
|
+
rows.disconnect();
|
|
275
|
+
scroller.removeEventListener("scroll", hold);
|
|
276
|
+
scroller.removeEventListener("focusin", hold);
|
|
277
|
+
});
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
/** Rows one under the other. (Selection, keyboard and drag come with the behaviour layer.) */
|
|
281
|
+
export const List = props => {
|
|
282
|
+
let list;
|
|
283
|
+
onMount(() => {
|
|
284
|
+
if (list) keepPlace(list);
|
|
285
|
+
});
|
|
286
|
+
return (() => {
|
|
287
|
+
var _el$18 = _$getNextElement(_tmpl$7);
|
|
288
|
+
var _ref$ = list;
|
|
289
|
+
typeof _ref$ === "function" ? _$use(_ref$, _el$18) : list = _el$18;
|
|
290
|
+
_$insert(_el$18, _$createComponent(ListContext.Provider, {
|
|
291
|
+
value: true,
|
|
292
|
+
get children() {
|
|
293
|
+
return props.children;
|
|
294
|
+
}
|
|
295
|
+
}));
|
|
296
|
+
_$effect(() => _$setAttribute(_el$18, "aria-label", props.label));
|
|
297
|
+
return _el$18;
|
|
298
|
+
})();
|
|
299
|
+
};
|
|
300
|
+
/**
|
|
301
|
+
* What opens an entry: the title becomes a link or a button, stretched over the whole entry. It is never the entry
|
|
302
|
+
* itself, so buttons and links inside the entry stay buttons and links of their own (no control inside a control).
|
|
303
|
+
*/
|
|
304
|
+
export const RowOpen = props => _$createComponent(Show, {
|
|
305
|
+
get when() {
|
|
306
|
+
return props.href !== undefined || props.onOpen;
|
|
307
|
+
},
|
|
308
|
+
get fallback() {
|
|
309
|
+
return props.children;
|
|
310
|
+
},
|
|
311
|
+
get children() {
|
|
312
|
+
return _$createComponent(Show, {
|
|
313
|
+
get when() {
|
|
314
|
+
return props.href !== undefined;
|
|
315
|
+
},
|
|
316
|
+
get fallback() {
|
|
317
|
+
return (() => {
|
|
318
|
+
var _el$19 = _$getNextElement(_tmpl$8);
|
|
319
|
+
_el$19.$$click = () => props.onOpen?.();
|
|
320
|
+
_$insert(_el$19, () => props.children);
|
|
321
|
+
_$runHydrationEvents();
|
|
322
|
+
return _el$19;
|
|
323
|
+
})();
|
|
324
|
+
},
|
|
325
|
+
get children() {
|
|
326
|
+
return _$createComponent(Link, {
|
|
327
|
+
"class": "k2-row-open",
|
|
328
|
+
get href() {
|
|
329
|
+
return props.href ?? "";
|
|
330
|
+
},
|
|
331
|
+
get onNavigate() {
|
|
332
|
+
return props.onNavigate;
|
|
333
|
+
},
|
|
334
|
+
onClick: () => props.onOpen?.(),
|
|
335
|
+
get children() {
|
|
336
|
+
return props.children;
|
|
337
|
+
}
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
});
|
|
343
|
+
|
|
344
|
+
/** One entry: from column edge to column edge, square, also when it opens something. */
|
|
345
|
+
export const Row = props => {
|
|
346
|
+
const inList = useContext(ListContext);
|
|
347
|
+
// Parts passed as JSX are made once and read from here: reading a prop again would make its JSX again.
|
|
348
|
+
const text = createMemo(() => props.lines);
|
|
349
|
+
const lines = () => text().length;
|
|
350
|
+
const meta = resolveChildren(() => props.meta);
|
|
351
|
+
const time = resolveChildren(() => props.time);
|
|
352
|
+
const end = resolveChildren(() => props.end);
|
|
353
|
+
const marks = resolveChildren(() => props.marks);
|
|
354
|
+
const title = createUniqueId();
|
|
355
|
+
return (() => {
|
|
356
|
+
var _el$20 = _$getNextElement(_tmpl$13),
|
|
357
|
+
_el$36 = _el$20.firstChild,
|
|
358
|
+
[_el$37, _co$8] = _$getNextMarker(_el$36.nextSibling),
|
|
359
|
+
_el$21 = _el$37.nextSibling,
|
|
360
|
+
_el$22 = _el$21.nextSibling,
|
|
361
|
+
_el$23 = _el$22.firstChild,
|
|
362
|
+
_el$25 = _el$23.nextSibling,
|
|
363
|
+
[_el$26, _co$5] = _$getNextMarker(_el$25.nextSibling),
|
|
364
|
+
_el$38 = _el$22.nextSibling,
|
|
365
|
+
[_el$39, _co$9] = _$getNextMarker(_el$38.nextSibling),
|
|
366
|
+
_el$40 = _el$39.nextSibling,
|
|
367
|
+
[_el$41, _co$0] = _$getNextMarker(_el$40.nextSibling),
|
|
368
|
+
_el$42 = _el$41.nextSibling,
|
|
369
|
+
[_el$43, _co$1] = _$getNextMarker(_el$42.nextSibling),
|
|
370
|
+
_el$44 = _el$43.nextSibling,
|
|
371
|
+
[_el$45, _co$10] = _$getNextMarker(_el$44.nextSibling),
|
|
372
|
+
_el$46 = _el$45.nextSibling,
|
|
373
|
+
[_el$47, _co$11] = _$getNextMarker(_el$46.nextSibling);
|
|
374
|
+
_$setAttribute(_el$20, "role", inList ? "listitem" : undefined);
|
|
375
|
+
_$insert(_el$20, _$createComponent(Show, {
|
|
376
|
+
get when() {
|
|
377
|
+
return props.href !== undefined || props.onOpen;
|
|
378
|
+
},
|
|
379
|
+
get children() {
|
|
380
|
+
return _$createComponent(Show, {
|
|
381
|
+
get when() {
|
|
382
|
+
return props.href !== undefined;
|
|
383
|
+
},
|
|
384
|
+
get fallback() {
|
|
385
|
+
return (() => {
|
|
386
|
+
var _el$48 = _$getNextElement(_tmpl$8);
|
|
387
|
+
_el$48.$$click = () => props.onOpen?.();
|
|
388
|
+
_$setAttribute(_el$48, "aria-labelledby", title);
|
|
389
|
+
_$runHydrationEvents();
|
|
390
|
+
return _el$48;
|
|
391
|
+
})();
|
|
392
|
+
},
|
|
393
|
+
get children() {
|
|
394
|
+
return _$createComponent(Link, {
|
|
395
|
+
"class": "k2-row-open",
|
|
396
|
+
get href() {
|
|
397
|
+
return props.href ?? "";
|
|
398
|
+
},
|
|
399
|
+
"aria-labelledby": title,
|
|
400
|
+
get onNavigate() {
|
|
401
|
+
return props.onNavigate;
|
|
402
|
+
},
|
|
403
|
+
onClick: () => props.onOpen?.()
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
}), _el$37, _co$8);
|
|
409
|
+
_$insert(_el$21, _$createComponent(Show, {
|
|
410
|
+
get when() {
|
|
411
|
+
return props.avatar;
|
|
412
|
+
},
|
|
413
|
+
get fallback() {
|
|
414
|
+
return _$createComponent(Show, {
|
|
415
|
+
get when() {
|
|
416
|
+
return props.icon;
|
|
417
|
+
},
|
|
418
|
+
get fallback() {
|
|
419
|
+
return _$createComponent(Show, {
|
|
420
|
+
get when() {
|
|
421
|
+
return props.unread;
|
|
422
|
+
},
|
|
423
|
+
get children() {
|
|
424
|
+
return _$createComponent(Dot, {
|
|
425
|
+
status: "ok"
|
|
426
|
+
});
|
|
427
|
+
}
|
|
428
|
+
});
|
|
429
|
+
},
|
|
430
|
+
children: name => _$createComponent(Icon, {
|
|
431
|
+
get name() {
|
|
432
|
+
return name();
|
|
433
|
+
}
|
|
434
|
+
})
|
|
435
|
+
});
|
|
436
|
+
},
|
|
437
|
+
children: person => _$createComponent(Avatar, _$mergeProps(person))
|
|
438
|
+
}));
|
|
439
|
+
_$setAttribute(_el$23, "id", title);
|
|
440
|
+
_$insert(_el$23, () => text()[0]);
|
|
441
|
+
_$insert(_el$22, _$createComponent(Show, {
|
|
442
|
+
get when() {
|
|
443
|
+
return meta() !== undefined;
|
|
444
|
+
},
|
|
445
|
+
get children() {
|
|
446
|
+
var _el$24 = _$getNextElement(_tmpl$9);
|
|
447
|
+
_$insert(_el$24, meta);
|
|
448
|
+
return _el$24;
|
|
449
|
+
}
|
|
450
|
+
}), _el$26, _co$5);
|
|
451
|
+
_$insert(_el$20, _$createComponent(Show, {
|
|
452
|
+
get when() {
|
|
453
|
+
return lines() > 1;
|
|
454
|
+
},
|
|
455
|
+
get children() {
|
|
456
|
+
var _el$27 = _$getNextElement(_tmpl$0);
|
|
457
|
+
_$insert(_el$27, () => text()[1]);
|
|
458
|
+
return _el$27;
|
|
459
|
+
}
|
|
460
|
+
}), _el$39, _co$9);
|
|
461
|
+
_$insert(_el$20, _$createComponent(Show, {
|
|
462
|
+
get when() {
|
|
463
|
+
return lines() > 2;
|
|
464
|
+
},
|
|
465
|
+
get children() {
|
|
466
|
+
var _el$28 = _$getNextElement(_tmpl$1);
|
|
467
|
+
_$insert(_el$28, () => text()[2]);
|
|
468
|
+
return _el$28;
|
|
469
|
+
}
|
|
470
|
+
}), _el$41, _co$0);
|
|
471
|
+
_$insert(_el$20, _$createComponent(Show, {
|
|
472
|
+
get when() {
|
|
473
|
+
return time() !== undefined;
|
|
474
|
+
},
|
|
475
|
+
get children() {
|
|
476
|
+
var _el$29 = _$getNextElement(_tmpl$10);
|
|
477
|
+
_$insert(_el$29, time);
|
|
478
|
+
return _el$29;
|
|
479
|
+
}
|
|
480
|
+
}), _el$43, _co$1);
|
|
481
|
+
_$insert(_el$20, _$createComponent(Show, {
|
|
482
|
+
get when() {
|
|
483
|
+
return end() !== undefined || props.action;
|
|
484
|
+
},
|
|
485
|
+
get children() {
|
|
486
|
+
var _el$30 = _$getNextElement(_tmpl$11),
|
|
487
|
+
_el$31 = _el$30.firstChild,
|
|
488
|
+
[_el$32, _co$6] = _$getNextMarker(_el$31.nextSibling),
|
|
489
|
+
_el$33 = _el$32.nextSibling,
|
|
490
|
+
[_el$34, _co$7] = _$getNextMarker(_el$33.nextSibling);
|
|
491
|
+
_$insert(_el$30, _$createComponent(Show, {
|
|
492
|
+
get when() {
|
|
493
|
+
return props.action;
|
|
494
|
+
},
|
|
495
|
+
children: action => _$createComponent(ActionButton, {
|
|
496
|
+
get action() {
|
|
497
|
+
return action();
|
|
498
|
+
}
|
|
499
|
+
})
|
|
500
|
+
}), _el$32, _co$6);
|
|
501
|
+
_$insert(_el$30, end, _el$34, _co$7);
|
|
502
|
+
return _el$30;
|
|
503
|
+
}
|
|
504
|
+
}), _el$45, _co$10);
|
|
505
|
+
_$insert(_el$20, _$createComponent(Show, {
|
|
506
|
+
get when() {
|
|
507
|
+
return marks() !== undefined;
|
|
508
|
+
},
|
|
509
|
+
get children() {
|
|
510
|
+
var _el$35 = _$getNextElement(_tmpl$12);
|
|
511
|
+
_$insert(_el$35, marks);
|
|
512
|
+
return _el$35;
|
|
513
|
+
}
|
|
514
|
+
}), _el$47, _co$11);
|
|
515
|
+
_$effect(_p$ => {
|
|
516
|
+
var _v$ = props.href !== undefined || props.onOpen ? "" : undefined,
|
|
517
|
+
_v$2 = String(lines()),
|
|
518
|
+
_v$3 = props.unread ? "" : undefined,
|
|
519
|
+
_v$4 = props.strong ? "" : undefined,
|
|
520
|
+
_v$5 = props.selected ? "" : undefined,
|
|
521
|
+
_v$6 = props.selected ? "true" : undefined,
|
|
522
|
+
_v$7 = props.yours ? "" : undefined,
|
|
523
|
+
_v$8 = props.avatar ? "" : undefined,
|
|
524
|
+
_v$9 = time() !== undefined ? "" : undefined,
|
|
525
|
+
_v$0 = props.action ? "" : undefined,
|
|
526
|
+
_v$1 = custom({
|
|
527
|
+
"--k2-c": props.color
|
|
528
|
+
});
|
|
529
|
+
_v$ !== _p$.e && _$setAttribute(_el$20, "data-open", _p$.e = _v$);
|
|
530
|
+
_v$2 !== _p$.t && _$setAttribute(_el$20, "data-lines", _p$.t = _v$2);
|
|
531
|
+
_v$3 !== _p$.a && _$setAttribute(_el$20, "data-unread", _p$.a = _v$3);
|
|
532
|
+
_v$4 !== _p$.o && _$setAttribute(_el$20, "data-strong", _p$.o = _v$4);
|
|
533
|
+
_v$5 !== _p$.i && _$setAttribute(_el$20, "data-selected", _p$.i = _v$5);
|
|
534
|
+
_v$6 !== _p$.n && _$setAttribute(_el$20, "aria-current", _p$.n = _v$6);
|
|
535
|
+
_v$7 !== _p$.s && _$setAttribute(_el$20, "data-yours", _p$.s = _v$7);
|
|
536
|
+
_v$8 !== _p$.h && _$setAttribute(_el$20, "data-avatar", _p$.h = _v$8);
|
|
537
|
+
_v$9 !== _p$.r && _$setAttribute(_el$20, "data-time", _p$.r = _v$9);
|
|
538
|
+
_v$0 !== _p$.d && _$setAttribute(_el$20, "data-action", _p$.d = _v$0);
|
|
539
|
+
_p$.l = _$style(_el$20, _v$1, _p$.l);
|
|
540
|
+
return _p$;
|
|
541
|
+
}, {
|
|
542
|
+
e: undefined,
|
|
543
|
+
t: undefined,
|
|
544
|
+
a: undefined,
|
|
545
|
+
o: undefined,
|
|
546
|
+
i: undefined,
|
|
547
|
+
n: undefined,
|
|
548
|
+
s: undefined,
|
|
549
|
+
h: undefined,
|
|
550
|
+
r: undefined,
|
|
551
|
+
d: undefined,
|
|
552
|
+
l: undefined
|
|
553
|
+
});
|
|
554
|
+
return _el$20;
|
|
555
|
+
})();
|
|
556
|
+
};
|
|
557
|
+
|
|
558
|
+
// ── Table ────────────────────────────────────────────────────────────────────────────────────────────────────────
|
|
559
|
+
|
|
560
|
+
/** Two lines of a cell: the line itself and a quiet second line under it. */
|
|
561
|
+
|
|
562
|
+
/** What a cell shows: one line, or two lines named as such (`{ lines: [first, second] }`). */
|
|
563
|
+
|
|
564
|
+
/** Where an entry leads: a page (a real link, also before the page is live) or a deed in place. */
|
|
565
|
+
|
|
566
|
+
/** A table whose rows are told apart: selection, the open row and groups need the stable key of a row. */
|
|
567
|
+
|
|
568
|
+
/** Two lines only when they are named so: an array of two parts (a fragment) stays one line. */
|
|
569
|
+
const isPair = value => typeof value === "object" && value !== null && !Array.isArray(value) && !(typeof Node !== "undefined" && value instanceof Node) && "lines" in value;
|
|
570
|
+
|
|
571
|
+
/**
|
|
572
|
+
* A group of rows: its key, its head (such as a state chip), quiet figures after it, and the count for the phone.
|
|
573
|
+
* The head is made where it stands (the table and the phone list each make their own), so it is a function.
|
|
574
|
+
*/
|
|
575
|
+
|
|
576
|
+
/**
|
|
577
|
+
* Many like things in columns: head 36, a line under every row, none between columns. Long text stays on one line
|
|
578
|
+
* with "…" and a fixed row height (variant a, decided 22.11.); `wrap` lets one text column take three lines. With
|
|
579
|
+
* `select` or `sticky` it is the large table of Grids: one scroller for head and rows, a sticky head and first column,
|
|
580
|
+
* rows and cells under the pointer, groups as tinted rows.
|
|
581
|
+
*/
|
|
582
|
+
export const Table = props => {
|
|
583
|
+
const grid = () => props.select !== undefined || props.sticky === true;
|
|
584
|
+
const sized = () => grid() || props.columns.some(column => column.width);
|
|
585
|
+
// Every cell is made once: what `cell` returns is placed, never rendered a second time.
|
|
586
|
+
const values = createMemo(() => props.rows.map(row => props.columns.map(column => column.cell(row))));
|
|
587
|
+
// the shape of the placeholders while the rows load
|
|
588
|
+
const loading = () => {
|
|
589
|
+
const shape = props.loading;
|
|
590
|
+
return shape === true ? {
|
|
591
|
+
rows: 3,
|
|
592
|
+
lines: 1
|
|
593
|
+
} : shape ? {
|
|
594
|
+
rows: shape.rows ?? 3,
|
|
595
|
+
lines: shape.lines ?? 1
|
|
596
|
+
} : undefined;
|
|
597
|
+
};
|
|
598
|
+
const empty = () => loading() || props.rows.length > 0 ? undefined : props.empty;
|
|
599
|
+
const lines = () => loading()?.lines === 2 || values().some(row => row.some(isPair)) ? "2" : "1";
|
|
600
|
+
const key = (row, index) => props.rowKey?.(row) ?? String(index);
|
|
601
|
+
const items = createMemo(() => {
|
|
602
|
+
const out = [];
|
|
603
|
+
let last;
|
|
604
|
+
props.rows.forEach((row, index) => {
|
|
605
|
+
const group = props.group?.(row);
|
|
606
|
+
if (group && group.key !== last) out.push({
|
|
607
|
+
group
|
|
608
|
+
});
|
|
609
|
+
last = group?.key;
|
|
610
|
+
out.push({
|
|
611
|
+
row,
|
|
612
|
+
index
|
|
613
|
+
});
|
|
614
|
+
});
|
|
615
|
+
return out;
|
|
616
|
+
});
|
|
617
|
+
const selected = (row, index) => props.select?.selected.includes(key(row, index)) ?? false;
|
|
618
|
+
// A click anywhere on a row that opens something opens it, unless it was meant for a control in the row.
|
|
619
|
+
const openRow = event => {
|
|
620
|
+
if (!(event.target instanceof Element) || event.target.closest("a, button, input, label, select, textarea")) return;
|
|
621
|
+
const open = event.currentTarget.querySelector(".k2-row-open");
|
|
622
|
+
if (!open || event.altKey) return;
|
|
623
|
+
// With Ctrl, Cmd or Shift a link opens elsewhere, as on the link itself. A click handed on loses that in WebKit,
|
|
624
|
+
// which follows it in this tab, so the row opens the link's address in a new tab itself.
|
|
625
|
+
if (open instanceof HTMLAnchorElement && (event.ctrlKey || event.metaKey || event.shiftKey)) {
|
|
626
|
+
window.open(open.href, "_blank", "noopener");
|
|
627
|
+
return;
|
|
628
|
+
}
|
|
629
|
+
// a plain click is handed on to the link or button, which decides (`onNavigate`, `onOpen`, or the browser)
|
|
630
|
+
open.dispatchEvent(new MouseEvent("click", {
|
|
631
|
+
bubbles: true,
|
|
632
|
+
cancelable: true,
|
|
633
|
+
view: window,
|
|
634
|
+
detail: event.detail
|
|
635
|
+
}));
|
|
636
|
+
};
|
|
637
|
+
const all = () => {
|
|
638
|
+
const count = props.select?.selected.length ?? 0;
|
|
639
|
+
return count === 0 ? false : count === props.rows.length ? true : "mixed";
|
|
640
|
+
};
|
|
641
|
+
const toggle = (rowKey, on) => {
|
|
642
|
+
const select = props.select;
|
|
643
|
+
if (!select) return;
|
|
644
|
+
select.onChange(on ? [...select.selected, rowKey] : select.selected.filter(selectedKey => selectedKey !== rowKey));
|
|
645
|
+
};
|
|
646
|
+
const span = () => props.columns.length + (props.select ? 1 : 0);
|
|
647
|
+
// The sticky first data column stands after the box column (44 px).
|
|
648
|
+
const stickyLeft = () => props.select ? "44px" : "0px";
|
|
649
|
+
const firstSticky = index => props.sticky && index === 0 ? "last" : undefined;
|
|
650
|
+
const cell = (column, value, target) => {
|
|
651
|
+
// Every line of a cell is a block of its own: cut with "…" in a sized table, wrapped in a small one.
|
|
652
|
+
const line = (content, second = false) => (() => {
|
|
653
|
+
var _el$49 = _$getNextElement(_tmpl$14);
|
|
654
|
+
_$setAttribute(_el$49, "data-second", second ? "" : undefined);
|
|
655
|
+
_$insert(_el$49, content);
|
|
656
|
+
_$effect(() => _$setAttribute(_el$49, "data-wrap", !second && column.wrap ? "" : undefined));
|
|
657
|
+
return _el$49;
|
|
658
|
+
})();
|
|
659
|
+
const first = content => line(target ? _$createComponent(RowOpen, {
|
|
660
|
+
get href() {
|
|
661
|
+
return target.href;
|
|
662
|
+
},
|
|
663
|
+
get onNavigate() {
|
|
664
|
+
return target.onNavigate;
|
|
665
|
+
},
|
|
666
|
+
get onOpen() {
|
|
667
|
+
return target.onOpen;
|
|
668
|
+
},
|
|
669
|
+
children: content
|
|
670
|
+
}) : content);
|
|
671
|
+
return isPair(value) ? [first(value.lines[0]), line(value.lines[1], true)] : first(value);
|
|
672
|
+
};
|
|
673
|
+
const table = () => [(() => {
|
|
674
|
+
var _el$50 = _$getNextElement(_tmpl$17),
|
|
675
|
+
_el$71 = _el$50.firstChild,
|
|
676
|
+
[_el$72, _co$19] = _$getNextMarker(_el$71.nextSibling),
|
|
677
|
+
_el$51 = _el$72.nextSibling,
|
|
678
|
+
_el$69 = _el$51.firstChild,
|
|
679
|
+
[_el$70, _co$18] = _$getNextMarker(_el$69.nextSibling),
|
|
680
|
+
_el$58 = _el$70.nextSibling,
|
|
681
|
+
_el$59 = _el$58.firstChild,
|
|
682
|
+
_el$60 = _el$59.firstChild,
|
|
683
|
+
[_el$61, _co$14] = _$getNextMarker(_el$60.nextSibling),
|
|
684
|
+
_el$62 = _el$61.nextSibling,
|
|
685
|
+
[_el$63, _co$15] = _$getNextMarker(_el$62.nextSibling),
|
|
686
|
+
_el$64 = _el$58.nextSibling,
|
|
687
|
+
_el$65 = _el$64.firstChild,
|
|
688
|
+
[_el$66, _co$16] = _$getNextMarker(_el$65.nextSibling),
|
|
689
|
+
_el$67 = _el$66.nextSibling,
|
|
690
|
+
[_el$68, _co$17] = _$getNextMarker(_el$67.nextSibling);
|
|
691
|
+
_$insert(_el$50, _$createComponent(Show, {
|
|
692
|
+
get when() {
|
|
693
|
+
return loading();
|
|
694
|
+
},
|
|
695
|
+
get children() {
|
|
696
|
+
return _$createComponent(LoadingStatus, {});
|
|
697
|
+
}
|
|
698
|
+
}), _el$72, _co$19);
|
|
699
|
+
_$insert(_el$51, _$createComponent(Show, {
|
|
700
|
+
get when() {
|
|
701
|
+
return sized();
|
|
702
|
+
},
|
|
703
|
+
get children() {
|
|
704
|
+
var _el$52 = _$getNextElement(_tmpl$16),
|
|
705
|
+
_el$54 = _el$52.firstChild,
|
|
706
|
+
[_el$55, _co$12] = _$getNextMarker(_el$54.nextSibling),
|
|
707
|
+
_el$56 = _el$55.nextSibling,
|
|
708
|
+
[_el$57, _co$13] = _$getNextMarker(_el$56.nextSibling);
|
|
709
|
+
_$insert(_el$52, _$createComponent(Show, {
|
|
710
|
+
get when() {
|
|
711
|
+
return props.select;
|
|
712
|
+
},
|
|
713
|
+
get children() {
|
|
714
|
+
return _$getNextElement(_tmpl$15);
|
|
715
|
+
}
|
|
716
|
+
}), _el$55, _co$12);
|
|
717
|
+
_$insert(_el$52, _$createComponent(For, {
|
|
718
|
+
get each() {
|
|
719
|
+
return props.columns;
|
|
720
|
+
},
|
|
721
|
+
children: (column, index) => (() => {
|
|
722
|
+
var _el$73 = _$getNextElement(_tmpl$18);
|
|
723
|
+
_$effect(_$p => _$style(_el$73, column.width && (grid() || index() < props.columns.length - 1) ? {
|
|
724
|
+
width: `${column.width.default}px`
|
|
725
|
+
} : undefined, _$p));
|
|
726
|
+
return _el$73;
|
|
727
|
+
})()
|
|
728
|
+
}), _el$57, _co$13);
|
|
729
|
+
return _el$52;
|
|
730
|
+
}
|
|
731
|
+
}), _el$70, _co$18);
|
|
732
|
+
_$insert(_el$59, _$createComponent(Show, {
|
|
733
|
+
get when() {
|
|
734
|
+
return props.select;
|
|
735
|
+
},
|
|
736
|
+
children: select => (() => {
|
|
737
|
+
var _el$74 = _$getNextElement(_tmpl$19);
|
|
738
|
+
_$insert(_el$74, _$createComponent(MarkCheck, {
|
|
739
|
+
get label() {
|
|
740
|
+
return select().all;
|
|
741
|
+
},
|
|
742
|
+
get checked() {
|
|
743
|
+
return all();
|
|
744
|
+
},
|
|
745
|
+
onChange: on => select().onChange(on ? props.rows.map(key) : [])
|
|
746
|
+
}));
|
|
747
|
+
_$effect(() => _$setAttribute(_el$74, "data-sticky", props.sticky ? "" : undefined));
|
|
748
|
+
return _el$74;
|
|
749
|
+
})()
|
|
750
|
+
}), _el$61, _co$14);
|
|
751
|
+
_$insert(_el$59, _$createComponent(For, {
|
|
752
|
+
get each() {
|
|
753
|
+
return props.columns;
|
|
754
|
+
},
|
|
755
|
+
children: (column, index) => (() => {
|
|
756
|
+
var _el$75 = _$getNextElement(_tmpl$21),
|
|
757
|
+
_el$77 = _el$75.firstChild,
|
|
758
|
+
[_el$78, _co$20] = _$getNextMarker(_el$77.nextSibling),
|
|
759
|
+
_el$79 = _el$78.nextSibling,
|
|
760
|
+
[_el$80, _co$21] = _$getNextMarker(_el$79.nextSibling),
|
|
761
|
+
_el$81 = _el$80.nextSibling,
|
|
762
|
+
[_el$82, _co$22] = _$getNextMarker(_el$81.nextSibling);
|
|
763
|
+
_$insert(_el$75, _$createComponent(Show, {
|
|
764
|
+
get when() {
|
|
765
|
+
return _$memo(() => index() > 0)() && props.columns[index() - 1]?.width;
|
|
766
|
+
},
|
|
767
|
+
get children() {
|
|
768
|
+
var _el$76 = _$getNextElement(_tmpl$20);
|
|
769
|
+
_$effect(_p$ => {
|
|
770
|
+
var _v$17 = props.columns[index() - 1].title,
|
|
771
|
+
_v$18 = props.columns[index() - 1].width.min,
|
|
772
|
+
_v$19 = props.columns[index() - 1].width.default;
|
|
773
|
+
_v$17 !== _p$.e && _$setAttribute(_el$76, "aria-label", _p$.e = _v$17);
|
|
774
|
+
_v$18 !== _p$.t && _$setAttribute(_el$76, "aria-valuemin", _p$.t = _v$18);
|
|
775
|
+
_v$19 !== _p$.a && _$setAttribute(_el$76, "aria-valuenow", _p$.a = _v$19);
|
|
776
|
+
return _p$;
|
|
777
|
+
}, {
|
|
778
|
+
e: undefined,
|
|
779
|
+
t: undefined,
|
|
780
|
+
a: undefined
|
|
781
|
+
});
|
|
782
|
+
return _el$76;
|
|
783
|
+
}
|
|
784
|
+
}), _el$78, _co$20);
|
|
785
|
+
_$insert(_el$75, () => column.title, _el$80, _co$21);
|
|
786
|
+
_$insert(_el$75, _$createComponent(Show, {
|
|
787
|
+
get when() {
|
|
788
|
+
return props.sort?.column === index();
|
|
789
|
+
},
|
|
790
|
+
get children() {
|
|
791
|
+
return _$createComponent(Icon, {
|
|
792
|
+
get name() {
|
|
793
|
+
return props.sort?.direction === "descending" ? "arrow-down" : "arrow-up";
|
|
794
|
+
}
|
|
795
|
+
});
|
|
796
|
+
}
|
|
797
|
+
}), _el$82, _co$22);
|
|
798
|
+
_$effect(_p$ => {
|
|
799
|
+
var _v$20 = column.align,
|
|
800
|
+
_v$21 = column.drop ? "" : undefined,
|
|
801
|
+
_v$22 = firstSticky(index()),
|
|
802
|
+
_v$23 = firstSticky(index()) ? custom({
|
|
803
|
+
"--k2-sticky-left": stickyLeft()
|
|
804
|
+
}) : undefined,
|
|
805
|
+
_v$24 = props.sort?.column === index() ? props.sort.direction : undefined;
|
|
806
|
+
_v$20 !== _p$.e && _$setAttribute(_el$75, "data-align", _p$.e = _v$20);
|
|
807
|
+
_v$21 !== _p$.t && _$setAttribute(_el$75, "data-drop", _p$.t = _v$21);
|
|
808
|
+
_v$22 !== _p$.a && _$setAttribute(_el$75, "data-sticky", _p$.a = _v$22);
|
|
809
|
+
_p$.o = _$style(_el$75, _v$23, _p$.o);
|
|
810
|
+
_v$24 !== _p$.i && _$setAttribute(_el$75, "aria-sort", _p$.i = _v$24);
|
|
811
|
+
return _p$;
|
|
812
|
+
}, {
|
|
813
|
+
e: undefined,
|
|
814
|
+
t: undefined,
|
|
815
|
+
a: undefined,
|
|
816
|
+
o: undefined,
|
|
817
|
+
i: undefined
|
|
818
|
+
});
|
|
819
|
+
return _el$75;
|
|
820
|
+
})()
|
|
821
|
+
}), _el$63, _co$15);
|
|
822
|
+
_$insert(_el$64, _$createComponent(Show, {
|
|
823
|
+
get when() {
|
|
824
|
+
return loading();
|
|
825
|
+
},
|
|
826
|
+
children: shape => _$createComponent(For, {
|
|
827
|
+
get each() {
|
|
828
|
+
return Array.from({
|
|
829
|
+
length: shape().rows
|
|
830
|
+
}, (_, index) => index);
|
|
831
|
+
},
|
|
832
|
+
children: () => (() => {
|
|
833
|
+
var _el$83 = _$getNextElement(_tmpl$23),
|
|
834
|
+
_el$85 = _el$83.firstChild,
|
|
835
|
+
[_el$86, _co$23] = _$getNextMarker(_el$85.nextSibling),
|
|
836
|
+
_el$87 = _el$86.nextSibling,
|
|
837
|
+
[_el$88, _co$24] = _$getNextMarker(_el$87.nextSibling);
|
|
838
|
+
_$insert(_el$83, _$createComponent(Show, {
|
|
839
|
+
get when() {
|
|
840
|
+
return props.select;
|
|
841
|
+
},
|
|
842
|
+
get children() {
|
|
843
|
+
var _el$84 = _$getNextElement(_tmpl$22);
|
|
844
|
+
_$effect(() => _$setAttribute(_el$84, "data-sticky", props.sticky ? "" : undefined));
|
|
845
|
+
return _el$84;
|
|
846
|
+
}
|
|
847
|
+
}), _el$86, _co$23);
|
|
848
|
+
_$insert(_el$83, _$createComponent(For, {
|
|
849
|
+
get each() {
|
|
850
|
+
return props.columns;
|
|
851
|
+
},
|
|
852
|
+
children: (column, columnIndex) => (() => {
|
|
853
|
+
var _el$89 = _$getNextElement(_tmpl$25),
|
|
854
|
+
_el$90 = _el$89.firstChild,
|
|
855
|
+
_el$92 = _el$90.nextSibling,
|
|
856
|
+
[_el$93, _co$25] = _$getNextMarker(_el$92.nextSibling);
|
|
857
|
+
_$insert(_el$89, _$createComponent(Show, {
|
|
858
|
+
get when() {
|
|
859
|
+
return shape().lines === 2;
|
|
860
|
+
},
|
|
861
|
+
get children() {
|
|
862
|
+
return _$getNextElement(_tmpl$24);
|
|
863
|
+
}
|
|
864
|
+
}), _el$93, _co$25);
|
|
865
|
+
_$effect(_p$ => {
|
|
866
|
+
var _v$25 = column.align,
|
|
867
|
+
_v$26 = column.drop ? "" : undefined,
|
|
868
|
+
_v$27 = firstSticky(columnIndex()),
|
|
869
|
+
_v$28 = firstSticky(columnIndex()) ? custom({
|
|
870
|
+
"--k2-sticky-left": stickyLeft()
|
|
871
|
+
}) : undefined;
|
|
872
|
+
_v$25 !== _p$.e && _$setAttribute(_el$89, "data-align", _p$.e = _v$25);
|
|
873
|
+
_v$26 !== _p$.t && _$setAttribute(_el$89, "data-drop", _p$.t = _v$26);
|
|
874
|
+
_v$27 !== _p$.a && _$setAttribute(_el$89, "data-sticky", _p$.a = _v$27);
|
|
875
|
+
_p$.o = _$style(_el$89, _v$28, _p$.o);
|
|
876
|
+
return _p$;
|
|
877
|
+
}, {
|
|
878
|
+
e: undefined,
|
|
879
|
+
t: undefined,
|
|
880
|
+
a: undefined,
|
|
881
|
+
o: undefined
|
|
882
|
+
});
|
|
883
|
+
return _el$89;
|
|
884
|
+
})()
|
|
885
|
+
}), _el$88, _co$24);
|
|
886
|
+
return _el$83;
|
|
887
|
+
})()
|
|
888
|
+
})
|
|
889
|
+
}), _el$66, _co$16);
|
|
890
|
+
_$insert(_el$64, _$createComponent(For, {
|
|
891
|
+
get each() {
|
|
892
|
+
return _$memo(() => !!loading())() ? [] : items();
|
|
893
|
+
},
|
|
894
|
+
children: item => "group" in item ? (() => {
|
|
895
|
+
var _el$94 = _$getNextElement(_tmpl$27),
|
|
896
|
+
_el$95 = _el$94.firstChild,
|
|
897
|
+
_el$96 = _el$95.firstChild,
|
|
898
|
+
_el$98 = _el$96.firstChild,
|
|
899
|
+
[_el$99, _co$26] = _$getNextMarker(_el$98.nextSibling),
|
|
900
|
+
_el$100 = _el$99.nextSibling,
|
|
901
|
+
[_el$101, _co$27] = _$getNextMarker(_el$100.nextSibling);
|
|
902
|
+
_$insert(_el$96, () => item.group.head(), _el$99, _co$26);
|
|
903
|
+
_$insert(_el$96, _$createComponent(Show, {
|
|
904
|
+
get when() {
|
|
905
|
+
return item.group.meta;
|
|
906
|
+
},
|
|
907
|
+
get children() {
|
|
908
|
+
var _el$97 = _$getNextElement(_tmpl$26);
|
|
909
|
+
_$insert(_el$97, () => item.group.meta);
|
|
910
|
+
return _el$97;
|
|
911
|
+
}
|
|
912
|
+
}), _el$101, _co$27);
|
|
913
|
+
_$effect(() => _$setAttribute(_el$95, "colspan", span()));
|
|
914
|
+
return _el$94;
|
|
915
|
+
})() : (() => {
|
|
916
|
+
const target = props.open?.(item.row);
|
|
917
|
+
return (() => {
|
|
918
|
+
var _el$102 = _$getNextElement(_tmpl$28),
|
|
919
|
+
_el$103 = _el$102.firstChild,
|
|
920
|
+
[_el$104, _co$28] = _$getNextMarker(_el$103.nextSibling),
|
|
921
|
+
_el$105 = _el$104.nextSibling,
|
|
922
|
+
[_el$106, _co$29] = _$getNextMarker(_el$105.nextSibling);
|
|
923
|
+
_$addEventListener(_el$102, "click", target ? openRow : undefined, true);
|
|
924
|
+
_$setAttribute(_el$102, "data-open", target ? "" : undefined);
|
|
925
|
+
_$insert(_el$102, _$createComponent(Show, {
|
|
926
|
+
get when() {
|
|
927
|
+
return props.select;
|
|
928
|
+
},
|
|
929
|
+
children: select => (() => {
|
|
930
|
+
var _el$107 = _$getNextElement(_tmpl$29);
|
|
931
|
+
_$insert(_el$107, _$createComponent(MarkCheck, {
|
|
932
|
+
get label() {
|
|
933
|
+
return select().row(item.row);
|
|
934
|
+
},
|
|
935
|
+
get checked() {
|
|
936
|
+
return selected(item.row, item.index);
|
|
937
|
+
},
|
|
938
|
+
onChange: on => toggle(key(item.row, item.index), on)
|
|
939
|
+
}));
|
|
940
|
+
_$effect(() => _$setAttribute(_el$107, "data-sticky", props.sticky ? "" : undefined));
|
|
941
|
+
return _el$107;
|
|
942
|
+
})()
|
|
943
|
+
}), _el$104, _co$28);
|
|
944
|
+
_$insert(_el$102, _$createComponent(For, {
|
|
945
|
+
get each() {
|
|
946
|
+
return props.columns;
|
|
947
|
+
},
|
|
948
|
+
children: (column, columnIndex) => (() => {
|
|
949
|
+
var _el$108 = _$getNextElement(_tmpl$30);
|
|
950
|
+
_$insert(_el$108, () => cell(column, values()[item.index][columnIndex()], columnIndex() === 0 ? target : undefined));
|
|
951
|
+
_$effect(_p$ => {
|
|
952
|
+
var _v$31 = column.align,
|
|
953
|
+
_v$32 = column.drop ? "" : undefined,
|
|
954
|
+
_v$33 = firstSticky(columnIndex()),
|
|
955
|
+
_v$34 = firstSticky(columnIndex()) ? custom({
|
|
956
|
+
"--k2-sticky-left": stickyLeft()
|
|
957
|
+
}) : undefined;
|
|
958
|
+
_v$31 !== _p$.e && _$setAttribute(_el$108, "data-align", _p$.e = _v$31);
|
|
959
|
+
_v$32 !== _p$.t && _$setAttribute(_el$108, "data-drop", _p$.t = _v$32);
|
|
960
|
+
_v$33 !== _p$.a && _$setAttribute(_el$108, "data-sticky", _p$.a = _v$33);
|
|
961
|
+
_p$.o = _$style(_el$108, _v$34, _p$.o);
|
|
962
|
+
return _p$;
|
|
963
|
+
}, {
|
|
964
|
+
e: undefined,
|
|
965
|
+
t: undefined,
|
|
966
|
+
a: undefined,
|
|
967
|
+
o: undefined
|
|
968
|
+
});
|
|
969
|
+
return _el$108;
|
|
970
|
+
})()
|
|
971
|
+
}), _el$106, _co$29);
|
|
972
|
+
_$effect(_p$ => {
|
|
973
|
+
var _v$29 = props.select && selected(item.row, item.index) ? "" : undefined,
|
|
974
|
+
_v$30 = props.current !== undefined && props.current === key(item.row, item.index) ? "true" : undefined;
|
|
975
|
+
_v$29 !== _p$.e && _$setAttribute(_el$102, "data-selected", _p$.e = _v$29);
|
|
976
|
+
_v$30 !== _p$.t && _$setAttribute(_el$102, "aria-current", _p$.t = _v$30);
|
|
977
|
+
return _p$;
|
|
978
|
+
}, {
|
|
979
|
+
e: undefined,
|
|
980
|
+
t: undefined
|
|
981
|
+
});
|
|
982
|
+
_$runHydrationEvents();
|
|
983
|
+
return _el$102;
|
|
984
|
+
})();
|
|
985
|
+
})()
|
|
986
|
+
}), _el$68, _co$17);
|
|
987
|
+
_$effect(_p$ => {
|
|
988
|
+
var _v$10 = grid() ? "" : undefined,
|
|
989
|
+
_v$11 = props.columns.some(column => column.wrap) ? "" : undefined,
|
|
990
|
+
_v$12 = lines(),
|
|
991
|
+
_v$13 = sized() ? "" : undefined,
|
|
992
|
+
_v$14 = grid() ? "" : undefined,
|
|
993
|
+
_v$15 = props.label,
|
|
994
|
+
_v$16 = loading() ? "true" : undefined;
|
|
995
|
+
_v$10 !== _p$.e && _$setAttribute(_el$50, "data-grid", _p$.e = _v$10);
|
|
996
|
+
_v$11 !== _p$.t && _$setAttribute(_el$50, "data-wrap", _p$.t = _v$11);
|
|
997
|
+
_v$12 !== _p$.a && _$setAttribute(_el$51, "data-lines", _p$.a = _v$12);
|
|
998
|
+
_v$13 !== _p$.o && _$setAttribute(_el$51, "data-sized", _p$.o = _v$13);
|
|
999
|
+
_v$14 !== _p$.i && _$setAttribute(_el$51, "data-grid", _p$.i = _v$14);
|
|
1000
|
+
_v$15 !== _p$.n && _$setAttribute(_el$51, "aria-label", _p$.n = _v$15);
|
|
1001
|
+
_v$16 !== _p$.s && _$setAttribute(_el$51, "aria-busy", _p$.s = _v$16);
|
|
1002
|
+
return _p$;
|
|
1003
|
+
}, {
|
|
1004
|
+
e: undefined,
|
|
1005
|
+
t: undefined,
|
|
1006
|
+
a: undefined,
|
|
1007
|
+
o: undefined,
|
|
1008
|
+
i: undefined,
|
|
1009
|
+
n: undefined,
|
|
1010
|
+
s: undefined
|
|
1011
|
+
});
|
|
1012
|
+
return _el$50;
|
|
1013
|
+
})(), _$createComponent(Show, {
|
|
1014
|
+
get when() {
|
|
1015
|
+
return props.phone;
|
|
1016
|
+
},
|
|
1017
|
+
children: phone => (() => {
|
|
1018
|
+
var _el$109 = _$getNextElement(_tmpl$31);
|
|
1019
|
+
_$insert(_el$109, _$createComponent(Show, {
|
|
1020
|
+
get when() {
|
|
1021
|
+
return !loading();
|
|
1022
|
+
},
|
|
1023
|
+
get fallback() {
|
|
1024
|
+
return _$createComponent(Loading, {
|
|
1025
|
+
get rows() {
|
|
1026
|
+
return loading()?.rows;
|
|
1027
|
+
},
|
|
1028
|
+
lines: 2
|
|
1029
|
+
});
|
|
1030
|
+
},
|
|
1031
|
+
get children() {
|
|
1032
|
+
return _$createComponent(List, {
|
|
1033
|
+
get label() {
|
|
1034
|
+
return props.label;
|
|
1035
|
+
},
|
|
1036
|
+
get children() {
|
|
1037
|
+
return _$createComponent(For, {
|
|
1038
|
+
get each() {
|
|
1039
|
+
return items();
|
|
1040
|
+
},
|
|
1041
|
+
children: item => "group" in item ? (() => {
|
|
1042
|
+
var _el$110 = _$getNextElement(_tmpl$33),
|
|
1043
|
+
_el$111 = _el$110.firstChild,
|
|
1044
|
+
_el$113 = _el$111.firstChild,
|
|
1045
|
+
[_el$114, _co$30] = _$getNextMarker(_el$113.nextSibling),
|
|
1046
|
+
_el$115 = _el$114.nextSibling,
|
|
1047
|
+
[_el$116, _co$31] = _$getNextMarker(_el$115.nextSibling);
|
|
1048
|
+
_$insert(_el$111, () => item.group.head(), _el$114, _co$30);
|
|
1049
|
+
_$insert(_el$111, _$createComponent(Show, {
|
|
1050
|
+
get when() {
|
|
1051
|
+
return item.group.count ?? item.group.meta;
|
|
1052
|
+
},
|
|
1053
|
+
get children() {
|
|
1054
|
+
var _el$112 = _$getNextElement(_tmpl$32);
|
|
1055
|
+
_$insert(_el$112, () => item.group.count ?? item.group.meta);
|
|
1056
|
+
return _el$112;
|
|
1057
|
+
}
|
|
1058
|
+
}), _el$116, _co$31);
|
|
1059
|
+
return _el$110;
|
|
1060
|
+
})() : (() => {
|
|
1061
|
+
const form = phone()(item.row);
|
|
1062
|
+
const target = props.open?.(item.row);
|
|
1063
|
+
return _$createComponent(Row, {
|
|
1064
|
+
get lines() {
|
|
1065
|
+
return form.lines;
|
|
1066
|
+
},
|
|
1067
|
+
get avatar() {
|
|
1068
|
+
return form.avatar;
|
|
1069
|
+
},
|
|
1070
|
+
get time() {
|
|
1071
|
+
return form.time;
|
|
1072
|
+
},
|
|
1073
|
+
strong: true,
|
|
1074
|
+
get href() {
|
|
1075
|
+
return target?.href;
|
|
1076
|
+
},
|
|
1077
|
+
get onNavigate() {
|
|
1078
|
+
return target?.onNavigate;
|
|
1079
|
+
},
|
|
1080
|
+
get onOpen() {
|
|
1081
|
+
return target?.onOpen;
|
|
1082
|
+
},
|
|
1083
|
+
get selected() {
|
|
1084
|
+
return _$memo(() => props.current !== undefined)() && props.current === key(item.row, item.index);
|
|
1085
|
+
}
|
|
1086
|
+
});
|
|
1087
|
+
})()
|
|
1088
|
+
});
|
|
1089
|
+
}
|
|
1090
|
+
});
|
|
1091
|
+
}
|
|
1092
|
+
}));
|
|
1093
|
+
return _el$109;
|
|
1094
|
+
})()
|
|
1095
|
+
})];
|
|
1096
|
+
return _$createComponent(Show, {
|
|
1097
|
+
get when() {
|
|
1098
|
+
return empty();
|
|
1099
|
+
},
|
|
1100
|
+
get fallback() {
|
|
1101
|
+
return table();
|
|
1102
|
+
},
|
|
1103
|
+
children: state => _$createComponent(Empty, _$mergeProps(state))
|
|
1104
|
+
});
|
|
1105
|
+
};
|
|
1106
|
+
_$delegateEvents(["click"]);
|
|
1107
|
+
//# sourceMappingURL=content.js.map
|