@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,211 @@
|
|
|
1
|
+
import { template as _$template } from "solid-js/web";
|
|
2
|
+
import { getNextMarker as _$getNextMarker } from "solid-js/web";
|
|
3
|
+
import { createComponent as _$createComponent } from "solid-js/web";
|
|
4
|
+
import { memo as _$memo } from "solid-js/web";
|
|
5
|
+
import { style as _$style } from "solid-js/web";
|
|
6
|
+
import { insert as _$insert } from "solid-js/web";
|
|
7
|
+
import { setAttribute as _$setAttribute } from "solid-js/web";
|
|
8
|
+
import { className as _$className } from "solid-js/web";
|
|
9
|
+
import { effect as _$effect } from "solid-js/web";
|
|
10
|
+
import { getNextElement as _$getNextElement } from "solid-js/web";
|
|
11
|
+
var _tmpl$ = /*#__PURE__*/_$template(`<i data-k2-part=Icon role=img>`),
|
|
12
|
+
_tmpl$2 = /*#__PURE__*/_$template(`<span class=k2-av data-k2-part=Avatar data-k2-avatar role=img>`),
|
|
13
|
+
_tmpl$3 = /*#__PURE__*/_$template(`<span class=k2-dot data-status=app>`),
|
|
14
|
+
_tmpl$4 = /*#__PURE__*/_$template(`<span class=k2-dot>`),
|
|
15
|
+
_tmpl$5 = /*#__PURE__*/_$template(`<span class=k2-dot role=img>`),
|
|
16
|
+
_tmpl$6 = /*#__PURE__*/_$template(`<span>`),
|
|
17
|
+
_tmpl$7 = /*#__PURE__*/_$template(`<span class=k2-progress data-k2-part=Progress role=progressbar aria-valuemin=0><span class=k2-progress-track><i></i></span><!$><!/>`);
|
|
18
|
+
import { Show } from "solid-js";
|
|
19
|
+
import { Dynamic } from "solid-js/web";
|
|
20
|
+
import { personColor } from "../surfaces/person-color";
|
|
21
|
+
import { linkOr } from "./link";
|
|
22
|
+
import { initialsOf } from "./types";
|
|
23
|
+
|
|
24
|
+
/** Inline custom properties are the primitive's own business: data colours and measured widths, never layout. */
|
|
25
|
+
export const custom = values => {
|
|
26
|
+
const entries = Object.entries(values).filter(entry => entry[1] !== undefined);
|
|
27
|
+
return entries.length ? Object.fromEntries(entries) : undefined;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
// ── Marks ────────────────────────────────────────────────────────────────────────────────────────────────────────
|
|
31
|
+
|
|
32
|
+
/** A Tabler icon. Its size comes from its place: 16 px in rows and bars, 20 px on a tile, 14 px among marks. */
|
|
33
|
+
export const Icon = props => (() => {
|
|
34
|
+
var _el$ = _$getNextElement(_tmpl$);
|
|
35
|
+
_$effect(_p$ => {
|
|
36
|
+
var _v$ = `ti ti-${props.name} k2-icon`,
|
|
37
|
+
_v$2 = props.name,
|
|
38
|
+
_v$3 = props.tone,
|
|
39
|
+
_v$4 = props.label,
|
|
40
|
+
_v$5 = props.label ? undefined : "true";
|
|
41
|
+
_v$ !== _p$.e && _$className(_el$, _p$.e = _v$);
|
|
42
|
+
_v$2 !== _p$.t && _$setAttribute(_el$, "data-name", _p$.t = _v$2);
|
|
43
|
+
_v$3 !== _p$.a && _$setAttribute(_el$, "data-tone", _p$.a = _v$3);
|
|
44
|
+
_v$4 !== _p$.o && _$setAttribute(_el$, "aria-label", _p$.o = _v$4);
|
|
45
|
+
_v$5 !== _p$.i && _$setAttribute(_el$, "aria-hidden", _p$.i = _v$5);
|
|
46
|
+
return _p$;
|
|
47
|
+
}, {
|
|
48
|
+
e: undefined,
|
|
49
|
+
t: undefined,
|
|
50
|
+
a: undefined,
|
|
51
|
+
o: undefined,
|
|
52
|
+
i: undefined
|
|
53
|
+
});
|
|
54
|
+
return _el$;
|
|
55
|
+
})();
|
|
56
|
+
/**
|
|
57
|
+
* A person as initials on a colour. The place sets the size: 24 px by default, 32 px leading a row of two or three
|
|
58
|
+
* lines and in a record head (soft there), 20 px among the marks of a row and in a button.
|
|
59
|
+
*/
|
|
60
|
+
export const Avatar = props => (() => {
|
|
61
|
+
var _el$2 = _$getNextElement(_tmpl$2);
|
|
62
|
+
_$insert(_el$2, () => initialsOf(props));
|
|
63
|
+
_$effect(_p$ => {
|
|
64
|
+
var _v$6 = props.name,
|
|
65
|
+
_v$7 = custom({
|
|
66
|
+
"--k2-c": props.color ?? personColor(props.name)
|
|
67
|
+
});
|
|
68
|
+
_v$6 !== _p$.e && _$setAttribute(_el$2, "aria-label", _p$.e = _v$6);
|
|
69
|
+
_p$.t = _$style(_el$2, _v$7, _p$.t);
|
|
70
|
+
return _p$;
|
|
71
|
+
}, {
|
|
72
|
+
e: undefined,
|
|
73
|
+
t: undefined
|
|
74
|
+
});
|
|
75
|
+
return _el$2;
|
|
76
|
+
})();
|
|
77
|
+
/** A round mark that shows a state, a tag, an amount or a count. Never a colour without a word. */
|
|
78
|
+
export const Chip = props => {
|
|
79
|
+
const pressable = () => props.href !== undefined || props.onClick !== undefined;
|
|
80
|
+
const kind = () => props.yours ? "yours" : props.tag ? "tag" : props.amount ? "amount" : props.ai ? "ai" : props.status ? undefined : pressable() ? "control" : "plain";
|
|
81
|
+
return _$createComponent(Dynamic, {
|
|
82
|
+
get component() {
|
|
83
|
+
return linkOr(props.href, props.onClick ? "button" : "span");
|
|
84
|
+
},
|
|
85
|
+
get href() {
|
|
86
|
+
return props.href;
|
|
87
|
+
},
|
|
88
|
+
get onNavigate() {
|
|
89
|
+
return _$memo(() => props.href !== undefined)() ? props.onNavigate : undefined;
|
|
90
|
+
},
|
|
91
|
+
get type() {
|
|
92
|
+
return props.onClick && props.href === undefined ? "button" : undefined;
|
|
93
|
+
},
|
|
94
|
+
onClick: () => props.onClick?.(),
|
|
95
|
+
"class": "k2-chip",
|
|
96
|
+
"data-k2-part": "Chip",
|
|
97
|
+
get ["data-status"]() {
|
|
98
|
+
return props.status;
|
|
99
|
+
},
|
|
100
|
+
get ["data-kind"]() {
|
|
101
|
+
return kind();
|
|
102
|
+
},
|
|
103
|
+
get ["aria-pressed"]() {
|
|
104
|
+
return _$memo(() => !!(props.onClick && props.pressed !== undefined))() ? props.pressed ? "true" : "false" : undefined;
|
|
105
|
+
},
|
|
106
|
+
get ["data-pressed"]() {
|
|
107
|
+
return props.pressed ? "" : undefined;
|
|
108
|
+
},
|
|
109
|
+
get style() {
|
|
110
|
+
return custom({
|
|
111
|
+
"--k2-c": "color" in props ? props.color : undefined
|
|
112
|
+
});
|
|
113
|
+
},
|
|
114
|
+
get children() {
|
|
115
|
+
return [_$createComponent(Show, {
|
|
116
|
+
get when() {
|
|
117
|
+
return props.status;
|
|
118
|
+
},
|
|
119
|
+
children: status => (() => {
|
|
120
|
+
var _el$4 = _$getNextElement(_tmpl$4);
|
|
121
|
+
_$effect(() => _$setAttribute(_el$4, "data-status", status()));
|
|
122
|
+
return _el$4;
|
|
123
|
+
})()
|
|
124
|
+
}), _$createComponent(Show, {
|
|
125
|
+
get when() {
|
|
126
|
+
return _$memo(() => "dot" in props)() && props.dot;
|
|
127
|
+
},
|
|
128
|
+
get children() {
|
|
129
|
+
return _$getNextElement(_tmpl$3);
|
|
130
|
+
}
|
|
131
|
+
}), _$createComponent(Show, {
|
|
132
|
+
get when() {
|
|
133
|
+
return props.amount;
|
|
134
|
+
},
|
|
135
|
+
children: amount => _$createComponent(Icon, {
|
|
136
|
+
get name() {
|
|
137
|
+
return amount() === "out" ? "arrow-up-right" : "arrow-down-left";
|
|
138
|
+
}
|
|
139
|
+
})
|
|
140
|
+
}), _$createComponent(Show, {
|
|
141
|
+
get when() {
|
|
142
|
+
return props.icon;
|
|
143
|
+
},
|
|
144
|
+
children: name => _$createComponent(Icon, {
|
|
145
|
+
get name() {
|
|
146
|
+
return name();
|
|
147
|
+
}
|
|
148
|
+
})
|
|
149
|
+
}), _$memo(() => props.children)];
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
/** A small round dot of a state (internal: a row marks "unread" with it, the sidebar "new"). */
|
|
155
|
+
export const Dot = props => (() => {
|
|
156
|
+
var _el$5 = _$getNextElement(_tmpl$5);
|
|
157
|
+
_$effect(_p$ => {
|
|
158
|
+
var _v$8 = props.status,
|
|
159
|
+
_v$9 = props.label,
|
|
160
|
+
_v$0 = props.label ? undefined : "true";
|
|
161
|
+
_v$8 !== _p$.e && _$setAttribute(_el$5, "data-status", _p$.e = _v$8);
|
|
162
|
+
_v$9 !== _p$.t && _$setAttribute(_el$5, "aria-label", _p$.t = _v$9);
|
|
163
|
+
_v$0 !== _p$.a && _$setAttribute(_el$5, "aria-hidden", _p$.a = _v$0);
|
|
164
|
+
return _p$;
|
|
165
|
+
}, {
|
|
166
|
+
e: undefined,
|
|
167
|
+
t: undefined,
|
|
168
|
+
a: undefined
|
|
169
|
+
});
|
|
170
|
+
return _el$5;
|
|
171
|
+
})();
|
|
172
|
+
/** A thin bar with its value. */
|
|
173
|
+
export const Progress = props => {
|
|
174
|
+
const share = () => props.of > 0 ? Math.max(0, Math.min(1, props.value / props.of)) : 0;
|
|
175
|
+
return (() => {
|
|
176
|
+
var _el$6 = _$getNextElement(_tmpl$7),
|
|
177
|
+
_el$7 = _el$6.firstChild,
|
|
178
|
+
_el$9 = _el$7.nextSibling,
|
|
179
|
+
[_el$0, _co$] = _$getNextMarker(_el$9.nextSibling);
|
|
180
|
+
_$insert(_el$6, _$createComponent(Show, {
|
|
181
|
+
get when() {
|
|
182
|
+
return props.label;
|
|
183
|
+
},
|
|
184
|
+
get children() {
|
|
185
|
+
var _el$8 = _$getNextElement(_tmpl$6);
|
|
186
|
+
_$insert(_el$8, () => props.label);
|
|
187
|
+
return _el$8;
|
|
188
|
+
}
|
|
189
|
+
}), _el$0, _co$);
|
|
190
|
+
_$effect(_p$ => {
|
|
191
|
+
var _v$1 = props.of,
|
|
192
|
+
_v$10 = props.value,
|
|
193
|
+
_v$11 = props.label,
|
|
194
|
+
_v$12 = custom({
|
|
195
|
+
"--k2-p": `${Math.round(share() * 1000) / 10}%`
|
|
196
|
+
});
|
|
197
|
+
_v$1 !== _p$.e && _$setAttribute(_el$6, "aria-valuemax", _p$.e = _v$1);
|
|
198
|
+
_v$10 !== _p$.t && _$setAttribute(_el$6, "aria-valuenow", _p$.t = _v$10);
|
|
199
|
+
_v$11 !== _p$.a && _$setAttribute(_el$6, "aria-label", _p$.a = _v$11);
|
|
200
|
+
_p$.o = _$style(_el$7, _v$12, _p$.o);
|
|
201
|
+
return _p$;
|
|
202
|
+
}, {
|
|
203
|
+
e: undefined,
|
|
204
|
+
t: undefined,
|
|
205
|
+
a: undefined,
|
|
206
|
+
o: undefined
|
|
207
|
+
});
|
|
208
|
+
return _el$6;
|
|
209
|
+
})();
|
|
210
|
+
};
|
|
211
|
+
//# sourceMappingURL=marks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["v2/marks.tsx"],"sourcesContent":["import { type JSX, Show } from \"solid-js\";\nimport { Dynamic } from \"solid-js/web\";\nimport { personColor } from \"../surfaces/person-color\";\nimport { linkOr } from \"./link\";\nimport { initialsOf, type OnNavigate, type Person, type Status } from \"./types\";\n\n/** Inline custom properties are the primitive's own business: data colours and measured widths, never layout. */\nexport const custom = (values: Record<string, string | undefined>): JSX.CSSProperties | undefined => {\n const entries = Object.entries(values).filter((entry): entry is [string, string] => entry[1] !== undefined);\n return entries.length ? Object.fromEntries(entries) : undefined;\n};\n\n// ── Marks ────────────────────────────────────────────────────────────────────────────────────────────────────────\n\nexport type IconProps = {\n /** A Tabler icon name without the `ti-` prefix, such as `package`. */\n name: string;\n /** A name for assistive technology; without one the icon is decoration. */\n label?: string;\n tone?: Status | \"ai\" | \"app\" | \"muted\" | \"subtle\";\n};\n\n/** A Tabler icon. Its size comes from its place: 16 px in rows and bars, 20 px on a tile, 14 px among marks. */\nexport const Icon = (props: IconProps) => (\n <i\n class={`ti ti-${props.name} k2-icon`}\n data-k2-part=\"Icon\"\n data-name={props.name}\n data-tone={props.tone}\n role=\"img\"\n aria-label={props.label}\n aria-hidden={props.label ? undefined : \"true\"}\n />\n);\n\nexport type AvatarProps = Person;\n\n/**\n * A person as initials on a colour. The place sets the size: 24 px by default, 32 px leading a row of two or three\n * lines and in a record head (soft there), 20 px among the marks of a row and in a button.\n */\nexport const Avatar = (props: AvatarProps) => (\n <span\n class=\"k2-av\"\n data-k2-part=\"Avatar\"\n data-k2-avatar=\"\"\n role=\"img\"\n aria-label={props.name}\n // Every person has a colour: given, or the fixed one of their name, the same as everywhere in Cloud.\n style={custom({ \"--k2-c\": props.color ?? personColor(props.name) })}\n >\n {initialsOf(props)}\n </span>\n);\n\nexport type ChipProps = {\n children: JSX.Element;\n /** A symbol before the word. */\n icon?: string;\n /**\n * A plain chip you can press, such as \"1 linked\" or \"+ Tag\": then it is a control with a frame (rule 8).\n */\n onClick?: () => void;\n href?: string;\n /** With `href`: opens the page in place on a plain click (see `OnNavigate`). */\n onNavigate?: OnNavigate;\n /** A pressable chip that is on, such as an active filter: in the tint of the app. */\n pressed?: boolean;\n} & (\n | {\n /** A state with a dot and a word: ok, waiting or wrong. */\n status: Status;\n yours?: never;\n tag?: never;\n amount?: never;\n ai?: never;\n }\n | {\n status?: never;\n /** \"You are next\" in the blue of selection; with `dot` a state that is being worked on (\"in Arbeit\"). */\n yours: true;\n dot?: boolean;\n tag?: never;\n amount?: never;\n ai?: never;\n }\n | {\n status?: never;\n yours?: never;\n /** A tag in its data colour. */\n tag: true;\n color?: string;\n amount?: never;\n ai?: never;\n }\n | {\n status?: never;\n yours?: never;\n tag?: never;\n /** An amount of money that goes out (we pay) or comes in. */\n amount: \"out\" | \"in\";\n ai?: never;\n }\n | { status?: never; yours?: never; tag?: never; amount?: never /** Something Gustav proposes, in plum. */; ai: true }\n | { status?: never; yours?: never; tag?: never; amount?: never; ai?: never }\n);\n\n/** A round mark that shows a state, a tag, an amount or a count. Never a colour without a word. */\nexport const Chip = (props: ChipProps) => {\n const pressable = () => props.href !== undefined || props.onClick !== undefined;\n const kind = () =>\n props.yours\n ? \"yours\"\n : props.tag\n ? \"tag\"\n : props.amount\n ? \"amount\"\n : props.ai\n ? \"ai\"\n : props.status\n ? undefined\n : pressable()\n ? \"control\"\n : \"plain\";\n return (\n <Dynamic\n component={linkOr(props.href, props.onClick ? \"button\" : \"span\")}\n href={props.href}\n onNavigate={props.href !== undefined ? props.onNavigate : undefined}\n type={props.onClick && props.href === undefined ? \"button\" : undefined}\n onClick={() => props.onClick?.()}\n class=\"k2-chip\"\n data-k2-part=\"Chip\"\n data-status={props.status}\n data-kind={kind()}\n aria-pressed={props.onClick && props.pressed !== undefined ? (props.pressed ? \"true\" : \"false\") : undefined}\n data-pressed={props.pressed ? \"\" : undefined}\n style={custom({ \"--k2-c\": \"color\" in props ? props.color : undefined })}\n >\n <Show when={props.status}>{(status) => <span class=\"k2-dot\" data-status={status()} />}</Show>\n <Show when={\"dot\" in props && props.dot}>\n <span class=\"k2-dot\" data-status=\"app\" />\n </Show>\n <Show when={props.amount}>{(amount) => <Icon name={amount() === \"out\" ? \"arrow-up-right\" : \"arrow-down-left\"} />}</Show>\n <Show when={props.icon}>{(name) => <Icon name={name()} />}</Show>\n {props.children}\n </Dynamic>\n );\n};\n\n/** A small round dot of a state (internal: a row marks \"unread\" with it, the sidebar \"new\"). */\nexport const Dot = (props: { status?: Status | \"app\"; label?: string }) => (\n <span class=\"k2-dot\" data-status={props.status} role=\"img\" aria-label={props.label} aria-hidden={props.label ? undefined : \"true\"} />\n);\n\nexport type ProgressProps = {\n value: number;\n of: number;\n /** The words next to the bar, such as \"Arbeitstag 5 von 22\". */\n label?: string;\n};\n\n/** A thin bar with its value. */\nexport const Progress = (props: ProgressProps) => {\n const share = () => (props.of > 0 ? Math.max(0, Math.min(1, props.value / props.of)) : 0);\n return (\n <span\n class=\"k2-progress\"\n data-k2-part=\"Progress\"\n role=\"progressbar\"\n aria-valuemin={0}\n aria-valuemax={props.of}\n aria-valuenow={props.value}\n aria-label={props.label}\n >\n <span class=\"k2-progress-track\" style={custom({ \"--k2-p\": `${Math.round(share() * 1000) / 10}%` })}>\n <i />\n </span>\n <Show when={props.label}>\n <span>{props.label}</span>\n </Show>\n </span>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA,SAAmB,IAAI,QAAQ,UAAU;AACzC,SAAS,OAAO,QAAQ,cAAc;AACtC,SAAS,WAAW,QAAQ,0BAA0B;AACtD,SAAS,MAAM,QAAQ,QAAQ;AAC/B,SAAS,UAAU,QAAmD,SAAS;;AAE/E;AACA,OAAO,MAAM,MAAM,GAAI,MAA0C,IAAoC;EACnG,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,CAAE,KAAK,IAAgC,KAAK,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC;EAC3G,OAAO,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,GAAG,SAAS;AACjE,CAAC;;AAED;;AAUA;AACA,OAAO,MAAM,IAAI,GAAI,KAAgB;EAAA;EAAA;IAAA,UAE1B,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I;YAAA,OAAE,IAAI,CAAC,CAAC;UAAA;QAAA;MAAI,iBACxD,KAAK,CAAC,QAAQ;IAAA;EAAA;AAGrB,CAAC;;AAED;AACA,OAAO,MAAM,GAAG,GAAI,KAAkD;EAAA;EAAA;IAAA,WAClC,KAAK,CAAC,MAAM;MAAA,OAAyB,KAAK,CAAC,KAAK;MAAA,OAAe,KAAK,CAAC,KAAK,GAAG,SAAS,GAAG,MAAM;IAAA;IAAA;IAAA;IAAA;EAAA;IAAA;IAAA;IAAA;EAAA;EAAA;AAAA,IAClI;AASD;AACA,OAAO,MAAM,QAAQ,GAAI,KAAoB,IAAK;EAChD,MAAM,KAAK,GAAG,MAAO,KAAK,CAAC,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC,GAAG,CAAE;EACzF;IAAA;MAAA;MAAA;MAAA;IAAA,kCAaK,IAAI;MAAA,IAAC,IAAI;QAAA,OAAE,KAAK,CAAC,KAAK;MAAA;MAAA;QAAA;QAAA,sBACd,KAAK,CAAC,KAAK;QAAA;MAAA;IAAA;IAAA;MAAA,WARL,KAAK,CAAC,EAAE;QAAA,QACR,KAAK,CAAC,KAAK;QAAA,QACd,KAAK,CAAC,KAAK;QAAA,QAEgB,MAAM,CAAC;UAAE,QAAQ,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE;QAAI,CAAC,CAAC;MAAA;MAAA;MAAA;MAAA;MAAA;IAAA;MAAA;MAAA;MAAA;MAAA;IAAA;IAAA;EAAA;AAQxG,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { template as _$template } from "solid-js/web";
|
|
2
|
+
import { className as _$className } from "solid-js/web";
|
|
3
|
+
import { setAttribute as _$setAttribute } from "solid-js/web";
|
|
4
|
+
import { effect as _$effect } from "solid-js/web";
|
|
5
|
+
import { memo as _$memo } from "solid-js/web";
|
|
6
|
+
import { use as _$use } from "solid-js/web";
|
|
7
|
+
import { getNextElement as _$getNextElement } from "solid-js/web";
|
|
8
|
+
import { getNextMarker as _$getNextMarker } from "solid-js/web";
|
|
9
|
+
import { insert as _$insert } from "solid-js/web";
|
|
10
|
+
import { createComponent as _$createComponent } from "solid-js/web";
|
|
11
|
+
var _tmpl$ = /*#__PURE__*/_$template(`<div class=k2-state data-k2-part=Empty><span class=k2-sign></span><span class=k2-state-text></span><!$><!/>`),
|
|
12
|
+
_tmpl$2 = /*#__PURE__*/_$template(`<div class=k2-state data-k2-part=Failed role=alert><span class=k2-sign data-tone=bad></span><span class=k2-state-text></span><!$><!/>`),
|
|
13
|
+
_tmpl$3 = /*#__PURE__*/_$template(`<div class="k2-list k2-loading"data-k2-part=Loading><!$><!/><!$><!/>`),
|
|
14
|
+
_tmpl$4 = /*#__PURE__*/_$template(`<span class=k2-hidden-text role=status>`),
|
|
15
|
+
_tmpl$5 = /*#__PURE__*/_$template(`<div class=k2-row aria-hidden=true><span class=k2-row-lead></span><!$><!/>`),
|
|
16
|
+
_tmpl$6 = /*#__PURE__*/_$template(`<span><span class=k2-skel>`);
|
|
17
|
+
import { For, Index, Show } from "solid-js";
|
|
18
|
+
import { useUiMessages } from "../intl/messages";
|
|
19
|
+
import { ActionButton, Button } from "./button";
|
|
20
|
+
import { Icon } from "./marks";
|
|
21
|
+
|
|
22
|
+
// The three states every place that shows data has, in the place where the data will stand (design guide "Zustände"):
|
|
23
|
+
// empty, loading and failed. None draws a box; each stands where the list, the table or the content would stand, so
|
|
24
|
+
// the head and the status row above it never move.
|
|
25
|
+
|
|
26
|
+
/** Nothing here: a round sign, one sentence, one way out, without a box (mockup: Notice · Empty). */
|
|
27
|
+
export const Empty = props => (() => {
|
|
28
|
+
var _el$ = _$getNextElement(_tmpl$),
|
|
29
|
+
_el$2 = _el$.firstChild,
|
|
30
|
+
_el$3 = _el$2.nextSibling,
|
|
31
|
+
_el$4 = _el$3.nextSibling,
|
|
32
|
+
[_el$5, _co$] = _$getNextMarker(_el$4.nextSibling);
|
|
33
|
+
_$insert(_el$2, _$createComponent(Icon, {
|
|
34
|
+
get name() {
|
|
35
|
+
return props.icon;
|
|
36
|
+
}
|
|
37
|
+
}));
|
|
38
|
+
_$insert(_el$3, () => props.text);
|
|
39
|
+
_$insert(_el$, _$createComponent(Show, {
|
|
40
|
+
get when() {
|
|
41
|
+
return props.action;
|
|
42
|
+
},
|
|
43
|
+
children: action => _$createComponent(ActionButton, {
|
|
44
|
+
get action() {
|
|
45
|
+
return action();
|
|
46
|
+
}
|
|
47
|
+
})
|
|
48
|
+
}), _el$5, _co$);
|
|
49
|
+
return _el$;
|
|
50
|
+
})();
|
|
51
|
+
/**
|
|
52
|
+
* Loading failed: the shape of `Empty` with a sign in the tone of wrong, the sentence, and "Erneut versuchen". It
|
|
53
|
+
* replaces only the data; the selection and the view around it stay. (A connection that retries on its own shows in
|
|
54
|
+
* the status row instead, without a button; something a person must fix is a `Notice` that names the deed.)
|
|
55
|
+
*/
|
|
56
|
+
export const Failed = props => {
|
|
57
|
+
const t = useUiMessages();
|
|
58
|
+
let root;
|
|
59
|
+
return (() => {
|
|
60
|
+
var _el$6 = _$getNextElement(_tmpl$2),
|
|
61
|
+
_el$7 = _el$6.firstChild,
|
|
62
|
+
_el$8 = _el$7.nextSibling,
|
|
63
|
+
_el$9 = _el$8.nextSibling,
|
|
64
|
+
[_el$0, _co$2] = _$getNextMarker(_el$9.nextSibling);
|
|
65
|
+
var _ref$ = root;
|
|
66
|
+
typeof _ref$ === "function" ? _$use(_ref$, _el$6) : root = _el$6;
|
|
67
|
+
_$insert(_el$7, _$createComponent(Icon, {
|
|
68
|
+
name: "alert-circle"
|
|
69
|
+
}));
|
|
70
|
+
_$insert(_el$8, () => props.text);
|
|
71
|
+
_$insert(_el$6, _$createComponent(Button, {
|
|
72
|
+
icon: "refresh",
|
|
73
|
+
onClick: () => {
|
|
74
|
+
// the focus is on the button, which leaves with this state: it goes on to what comes in its place
|
|
75
|
+
if (root?.contains(document.activeElement)) focusWhatComes(root);
|
|
76
|
+
props.onRetry();
|
|
77
|
+
},
|
|
78
|
+
get children() {
|
|
79
|
+
return t().retry;
|
|
80
|
+
}
|
|
81
|
+
}), _el$0, _co$2);
|
|
82
|
+
return _el$6;
|
|
83
|
+
})();
|
|
84
|
+
};
|
|
85
|
+
const focusable = "a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]";
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Gives the focus to the first visible thing that can take it among what replaces `state` in its place, such as the
|
|
89
|
+
* first row of the list that loaded. It waits while placeholders stand there, and stops once it has placed the
|
|
90
|
+
* focus, once the person focuses something themselves, or once the content has come without anything to focus.
|
|
91
|
+
*/
|
|
92
|
+
const focusWhatComes = state => {
|
|
93
|
+
const place = state.parentElement;
|
|
94
|
+
if (!place || typeof MutationObserver === "undefined") return;
|
|
95
|
+
const before = state.previousSibling;
|
|
96
|
+
const after = state.nextSibling;
|
|
97
|
+
const follows = (node, anchor) => !anchor?.isConnected || !!(anchor.compareDocumentPosition(node) & Node.DOCUMENT_POSITION_FOLLOWING);
|
|
98
|
+
const precedes = (node, anchor) => !anchor?.isConnected || !!(anchor.compareDocumentPosition(node) & Node.DOCUMENT_POSITION_PRECEDING);
|
|
99
|
+
const inPlace = node => follows(node, before) && precedes(node, after) && !state.contains(node);
|
|
100
|
+
const stop = () => {
|
|
101
|
+
observer.disconnect();
|
|
102
|
+
document.removeEventListener("focusin", stop);
|
|
103
|
+
};
|
|
104
|
+
const settle = () => {
|
|
105
|
+
const target = [...place.querySelectorAll(focusable)].find(element => inPlace(element) && element.tabIndex >= 0 && element.getClientRects().length > 0);
|
|
106
|
+
if (target) {
|
|
107
|
+
stop();
|
|
108
|
+
target.focus();
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
const waiting = [...place.querySelectorAll('[data-k2-part="Loading"], [aria-busy="true"]')].some(inPlace);
|
|
112
|
+
if (!state.isConnected && !waiting) stop();
|
|
113
|
+
};
|
|
114
|
+
const observer = new MutationObserver(settle);
|
|
115
|
+
observer.observe(place, {
|
|
116
|
+
childList: true,
|
|
117
|
+
subtree: true
|
|
118
|
+
});
|
|
119
|
+
document.addEventListener("focusin", stop);
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* Loading: square placeholders in the heights of the real rows, so nothing moves when the data arrives. It stands
|
|
123
|
+
* where the `List` will stand; a `Table` takes `loading` itself and keeps its head. Assistive technology hears
|
|
124
|
+
* "Wird geladen…" (in the language of the page) from a status line; the placeholders themselves are hidden from it.
|
|
125
|
+
*/
|
|
126
|
+
export const Loading = props => (() => {
|
|
127
|
+
var _el$1 = _$getNextElement(_tmpl$3),
|
|
128
|
+
_el$10 = _el$1.firstChild,
|
|
129
|
+
[_el$11, _co$3] = _$getNextMarker(_el$10.nextSibling),
|
|
130
|
+
_el$12 = _el$11.nextSibling,
|
|
131
|
+
[_el$13, _co$4] = _$getNextMarker(_el$12.nextSibling);
|
|
132
|
+
_$insert(_el$1, _$createComponent(LoadingStatus, {}), _el$11, _co$3);
|
|
133
|
+
_$insert(_el$1, _$createComponent(PlaceholderRows, {
|
|
134
|
+
get rows() {
|
|
135
|
+
return props.rows ?? 3;
|
|
136
|
+
},
|
|
137
|
+
get lines() {
|
|
138
|
+
return props.lines ?? 1;
|
|
139
|
+
}
|
|
140
|
+
}), _el$13, _co$4);
|
|
141
|
+
return _el$1;
|
|
142
|
+
})();
|
|
143
|
+
|
|
144
|
+
/** The words "loading" for assistive technology only (internal: `Loading` and a loading `Table`). */
|
|
145
|
+
export const LoadingStatus = () => {
|
|
146
|
+
const t = useUiMessages();
|
|
147
|
+
return (() => {
|
|
148
|
+
var _el$14 = _$getNextElement(_tmpl$4);
|
|
149
|
+
_$insert(_el$14, () => t().loading);
|
|
150
|
+
return _el$14;
|
|
151
|
+
})();
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
/** Rows of placeholders in the shape of `Row` (internal: `Loading` and the phone list of a loading `Table`). */
|
|
155
|
+
export const PlaceholderRows = props => _$createComponent(Index, {
|
|
156
|
+
get each() {
|
|
157
|
+
return Array.from({
|
|
158
|
+
length: Math.max(0, props.rows)
|
|
159
|
+
});
|
|
160
|
+
},
|
|
161
|
+
children: () => (() => {
|
|
162
|
+
var _el$15 = _$getNextElement(_tmpl$5),
|
|
163
|
+
_el$16 = _el$15.firstChild,
|
|
164
|
+
_el$17 = _el$16.nextSibling,
|
|
165
|
+
[_el$18, _co$5] = _$getNextMarker(_el$17.nextSibling);
|
|
166
|
+
_$insert(_el$15, _$createComponent(For, {
|
|
167
|
+
get each() {
|
|
168
|
+
return ["k2-row-l1", "k2-row-l2", "k2-row-l3"].slice(0, props.lines);
|
|
169
|
+
},
|
|
170
|
+
children: line => (() => {
|
|
171
|
+
var _el$19 = _$getNextElement(_tmpl$6);
|
|
172
|
+
_$className(_el$19, line);
|
|
173
|
+
return _el$19;
|
|
174
|
+
})()
|
|
175
|
+
}), _el$18, _co$5);
|
|
176
|
+
_$effect(() => _$setAttribute(_el$15, "data-lines", String(props.lines)));
|
|
177
|
+
return _el$15;
|
|
178
|
+
})()
|
|
179
|
+
});
|
|
180
|
+
//# sourceMappingURL=states.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["v2/states.tsx"],"sourcesContent":["import { For, Index, Show } from \"solid-js\";\nimport { useUiMessages } from \"../intl/messages\";\nimport { ActionButton, Button } from \"./button\";\nimport { Icon } from \"./marks\";\nimport type { Action } from \"./types\";\n\n// The three states every place that shows data has, in the place where the data will stand (design guide \"Zustände\"):\n// empty, loading and failed. None draws a box; each stands where the list, the table or the content would stand, so\n// the head and the status row above it never move.\n\nexport type EmptyProps = {\n /** A Tabler icon for the round sign, such as `inbox`. */\n icon: string;\n /** One sentence that says what is the matter: \"Noch keine Einlieferung.\" is not \"Keine Treffer mit diesem Filter.\" */\n text: string;\n /** The one way out, such as \"Einlieferung erfassen\" or \"Filter zurücksetzen\". */\n action?: Action;\n};\n\n/** Nothing here: a round sign, one sentence, one way out, without a box (mockup: Notice · Empty). */\nexport const Empty = (props: EmptyProps) => (\n <div class=\"k2-state\" data-k2-part=\"Empty\">\n <span class=\"k2-sign\">\n <Icon name={props.icon} />\n </span>\n <span class=\"k2-state-text\">{props.text}</span>\n <Show when={props.action}>{(action) => <ActionButton action={action()} />}</Show>\n </div>\n);\n\nexport type FailedProps = {\n /**\n * What could not be loaded and what stays as it is, such as \"Unterhaltungen konnten nicht geladen werden. Deine\n * Ansicht und Auswahl bleiben erhalten.\"\n */\n text: string;\n /** Loads again; the button says \"Erneut versuchen\" in the language of the page. */\n onRetry: () => void;\n};\n\n/**\n * Loading failed: the shape of `Empty` with a sign in the tone of wrong, the sentence, and \"Erneut versuchen\". It\n * replaces only the data; the selection and the view around it stay. (A connection that retries on its own shows in\n * the status row instead, without a button; something a person must fix is a `Notice` that names the deed.)\n */\nexport const Failed = (props: FailedProps) => {\n const t = useUiMessages();\n let root: HTMLDivElement | undefined;\n return (\n <div ref={root} class=\"k2-state\" data-k2-part=\"Failed\" role=\"alert\">\n <span class=\"k2-sign\" data-tone=\"bad\">\n <Icon name=\"alert-circle\" />\n </span>\n <span class=\"k2-state-text\">{props.text}</span>\n <Button\n icon=\"refresh\"\n onClick={() => {\n // the focus is on the button, which leaves with this state: it goes on to what comes in its place\n if (root?.contains(document.activeElement)) focusWhatComes(root);\n props.onRetry();\n }}\n >\n {t().retry}\n </Button>\n </div>\n );\n};\n\nconst focusable = \"a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]\";\n\n/**\n * Gives the focus to the first visible thing that can take it among what replaces `state` in its place, such as the\n * first row of the list that loaded. It waits while placeholders stand there, and stops once it has placed the\n * focus, once the person focuses something themselves, or once the content has come without anything to focus.\n */\nconst focusWhatComes = (state: HTMLElement) => {\n const place = state.parentElement;\n if (!place || typeof MutationObserver === \"undefined\") return;\n const before = state.previousSibling;\n const after = state.nextSibling;\n const follows = (node: Node, anchor: Node | null) =>\n !anchor?.isConnected || !!(anchor.compareDocumentPosition(node) & Node.DOCUMENT_POSITION_FOLLOWING);\n const precedes = (node: Node, anchor: Node | null) =>\n !anchor?.isConnected || !!(anchor.compareDocumentPosition(node) & Node.DOCUMENT_POSITION_PRECEDING);\n const inPlace = (node: Node) => follows(node, before) && precedes(node, after) && !state.contains(node);\n const stop = () => {\n observer.disconnect();\n document.removeEventListener(\"focusin\", stop);\n };\n const settle = () => {\n const target = [...place.querySelectorAll<HTMLElement>(focusable)].find(\n (element) => inPlace(element) && element.tabIndex >= 0 && element.getClientRects().length > 0,\n );\n if (target) {\n stop();\n target.focus();\n return;\n }\n const waiting = [...place.querySelectorAll('[data-k2-part=\"Loading\"], [aria-busy=\"true\"]')].some(inPlace);\n if (!state.isConnected && !waiting) stop();\n };\n const observer = new MutationObserver(settle);\n observer.observe(place, { childList: true, subtree: true });\n document.addEventListener(\"focusin\", stop);\n};\n\nexport type LoadingProps = {\n /** How many rows hold the place; 3 when not set. Give as many as usually come, so nothing moves when they arrive. */\n rows?: number;\n /** The lines of the rows that will come, so each placeholder is exactly as high as its row (40, 52 or 72). */\n lines?: 1 | 2 | 3;\n};\n\n/**\n * Loading: square placeholders in the heights of the real rows, so nothing moves when the data arrives. It stands\n * where the `List` will stand; a `Table` takes `loading` itself and keeps its head. Assistive technology hears\n * \"Wird geladen…\" (in the language of the page) from a status line; the placeholders themselves are hidden from it.\n */\nexport const Loading = (props: LoadingProps) => (\n <div class=\"k2-list k2-loading\" data-k2-part=\"Loading\">\n <LoadingStatus />\n <PlaceholderRows rows={props.rows ?? 3} lines={props.lines ?? 1} />\n </div>\n);\n\n/** The words \"loading\" for assistive technology only (internal: `Loading` and a loading `Table`). */\nexport const LoadingStatus = () => {\n const t = useUiMessages();\n return (\n <span class=\"k2-hidden-text\" role=\"status\">\n {t().loading}\n </span>\n );\n};\n\n/** Rows of placeholders in the shape of `Row` (internal: `Loading` and the phone list of a loading `Table`). */\nexport const PlaceholderRows = (props: { rows: number; lines: 1 | 2 | 3 }) => (\n <Index each={Array.from({ length: Math.max(0, props.rows) })}>\n {() => (\n <div class=\"k2-row\" data-lines={String(props.lines)} aria-hidden=\"true\">\n <span class=\"k2-row-lead\" />\n <For each={([\"k2-row-l1\", \"k2-row-l2\", \"k2-row-l3\"] as const).slice(0, props.lines)}>\n {(line) => (\n <span class={line}>\n <span class=\"k2-skel\" />\n </span>\n )}\n </For>\n </div>\n )}\n </Index>\n);\n"],"mappings":";;;;;;;;;;;;;;;;AAAA,SAAS,GAAG,EAAE,KAAK,EAAE,IAAI,QAAQ,UAAU;AAC3C,SAAS,aAAa,QAAQ,kBAAkB;AAChD,SAAS,YAAY,EAAE,MAAM,QAAQ,UAAU;AAC/C,SAAS,IAAI,QAAQ,SAAS;;AAG9B;AACA;AACA;;AAWA;AACA,OAAO,MAAM,KAAK,GAAI,KAAiB;EAAA;IAAA;IAAA;IAAA;IAAA;EAAA,kCAGhC,IAAI;IAAA,IAAC,IAAI;MAAA,OAAE,KAAK,CAAC,IAAI;IAAA;EAAA;EAAA,sBAEK,KAAK,CAAC,IAAI;EAAA,iCACtC,IAAI;IAAA,IAAC,IAAI;MAAA,OAAE,KAAK,CAAC,MAAM;IAAA;IAAA,UAAI,MAAM,sBAAM,YAAY;MAAA,IAAC,MAAM;QAAA,OAAE,MAAM,CAAC,CAAC;MAAA;IAAA;EAAI;EAAA;AAAA,IAE5E;AAYD;AACA;AACA;AACA;AACA;AACA,OAAO,MAAM,MAAM,GAAI,KAAkB,IAAK;EAC5C,MAAM,CAAC,GAAG,aAAa,CAAC,CAAC;EACzB,IAAI,IAAgC;EACpC;IAAA;MAAA;MAAA;MAAA;MAAA;IAAA,YACY,IAAI;IAAA,oDAAJ,IAAI;IAAA,kCAET,IAAI;MAAC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