viewkitjs 0.26.0 → 0.27.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/CHANGELOG.md +24 -0
- package/MIGRATION.md +84 -6
- package/package.json +1 -1
- package/views/dist/contract.d.ts +171 -1
- package/views/dist/contract.js +162 -0
- package/views/dist/controls/compound-editor/map-parts-body.js +2 -1
- package/views/dist/controls/compound-editor/name-parts.js +10 -2
- package/views/dist/controls/compound-editor/place.d.ts +2 -1
- package/views/dist/controls/compound-editor/place.js +2 -0
- package/views/dist/controls/controls.d.ts +8 -0
- package/views/dist/controls/controls.js +8 -0
- package/views/dist/controls/index.d.ts +16 -0
- package/views/dist/controls/index.js +16 -0
- package/views/dist/controls/internal/editor-parts.d.ts +40 -0
- package/views/dist/controls/internal/editor-parts.js +43 -0
- package/views/dist/controls/links-editor/links-editor.d.ts +78 -0
- package/views/dist/controls/links-editor/links-editor.js +308 -0
- package/views/dist/controls/links-editor/links.d.ts +62 -0
- package/views/dist/controls/links-editor/links.js +50 -0
- package/views/dist/controls/links-editor/map-links-body.d.ts +10 -0
- package/views/dist/controls/links-editor/map-links-body.js +71 -0
- package/views/dist/controls/links-editor/tokens.d.ts +71 -0
- package/views/dist/controls/links-editor/tokens.js +20 -0
- package/views/dist/controls/links-editor/words.d.ts +56 -0
- package/views/dist/controls/links-editor/words.js +33 -0
- package/views/dist/controls/links-editor.css +132 -0
- package/views/dist/controls/number-editor/format.d.ts +31 -0
- package/views/dist/controls/number-editor/format.js +79 -0
- package/views/dist/controls/number-editor/looks.d.ts +14 -0
- package/views/dist/controls/number-editor/looks.js +17 -0
- package/views/dist/controls/number-editor/map-number-body.d.ts +16 -0
- package/views/dist/controls/number-editor/map-number-body.js +57 -0
- package/views/dist/controls/number-editor/number-editor.d.ts +72 -0
- package/views/dist/controls/number-editor/number-editor.js +202 -0
- package/views/dist/controls/number-editor/tokens.d.ts +28 -0
- package/views/dist/controls/number-editor/tokens.js +9 -0
- package/views/dist/controls/number-editor/words.d.ts +23 -0
- package/views/dist/controls/number-editor/words.js +13 -0
- package/views/dist/controls/number-editor.css +37 -0
- package/views/dist/controls/number-field/number-field.js +57 -5
- package/views/dist/controls/radio/radio.d.ts +33 -0
- package/views/dist/controls/radio/radio.js +19 -0
- package/views/dist/controls/radio/tokens.d.ts +127 -0
- package/views/dist/controls/radio/tokens.js +34 -0
- package/views/dist/controls/radio.css +104 -0
- package/views/dist/controls/text-editor/phone-number.d.ts +4 -0
- package/views/dist/controls/text-editor/phone-number.js +20 -0
- package/views/dist/controls/text-editor/text-editor.js +2 -19
- package/views/dist/controls/tokens.js +10 -0
- package/views/dist/controls/values-editor/looks.d.ts +16 -0
- package/views/dist/controls/values-editor/looks.js +19 -0
- package/views/dist/controls/values-editor/map-values-body.d.ts +12 -0
- package/views/dist/controls/values-editor/map-values-body.js +71 -0
- package/views/dist/controls/values-editor/tokens.d.ts +132 -0
- package/views/dist/controls/values-editor/tokens.js +35 -0
- package/views/dist/controls/values-editor/values-editor.d.ts +62 -0
- package/views/dist/controls/values-editor/values-editor.js +435 -0
- package/views/dist/controls/values-editor/values.d.ts +71 -0
- package/views/dist/controls/values-editor/values.js +59 -0
- package/views/dist/controls/values-editor/words.d.ts +50 -0
- package/views/dist/controls/values-editor/words.js +29 -0
- package/views/dist/controls/values-editor.css +207 -0
- package/views/dist/controls/views-list/looks.d.ts +13 -0
- package/views/dist/controls/views-list/looks.js +12 -0
- package/views/dist/controls/views-list/map-views-list-body.d.ts +19 -0
- package/views/dist/controls/views-list/map-views-list-body.js +65 -0
- package/views/dist/controls/views-list/rules.d.ts +72 -0
- package/views/dist/controls/views-list/rules.js +4 -0
- package/views/dist/controls/views-list/tokens.d.ts +11 -0
- package/views/dist/controls/views-list/tokens.js +5 -0
- package/views/dist/controls/views-list/views-list.d.ts +44 -0
- package/views/dist/controls/views-list/views-list.js +57 -0
- package/views/dist/controls/views-list/words.d.ts +22 -0
- package/views/dist/controls/views-list/words.js +3 -0
- package/views/dist/controls/views-list.css +8 -0
- package/views/dist/editors/NumberEditor.js +3 -1
- package/views/dist/grid/chrome/GridCellEditors.js +1 -1
- package/views/dist/grid/chrome/GridDateEditor.d.ts +3 -1
- package/views/dist/grid/chrome/GridDateEditor.js +2 -1
- package/views/dist/looks/index.d.ts +3 -0
- package/views/dist/looks/index.js +3 -0
- package/views/dist/looks/pieces.js +6 -0
- package/views/dist/provider/components.d.ts +4 -0
- package/views/dist/styles.css +432 -2
- package/views/dist/styles.unlayered.css +432 -2
- package/views/docs/contract.md +10 -8
- package/views/docs/controls/links-editor.md +25 -0
- package/views/docs/controls/number-editor.md +12 -0
- package/views/docs/controls/radio.md +39 -0
- package/views/docs/controls/values-editor.md +40 -0
- package/views/docs/controls/views-list.md +8 -0
- package/views/docs/reference/controls.md +117 -5
- package/views/docs/reference/looks.md +9 -2
- package/views/docs/reference/react.md +2 -2
package/views/dist/contract.js
CHANGED
|
@@ -506,6 +506,35 @@ export const VIEWS_MESSAGE_KEYS = [
|
|
|
506
506
|
"views.editors.values-main",
|
|
507
507
|
"views.editors.values-make-main",
|
|
508
508
|
"views.editors.values-remove",
|
|
509
|
+
"views.editors.values-line-email",
|
|
510
|
+
"views.editors.values-line-link",
|
|
511
|
+
"views.editors.values-line-domain",
|
|
512
|
+
"views.editors.values-card-line-email",
|
|
513
|
+
"views.editors.values-card-line-link",
|
|
514
|
+
"views.editors.values-card-line-domain",
|
|
515
|
+
"views.editors.values-add-email",
|
|
516
|
+
"views.editors.values-add-phone",
|
|
517
|
+
"views.editors.values-add-link",
|
|
518
|
+
"views.editors.values-add-domain",
|
|
519
|
+
"views.editors.values-nth-email",
|
|
520
|
+
"views.editors.values-nth-phone",
|
|
521
|
+
"views.editors.values-nth-link",
|
|
522
|
+
"views.editors.values-nth-domain",
|
|
523
|
+
"views.editors.values-change",
|
|
524
|
+
"views.editors.values-copy",
|
|
525
|
+
"views.editors.values-move",
|
|
526
|
+
"views.editors.values-label-is",
|
|
527
|
+
"views.editors.values-no-label",
|
|
528
|
+
"views.editors.values-label-search",
|
|
529
|
+
"views.editors.values-label-find",
|
|
530
|
+
"views.editors.values-country-code",
|
|
531
|
+
"views.editors.values-country-is",
|
|
532
|
+
"views.editors.values-country-code-is",
|
|
533
|
+
"views.editors.values-back-to",
|
|
534
|
+
"views.editors.values-label-work",
|
|
535
|
+
"views.editors.values-label-personal",
|
|
536
|
+
"views.editors.values-label-mobile",
|
|
537
|
+
"views.editors.values-label-other",
|
|
509
538
|
"views.editors.discard",
|
|
510
539
|
"views.editors.save",
|
|
511
540
|
"views.editors.back",
|
|
@@ -542,6 +571,12 @@ export const VIEWS_MESSAGE_KEYS = [
|
|
|
542
571
|
"views.editors.number-increase",
|
|
543
572
|
"views.editors.number-decrease",
|
|
544
573
|
"views.editors.number-field",
|
|
574
|
+
"views.editors.number-unit",
|
|
575
|
+
"views.editors.number-find-currency",
|
|
576
|
+
"views.editors.number-search-currency",
|
|
577
|
+
"views.editors.number-find-unit",
|
|
578
|
+
"views.editors.number-search-unit",
|
|
579
|
+
"views.editors.number-unit-named",
|
|
545
580
|
"views.editors.place-region-area",
|
|
546
581
|
"views.editors.place-region-county",
|
|
547
582
|
"views.editors.place-region-department",
|
|
@@ -736,6 +771,24 @@ export const VIEWS_MESSAGE_KEYS = [
|
|
|
736
771
|
"views.picker.back",
|
|
737
772
|
"views.picker.row-actions",
|
|
738
773
|
"views.picker.you",
|
|
774
|
+
"views.editors.links-search",
|
|
775
|
+
"views.editors.links-roles",
|
|
776
|
+
"views.editors.links-add",
|
|
777
|
+
"views.editors.links-add-to",
|
|
778
|
+
"views.editors.links-link",
|
|
779
|
+
"views.editors.links-unlink",
|
|
780
|
+
"views.editors.links-unlink-record",
|
|
781
|
+
"views.editors.links-is-lead",
|
|
782
|
+
"views.editors.links-edit",
|
|
783
|
+
"views.editors.links-menu",
|
|
784
|
+
"views.editors.links-field-at",
|
|
785
|
+
"views.editors.links-search-roles",
|
|
786
|
+
"views.editors.links-none",
|
|
787
|
+
"views.editors.links-no-details",
|
|
788
|
+
"views.editors.links-yes",
|
|
789
|
+
"views.editors.links-no",
|
|
790
|
+
"views.editors.links-all-linked",
|
|
791
|
+
"views.editors.links-done",
|
|
739
792
|
"views.panels.date-range-all",
|
|
740
793
|
"views.panels.date-range-between",
|
|
741
794
|
"views.panels.date-range-from",
|
|
@@ -759,6 +812,7 @@ export const VIEWS_MESSAGE_KEYS = [
|
|
|
759
812
|
"views.panels.view-change",
|
|
760
813
|
"views.panels.view-fallback",
|
|
761
814
|
"views.panels.views-search",
|
|
815
|
+
"views.panels.views-find",
|
|
762
816
|
"views.panels.views-list",
|
|
763
817
|
"views.panels.views-shared",
|
|
764
818
|
"views.panels.views-personal",
|
|
@@ -1068,6 +1122,64 @@ export function resolveViewsMessage(message) {
|
|
|
1068
1122
|
return `Make ${message.values.value} the main one`;
|
|
1069
1123
|
case "views.editors.values-remove":
|
|
1070
1124
|
return `Remove ${message.values.value}`;
|
|
1125
|
+
case "views.editors.values-line-email":
|
|
1126
|
+
return "Add email…";
|
|
1127
|
+
case "views.editors.values-line-link":
|
|
1128
|
+
return "Add link…";
|
|
1129
|
+
case "views.editors.values-line-domain":
|
|
1130
|
+
return "Add domain…";
|
|
1131
|
+
case "views.editors.values-card-line-email":
|
|
1132
|
+
return "Add email";
|
|
1133
|
+
case "views.editors.values-card-line-link":
|
|
1134
|
+
return "Add link";
|
|
1135
|
+
case "views.editors.values-card-line-domain":
|
|
1136
|
+
return "Add domain";
|
|
1137
|
+
case "views.editors.values-add-email":
|
|
1138
|
+
return "Add an email";
|
|
1139
|
+
case "views.editors.values-add-phone":
|
|
1140
|
+
return "Add a phone";
|
|
1141
|
+
case "views.editors.values-add-link":
|
|
1142
|
+
return "Add a link";
|
|
1143
|
+
case "views.editors.values-add-domain":
|
|
1144
|
+
return "Add a domain";
|
|
1145
|
+
case "views.editors.values-nth-email":
|
|
1146
|
+
return `email ${message.values.n}`;
|
|
1147
|
+
case "views.editors.values-nth-phone":
|
|
1148
|
+
return `phone ${message.values.n}`;
|
|
1149
|
+
case "views.editors.values-nth-link":
|
|
1150
|
+
return `link ${message.values.n}`;
|
|
1151
|
+
case "views.editors.values-nth-domain":
|
|
1152
|
+
return `domain ${message.values.n}`;
|
|
1153
|
+
case "views.editors.values-change":
|
|
1154
|
+
return `Change ${message.values.value}`;
|
|
1155
|
+
case "views.editors.values-copy":
|
|
1156
|
+
return `Copy ${message.values.value}`;
|
|
1157
|
+
case "views.editors.values-move":
|
|
1158
|
+
return `Move ${message.values.value}`;
|
|
1159
|
+
case "views.editors.values-label-is":
|
|
1160
|
+
return `Label: ${message.values.label}`;
|
|
1161
|
+
case "views.editors.values-no-label":
|
|
1162
|
+
return "none";
|
|
1163
|
+
case "views.editors.values-label-search":
|
|
1164
|
+
return "Search or type a label";
|
|
1165
|
+
case "views.editors.values-label-find":
|
|
1166
|
+
return "Find or type a label";
|
|
1167
|
+
case "views.editors.values-country-code":
|
|
1168
|
+
return "Country code";
|
|
1169
|
+
case "views.editors.values-country-is":
|
|
1170
|
+
return `Country: ${message.values.country}`;
|
|
1171
|
+
case "views.editors.values-country-code-is":
|
|
1172
|
+
return `Country code: ${message.values.country}`;
|
|
1173
|
+
case "views.editors.values-back-to":
|
|
1174
|
+
return `Back to ${message.values.label}`;
|
|
1175
|
+
case "views.editors.values-label-work":
|
|
1176
|
+
return "Work";
|
|
1177
|
+
case "views.editors.values-label-personal":
|
|
1178
|
+
return "Personal";
|
|
1179
|
+
case "views.editors.values-label-mobile":
|
|
1180
|
+
return "Mobile";
|
|
1181
|
+
case "views.editors.values-label-other":
|
|
1182
|
+
return "Other";
|
|
1071
1183
|
case "views.editors.discard":
|
|
1072
1184
|
return "Discard";
|
|
1073
1185
|
case "views.editors.save":
|
|
@@ -1140,6 +1252,18 @@ export function resolveViewsMessage(message) {
|
|
|
1140
1252
|
return "Decrease";
|
|
1141
1253
|
case "views.editors.number-field":
|
|
1142
1254
|
return "Number field";
|
|
1255
|
+
case "views.editors.number-unit":
|
|
1256
|
+
return "Unit";
|
|
1257
|
+
case "views.editors.number-find-currency":
|
|
1258
|
+
return "Find a currency";
|
|
1259
|
+
case "views.editors.number-search-currency":
|
|
1260
|
+
return "Search for a currency";
|
|
1261
|
+
case "views.editors.number-find-unit":
|
|
1262
|
+
return "Find a unit";
|
|
1263
|
+
case "views.editors.number-search-unit":
|
|
1264
|
+
return "Search for a unit";
|
|
1265
|
+
case "views.editors.number-unit-named":
|
|
1266
|
+
return `${message.values.unit}: ${message.values.name}`;
|
|
1143
1267
|
case "views.editors.place-region-area":
|
|
1144
1268
|
return "Area";
|
|
1145
1269
|
case "views.editors.place-region-county":
|
|
@@ -1528,6 +1652,42 @@ export function resolveViewsMessage(message) {
|
|
|
1528
1652
|
return `Actions for ${message.values.label}`;
|
|
1529
1653
|
case "views.picker.you":
|
|
1530
1654
|
return "you";
|
|
1655
|
+
case "views.editors.links-search":
|
|
1656
|
+
return "Search…";
|
|
1657
|
+
case "views.editors.links-roles":
|
|
1658
|
+
return "Roles";
|
|
1659
|
+
case "views.editors.links-add":
|
|
1660
|
+
return "Add";
|
|
1661
|
+
case "views.editors.links-add-to":
|
|
1662
|
+
return `Add to ${message.values.label}`;
|
|
1663
|
+
case "views.editors.links-link":
|
|
1664
|
+
return `Link ${message.values.label}`;
|
|
1665
|
+
case "views.editors.links-unlink":
|
|
1666
|
+
return "Unlink";
|
|
1667
|
+
case "views.editors.links-unlink-record":
|
|
1668
|
+
return `Unlink ${message.values.label}`;
|
|
1669
|
+
case "views.editors.links-is-lead":
|
|
1670
|
+
return `${message.values.label} is the ${message.values.lead.toLowerCase()}`;
|
|
1671
|
+
case "views.editors.links-edit":
|
|
1672
|
+
return `Edit the link to ${message.values.label}`;
|
|
1673
|
+
case "views.editors.links-menu":
|
|
1674
|
+
return `the link to ${message.values.label}`;
|
|
1675
|
+
case "views.editors.links-field-at":
|
|
1676
|
+
return `${message.values.field} at ${message.values.label}`;
|
|
1677
|
+
case "views.editors.links-search-roles":
|
|
1678
|
+
return "Search roles…";
|
|
1679
|
+
case "views.editors.links-none":
|
|
1680
|
+
return "None";
|
|
1681
|
+
case "views.editors.links-no-details":
|
|
1682
|
+
return "No details";
|
|
1683
|
+
case "views.editors.links-yes":
|
|
1684
|
+
return "Yes";
|
|
1685
|
+
case "views.editors.links-no":
|
|
1686
|
+
return "No";
|
|
1687
|
+
case "views.editors.links-all-linked":
|
|
1688
|
+
return "Everything is linked.";
|
|
1689
|
+
case "views.editors.links-done":
|
|
1690
|
+
return "Done";
|
|
1531
1691
|
case "views.panels.relation-value-one":
|
|
1532
1692
|
return `${message.values.quantifier} · ${message.values.field}: ${message.values.value}`;
|
|
1533
1693
|
case "views.panels.relation-value-many":
|
|
@@ -1583,6 +1743,8 @@ export function resolveViewsMessage(message) {
|
|
|
1583
1743
|
return "View";
|
|
1584
1744
|
case "views.panels.views-search":
|
|
1585
1745
|
return "Search views…";
|
|
1746
|
+
case "views.panels.views-find":
|
|
1747
|
+
return "Find a view";
|
|
1586
1748
|
case "views.panels.views-list":
|
|
1587
1749
|
return "Views";
|
|
1588
1750
|
case "views.panels.views-shared":
|
|
@@ -52,7 +52,8 @@ export function compoundEditorWordsOf(say) {
|
|
|
52
52
|
export function partsBodyPropsOf(p, words) {
|
|
53
53
|
const common = { label: p.label, autoFocus: p.autoFocus, form: p.form, draft: "shell", ...(words ? { words } : {}) };
|
|
54
54
|
if (p.kind === "name")
|
|
55
|
-
return { ...common, kind: "name", value: p.value, empty: p.empty,
|
|
55
|
+
return { ...common, kind: "name", value: p.value, empty: p.empty, ...(p.typed !== undefined ? { typing: { given: p.value.given } } : {}),
|
|
56
|
+
onValueChange: (v) => p.onValueChange(v ?? NO_NAME), onDone: () => p.onDone() };
|
|
56
57
|
if (p.kind === "place")
|
|
57
58
|
return { ...common, kind: "place", value: codelessRegion(p), parts: [...p.parts], required: [...p.required], countries: placeCountriesOf(p),
|
|
58
59
|
...(p.opens ? { opens: p.opens } : {}), onValueChange: (v) => p.onValueChange(v ?? {}), onDone: () => p.onDone() };
|
|
@@ -33,10 +33,18 @@ export function useNameParts(props, worn, wornAt) {
|
|
|
33
33
|
const joined = fullOf(given, family), own = !!line?.trim() && line.trim() !== joined;
|
|
34
34
|
const next = shownAs ? nameOf(given, family, line) : keptName(value, given, family);
|
|
35
35
|
const note = !shell && next === null && !empty && value ? `A person needs a name. Closing keeps ${value.full}.` : null;
|
|
36
|
-
const [opened, setOpened] = React.useState(value);
|
|
36
|
+
const [opened, setOpened] = React.useState(typing ? null : value);
|
|
37
37
|
const typedLine = shownAs ? (line != null ? (line.trim() ? line : joined) : null) : (keptName(opened, given, family)?.full ?? joined);
|
|
38
38
|
const handed = nameHanded(value ?? NO_NAME, given, family, typedLine);
|
|
39
|
-
useShellHand(shell, handed, value ?? NO_NAME, (a, b) => sameNameEcho(a, b) && (typedLine == null || a.full === b.full), onValueChange, (v) => { setNow(startOf(v)); setOpened(v); });
|
|
39
|
+
const handNow = useShellHand(shell, handed, value ?? NO_NAME, (a, b) => sameNameEcho(a, b) && (typedLine == null || a.full === b.full), onValueChange, (v) => { setNow(startOf(v)); setOpened(v); });
|
|
40
|
+
const typedHanded = React.useRef(false);
|
|
41
|
+
React.useEffect(() => {
|
|
42
|
+
if (typedHanded.current || !shell || !typing)
|
|
43
|
+
return;
|
|
44
|
+
typedHanded.current = true;
|
|
45
|
+
if (handed.full !== (value ?? NO_NAME).full)
|
|
46
|
+
handNow(handed);
|
|
47
|
+
}, [shell, typing, handed, value, handNow]);
|
|
40
48
|
const settled = React.useRef(false), last = React.useRef(null);
|
|
41
49
|
const first = useFocusFirst(autoFocus);
|
|
42
50
|
const part = (key, v) => setNow((d) => ({ ...d, [key]: v, line: d.line != null && (!d.line.trim() || d.line.trim() === fullOf(d.given, d.family)) ? null : d.line }));
|
|
@@ -34,7 +34,8 @@ export declare const ATTIO_ROWS: PlacePart[][];
|
|
|
34
34
|
* in one row. In Attio's: the same rows for every country, each kept to the field's parts, line 2 riding in line 1's box. */
|
|
35
35
|
export declare function rowsOf(country: Country | undefined, parts: PlacePart[], held?: PlaceValue, order?: PlaceOrder): PlacePart[][];
|
|
36
36
|
/** A part's words for a country: the field's own for it, else the editor's for it, else Attio's words in Attio's look, or
|
|
37
|
-
* the editor's, the short ones on a phone where they are long; each of those last the app's where `words` hands them.
|
|
37
|
+
* the editor's, the short ones on a phone where they are long; each of those last the app's where `words` hands them.
|
|
38
|
+
* In Attio's look the street is one box holding both lines, so it takes Attio's word whatever the country (VK-806). */
|
|
38
39
|
export declare function wordOf(country: Country | undefined, part: PlacePart, o?: {
|
|
39
40
|
phone?: boolean;
|
|
40
41
|
attio?: boolean;
|
|
@@ -23,6 +23,8 @@ export function rowsOf(country, parts, held, order = "country") {
|
|
|
23
23
|
return parts.includes("line1") ? kept : kept.length ? [kept.flat()] : [];
|
|
24
24
|
}
|
|
25
25
|
export function wordOf(country, part, o = {}) {
|
|
26
|
+
if (o.attio && (part === "line1" || part === "line2"))
|
|
27
|
+
return o.words?.attio?.[part] ?? ATTIO_WORDS[part];
|
|
26
28
|
const own = country?.words?.[part] ?? (country && KNOWN[country.code]?.words?.[part]);
|
|
27
29
|
if (own != null)
|
|
28
30
|
return own;
|
|
@@ -5,12 +5,16 @@ import { MapSheet } from "./sheet/map-sheet.js";
|
|
|
5
5
|
import { MapCheckbox } from "./checkbox/map-checkbox.js";
|
|
6
6
|
import { MapInput } from "./input/map-input.js";
|
|
7
7
|
import { MapMenu } from "./menu/map-menu.js";
|
|
8
|
+
import { MapViewsListBody } from "./views-list/map-views-list-body.js";
|
|
8
9
|
import { MapTextBody } from "./text-editor/map-text-body.js";
|
|
9
10
|
import { MapPicker } from "./picker/map-picker.js";
|
|
10
11
|
import { MapFieldsBody } from "./picker/map-fields-body.js";
|
|
11
12
|
import { MapDateBody } from "./date-editor/map-date-body.js";
|
|
12
13
|
import { MapCalendar } from "./date-editor/map-calendar.js";
|
|
13
14
|
import { MapPartsBody } from "./compound-editor/map-parts-body.js";
|
|
15
|
+
import { MapNumberBody } from "./number-editor/map-number-body.js";
|
|
16
|
+
import { MapValuesBody } from "./values-editor/map-values-body.js";
|
|
17
|
+
import { MapLinksBody } from "./links-editor/map-links-body.js";
|
|
14
18
|
export declare const CONTROLS: {
|
|
15
19
|
Button: typeof MapButton;
|
|
16
20
|
Tooltip: typeof MapTooltip;
|
|
@@ -19,10 +23,14 @@ export declare const CONTROLS: {
|
|
|
19
23
|
Input: typeof MapInput;
|
|
20
24
|
Checkbox: typeof MapCheckbox;
|
|
21
25
|
Menu: typeof MapMenu;
|
|
26
|
+
ViewsListBody: typeof MapViewsListBody;
|
|
22
27
|
TextBody: typeof MapTextBody;
|
|
23
28
|
Picker: typeof MapPicker;
|
|
24
29
|
FieldsBody: typeof MapFieldsBody;
|
|
25
30
|
DateBody: typeof MapDateBody;
|
|
26
31
|
Calendar: typeof MapCalendar;
|
|
27
32
|
PartsBody: typeof MapPartsBody;
|
|
33
|
+
NumberBody: typeof MapNumberBody;
|
|
34
|
+
ValuesBody: typeof MapValuesBody;
|
|
35
|
+
LinksBody: typeof MapLinksBody;
|
|
28
36
|
};
|
|
@@ -5,12 +5,16 @@ import { MapSheet } from "./sheet/map-sheet.js";
|
|
|
5
5
|
import { MapCheckbox } from "./checkbox/map-checkbox.js";
|
|
6
6
|
import { MapInput } from "./input/map-input.js";
|
|
7
7
|
import { MapMenu } from "./menu/map-menu.js";
|
|
8
|
+
import { MapViewsListBody } from "./views-list/map-views-list-body.js";
|
|
8
9
|
import { MapTextBody } from "./text-editor/map-text-body.js";
|
|
9
10
|
import { MapPicker } from "./picker/map-picker.js";
|
|
10
11
|
import { MapFieldsBody } from "./picker/map-fields-body.js";
|
|
11
12
|
import { MapDateBody } from "./date-editor/map-date-body.js";
|
|
12
13
|
import { MapCalendar } from "./date-editor/map-calendar.js";
|
|
13
14
|
import { MapPartsBody } from "./compound-editor/map-parts-body.js";
|
|
15
|
+
import { MapNumberBody } from "./number-editor/map-number-body.js";
|
|
16
|
+
import { MapValuesBody } from "./values-editor/map-values-body.js";
|
|
17
|
+
import { MapLinksBody } from "./links-editor/map-links-body.js";
|
|
14
18
|
export const CONTROLS = {
|
|
15
19
|
Button: MapButton,
|
|
16
20
|
Tooltip: MapTooltip,
|
|
@@ -19,10 +23,14 @@ export const CONTROLS = {
|
|
|
19
23
|
Input: MapInput,
|
|
20
24
|
Checkbox: MapCheckbox,
|
|
21
25
|
Menu: MapMenu,
|
|
26
|
+
ViewsListBody: MapViewsListBody,
|
|
22
27
|
TextBody: MapTextBody,
|
|
23
28
|
Picker: MapPicker,
|
|
24
29
|
FieldsBody: MapFieldsBody,
|
|
25
30
|
DateBody: MapDateBody,
|
|
26
31
|
Calendar: MapCalendar,
|
|
27
32
|
PartsBody: MapPartsBody,
|
|
33
|
+
NumberBody: MapNumberBody,
|
|
34
|
+
ValuesBody: MapValuesBody,
|
|
35
|
+
LinksBody: MapLinksBody,
|
|
28
36
|
};
|
|
@@ -53,6 +53,11 @@ export { Select, SelectShown, toPickerItems, type SelectAloneProps, type SelectI
|
|
|
53
53
|
export { listSide, type ListSide } from "./select/side.js";
|
|
54
54
|
export { chipsThatFit } from "./select/fit.js";
|
|
55
55
|
export { filledMatch } from "./select/filled.js";
|
|
56
|
+
export { Radio, RadioGroup, type RadioGroupProps, type RadioProps } from "./radio/radio.js";
|
|
57
|
+
export { LOCK, useViewsList, useViewsListWorn, ViewsList, type ViewsListParts } from "./views-list/views-list.js";
|
|
58
|
+
export { JUST_ME, listed, SHARED, type ListView, type ViewsListChange, type ViewsListLayout } from "./views-list/rules.js";
|
|
59
|
+
export { VIEWS_LIST_ATTRS, viewsListWornOf, type ViewsListWorn } from "./views-list/looks.js";
|
|
60
|
+
export { VIEWS_LIST_WORDS, viewsListWords, type ViewsListWords } from "./views-list/words.js";
|
|
56
61
|
export { useTextEditor, type TextEditorParts } from "./text-editor/text-editor.js";
|
|
57
62
|
export { TEXT_KEYS, enterDoes, kept, lineOf, midWord, ownChange, textRefusal, tidy, type TextKeys, type TextKind } from "./text-editor/check.js";
|
|
58
63
|
export { DIALS, countryName, dialOf, exampleOf, patternOf, phoneHanded, phoneOf, phoneParts, type Dial } from "./text-editor/phone-number.js";
|
|
@@ -73,3 +78,14 @@ export type { Range } from "./compound-editor/range.js";
|
|
|
73
78
|
export { compoundEditorRead, compoundEditorWornOf, type CompoundEditorWorn } from "./compound-editor/looks.js";
|
|
74
79
|
export { COMPOUND_EDITOR_WORDS, compoundWords, type CompoundEditorWords } from "./compound-editor/words.js";
|
|
75
80
|
export { Flag } from "./flag/flag.js";
|
|
81
|
+
export { useNumberEditor, useNumberEditorWorn, type NumberEditorParts, type NumberEditorProps } from "./number-editor/number-editor.js";
|
|
82
|
+
export { boxLocale, numberText, readTyped, type Currency, type NumberKind, type Unit, type Units } from "./number-editor/format.js";
|
|
83
|
+
export { NUMBER_EDITOR_ATTRS, numberEditorWornOf, type NumberEditorWorn } from "./number-editor/looks.js";
|
|
84
|
+
export { NUMBER_EDITOR_WORDS, numberWords, type NumberEditorWords } from "./number-editor/words.js";
|
|
85
|
+
export { ValuesEditor, useValuesEditor, useValuesEditorWorn, type ValuesEditorParts, type ValuesEditorProps } from "./values-editor/values-editor.js";
|
|
86
|
+
export { LABELS, added, charsThatFit, labelFor, listOf, openOf, splitEmail, valuesText, type DialCode, type ListedValue, type ValuesKind } from "./values-editor/values.js";
|
|
87
|
+
export { VALUES_EDITOR_ATTRS, valuesEditorWornOf, type ValuesEditorWorn } from "./values-editor/looks.js";
|
|
88
|
+
export { VALUES_EDITOR_WORDS, valuesWords, type ValuesEditorWords } from "./values-editor/words.js";
|
|
89
|
+
export { LinksEditor, useLinksEditor, type LinksEditorAction, type LinksEditorLead, type LinksEditorOpens, type LinksEditorParts, type LinksEditorProps, } from "./links-editor/links-editor.js";
|
|
90
|
+
export { found, heldOf, leadAfter, offered, removed, said, saidShort, setValue, ticked, type LinkChoice, type LinkField, type LinkFieldKind, type LinkValue, } from "./links-editor/links.js";
|
|
91
|
+
export { LINKS_EDITOR_WORDS, linksWords, type LinksEditorWords } from "./links-editor/words.js";
|
|
@@ -47,6 +47,11 @@ export { Select, SelectShown, toPickerItems, } from "./select/select.js";
|
|
|
47
47
|
export { listSide } from "./select/side.js";
|
|
48
48
|
export { chipsThatFit } from "./select/fit.js";
|
|
49
49
|
export { filledMatch } from "./select/filled.js";
|
|
50
|
+
export { Radio, RadioGroup } from "./radio/radio.js";
|
|
51
|
+
export { LOCK, useViewsList, useViewsListWorn, ViewsList } from "./views-list/views-list.js";
|
|
52
|
+
export { JUST_ME, listed, SHARED } from "./views-list/rules.js";
|
|
53
|
+
export { VIEWS_LIST_ATTRS, viewsListWornOf } from "./views-list/looks.js";
|
|
54
|
+
export { VIEWS_LIST_WORDS, viewsListWords } from "./views-list/words.js";
|
|
50
55
|
export { useTextEditor } from "./text-editor/text-editor.js";
|
|
51
56
|
export { TEXT_KEYS, enterDoes, kept, lineOf, midWord, ownChange, textRefusal, tidy } from "./text-editor/check.js";
|
|
52
57
|
export { DIALS, countryName, dialOf, exampleOf, patternOf, phoneHanded, phoneOf, phoneParts } from "./text-editor/phone-number.js";
|
|
@@ -66,3 +71,14 @@ export { ATTIO_ROWS, PLACE_PARTS, countriesOf, placeLine, placeOf, placeText, re
|
|
|
66
71
|
export { compoundEditorRead, compoundEditorWornOf } from "./compound-editor/looks.js";
|
|
67
72
|
export { COMPOUND_EDITOR_WORDS, compoundWords } from "./compound-editor/words.js";
|
|
68
73
|
export { Flag } from "./flag/flag.js";
|
|
74
|
+
export { useNumberEditor, useNumberEditorWorn } from "./number-editor/number-editor.js";
|
|
75
|
+
export { boxLocale, numberText, readTyped } from "./number-editor/format.js";
|
|
76
|
+
export { NUMBER_EDITOR_ATTRS, numberEditorWornOf } from "./number-editor/looks.js";
|
|
77
|
+
export { NUMBER_EDITOR_WORDS, numberWords } from "./number-editor/words.js";
|
|
78
|
+
export { ValuesEditor, useValuesEditor, useValuesEditorWorn } from "./values-editor/values-editor.js";
|
|
79
|
+
export { LABELS, added, charsThatFit, labelFor, listOf, openOf, splitEmail, valuesText } from "./values-editor/values.js";
|
|
80
|
+
export { VALUES_EDITOR_ATTRS, valuesEditorWornOf } from "./values-editor/looks.js";
|
|
81
|
+
export { VALUES_EDITOR_WORDS, valuesWords } from "./values-editor/words.js";
|
|
82
|
+
export { LinksEditor, useLinksEditor, } from "./links-editor/links-editor.js";
|
|
83
|
+
export { found, heldOf, leadAfter, offered, removed, said, saidShort, setValue, ticked, } from "./links-editor/links.js";
|
|
84
|
+
export { LINKS_EDITOR_WORDS, linksWords } from "./links-editor/words.js";
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ButtonOwnLook } from "../button/own-look.js";
|
|
2
|
+
import { type PickerProps } from "../picker/picker.js";
|
|
3
|
+
import { type SheetHeadProps } from "../sheet/bottom-sheet.js";
|
|
4
|
+
/** A mark as the editors draw it: its paths on a 24 grid, in the words' colour. */
|
|
5
|
+
export declare const glyph: (paths: string[], className?: string) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
/** A dot of a mark, at x and y. */
|
|
7
|
+
export declare const dots: (x: number, y: number) => string;
|
|
8
|
+
export declare const X: string[], PLUS: string[], TICK: string[];
|
|
9
|
+
export declare const DOTS: string[];
|
|
10
|
+
/** ⋯ on a phone, 40 × 44, the Button: no edge, its press the card's. */
|
|
11
|
+
export declare const DOTS_LOOK: ButtonOwnLook;
|
|
12
|
+
/** A Picker in a full Sheet on top of the editor's, its name the title: a link's field. `onGone` once its Sheet has gone, so what
|
|
13
|
+
* holds it can drop it then. The Picker's words come in its props (`picker.words`), its head's ✕ and ‹ names in `words`. */
|
|
14
|
+
export declare function OnTop({ open, onOpenChange, onGone, title, picker, container, standing, words }: {
|
|
15
|
+
open: boolean;
|
|
16
|
+
onOpenChange: (open: boolean) => void;
|
|
17
|
+
onGone: () => void;
|
|
18
|
+
title: string;
|
|
19
|
+
picker: Omit<PickerProps, "form" | "onDone">;
|
|
20
|
+
container?: HTMLElement | null;
|
|
21
|
+
standing: boolean;
|
|
22
|
+
words?: SheetHeadProps["words"];
|
|
23
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
24
|
+
/** The room a list a page shows standing open needs, on a computer: it stands over the rows under what opens it (`selector`, in
|
|
25
|
+
* the editor's body `root`), and the body grows by what it runs past, since the Popover round the body cuts it. Read again as
|
|
26
|
+
* the list resizes, and whenever one of `again` changes. Nothing on a phone. */
|
|
27
|
+
export declare function useStandingRoom(root: HTMLElement | null, selector: string, phone: boolean, again: readonly unknown[]): number;
|
|
28
|
+
/** On a phone, the Sheet head's ✕ and ✓ round an editor whose every change is handed on as it is made: ✕ takes what it holds
|
|
29
|
+
* back to what it held as its body was placed (the Sheet opening on it, which mounts the body afresh each time), then closes; ✓
|
|
30
|
+
* keeps it, as it is already. `place` is handed the body's element as it comes and goes; `now` is what it holds, a change ahead
|
|
31
|
+
* of the next render; `words` the two buttons' names. */
|
|
32
|
+
export declare function useDecide<T>(now: {
|
|
33
|
+
current: T;
|
|
34
|
+
}, change: (was: T) => void, onDone?: () => void, words?: {
|
|
35
|
+
close: string;
|
|
36
|
+
save: string;
|
|
37
|
+
}): {
|
|
38
|
+
place: (el: HTMLElement | null) => void;
|
|
39
|
+
head: Pick<SheetHeadProps, "left" | "right">;
|
|
40
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { usePicker } from "../picker/picker.js";
|
|
5
|
+
import { Sheet, SheetBody, SheetButton, SheetHead } from "../sheet/bottom-sheet.js";
|
|
6
|
+
import { drawnAt } from "./scroll.js";
|
|
7
|
+
export const glyph = (paths, className) => (_jsx("svg", { className: className, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: paths.map((d) => _jsx("path", { d: d }, d)) }));
|
|
8
|
+
export const dots = (x, y) => `M${x} ${y}m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0`;
|
|
9
|
+
export const X = ["M18 6l-12 12", "M6 6l12 12"], PLUS = ["M12 5l0 14", "M5 12l14 0"], TICK = ["M5 12l5 5l10 -10"];
|
|
10
|
+
export const DOTS = [dots(5, 12), dots(12, 12), dots(19, 12)];
|
|
11
|
+
export const DOTS_LOOK = { radius: "md", corner: "round", edge: "none", words: "inherit", icon: "20", hover: "none", press: "card" };
|
|
12
|
+
export function OnTop({ open, onOpenChange, onGone, title, picker, container, standing, words }) {
|
|
13
|
+
const parts = usePicker({ ...picker, form: "phone", onDone: () => onOpenChange(false) });
|
|
14
|
+
return (_jsxs(Sheet, { open: open, onOpenChange: (o) => onOpenChange(o), onOpenChangeComplete: (o) => { if (!o)
|
|
15
|
+
onGone(); }, label: title, form: "full", container: container, standing: standing, children: [_jsx(SheetHead, { title: title, ...(words ? { words } : {}), ...parts.head }), _jsx(SheetBody, { children: parts.body })] }));
|
|
16
|
+
}
|
|
17
|
+
export function useStandingRoom(root, selector, phone, again) {
|
|
18
|
+
const [room, setRoom] = React.useState(0);
|
|
19
|
+
React.useLayoutEffect(() => {
|
|
20
|
+
const list = root?.querySelector(selector);
|
|
21
|
+
if (!root || !list || phone) {
|
|
22
|
+
setRoom(0);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const read = () => {
|
|
26
|
+
const k = drawnAt(root) || 1, pad = parseFloat(getComputedStyle(root).paddingBottom) || 0;
|
|
27
|
+
const over = (list.getBoundingClientRect().bottom - root.getBoundingClientRect().bottom) / k + pad;
|
|
28
|
+
setRoom((r) => { const next = Math.max(0, Math.ceil(over)); return r === next ? r : next; });
|
|
29
|
+
};
|
|
30
|
+
read();
|
|
31
|
+
const watch = new ResizeObserver(read);
|
|
32
|
+
watch.observe(list);
|
|
33
|
+
return () => watch.disconnect();
|
|
34
|
+
}, [root, selector, phone, ...again]);
|
|
35
|
+
return room;
|
|
36
|
+
}
|
|
37
|
+
export function useDecide(now, change, onDone, words = { close: "Close", save: "Save" }) {
|
|
38
|
+
const opened = React.useRef(null);
|
|
39
|
+
const place = React.useCallback((el) => { opened.current = el ? opened.current ?? now.current : null; }, [now]);
|
|
40
|
+
const leave = () => { const was = opened.current; if (was && JSON.stringify(was) !== JSON.stringify(now.current))
|
|
41
|
+
change(was); onDone?.(); };
|
|
42
|
+
return { place, head: { left: _jsx(SheetButton, { "aria-label": words.close, icon: glyph(X), onClick: leave }), right: _jsx(SheetButton, { kind: "primary", "aria-label": words.save, icon: glyph(TICK), onClick: () => onDone?.() }) } };
|
|
43
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { type PickerItem } from "../picker/picker.js";
|
|
3
|
+
import { type SheetHeadProps } from "../sheet/bottom-sheet.js";
|
|
4
|
+
import { type Link, type LinkField } from "./links.js";
|
|
5
|
+
import { type LinksEditorWords } from "./words.js";
|
|
6
|
+
export type { Link, LinkField, LinkFieldKind, LinkValue } from "./links.js";
|
|
7
|
+
/** One link leads (a person's main company): which, a way to set it (none once nothing is linked), and its column's name. */
|
|
8
|
+
export interface LinksEditorLead {
|
|
9
|
+
value: string | null;
|
|
10
|
+
onLead: (value: string | null) => void;
|
|
11
|
+
label: string;
|
|
12
|
+
}
|
|
13
|
+
/** What a page shows standing open: a field's list on a link, or a link's fields. */
|
|
14
|
+
export type LinksEditorOpens = {
|
|
15
|
+
list: string;
|
|
16
|
+
link: string;
|
|
17
|
+
} | {
|
|
18
|
+
config: string;
|
|
19
|
+
};
|
|
20
|
+
export interface LinksEditorProps {
|
|
21
|
+
/** The field's name ("Companies"): the editor's name to a screen reader, and the Sheet's title on a phone. */
|
|
22
|
+
label: string;
|
|
23
|
+
/** One of its records ("Company"): the first column's name. */
|
|
24
|
+
kind: string;
|
|
25
|
+
/** The records that can be linked, in the list's order; each drawn with its face where it has one. */
|
|
26
|
+
records: PickerItem[];
|
|
27
|
+
/** The fields a link holds, in their columns' order. */
|
|
28
|
+
fields: LinkField[];
|
|
29
|
+
/** The links, in order. */
|
|
30
|
+
links: Link[];
|
|
31
|
+
/** Each change, as it is made: a record linked or unlinked, a field's value changed. */
|
|
32
|
+
onLinksChange: (links: Link[]) => void;
|
|
33
|
+
/** Given when one link leads. */
|
|
34
|
+
lead?: LinksEditorLead;
|
|
35
|
+
/** What the search says before anything is typed ("Search companies…"); "Search…" unless said. */
|
|
36
|
+
search?: string;
|
|
37
|
+
/** Which form; by default the phone's in a phone's window or in a PhoneHost screen, else the computer's. */
|
|
38
|
+
form?: "computer" | "phone";
|
|
39
|
+
/** The job is done and what holds it closes: ✓, or ✕ once the links are back, on a phone. */
|
|
40
|
+
onDone?: () => void;
|
|
41
|
+
/** The search takes the focus as it opens, on a computer; true unless said (a page's case says false). */
|
|
42
|
+
autoFocus?: boolean;
|
|
43
|
+
/** A page's state: what is typed in the search. */
|
|
44
|
+
typed?: string;
|
|
45
|
+
/** A page's state: a field's list standing open on a link, or a link's fields open. */
|
|
46
|
+
opens?: LinksEditorOpens;
|
|
47
|
+
/** Its words; English unless handed. */
|
|
48
|
+
words?: Partial<LinksEditorWords>;
|
|
49
|
+
/** The editor filters or fetches: every typed query is handed here, and `records` are drawn as handed, never filtered again. */
|
|
50
|
+
onSearch?: (query: string) => void;
|
|
51
|
+
/** What the list is doing besides showing its records: a first page in flight, or the last ask failed. */
|
|
52
|
+
doing?: "searching" | "failed";
|
|
53
|
+
/** Ask again after `doing: "failed"`. */
|
|
54
|
+
onRetry?: () => void;
|
|
55
|
+
/** More records are to come: called each time the list's end comes into sight. */
|
|
56
|
+
onMore?: () => void;
|
|
57
|
+
/** Rows that do something rather than link (create a record with what was typed), after the records to add. */
|
|
58
|
+
actions?: LinksEditorAction[];
|
|
59
|
+
/** Data attributes for a link's roles list, drawn outside the body (its Popover): ViewKit's map marks it as an inner level, so
|
|
60
|
+
* an app's popover that hears Escape first leaves it to the list. */
|
|
61
|
+
popupData?: Readonly<Record<`data-${string}`, string>>;
|
|
62
|
+
}
|
|
63
|
+
/** A row that does something rather than link: its key, its words, an optional mark, and what it does. */
|
|
64
|
+
export interface LinksEditorAction {
|
|
65
|
+
key: string;
|
|
66
|
+
label: string;
|
|
67
|
+
icon?: React.ReactNode;
|
|
68
|
+
onSelect: () => void;
|
|
69
|
+
}
|
|
70
|
+
export interface LinksEditorParts {
|
|
71
|
+
body: React.ReactNode;
|
|
72
|
+
/** On a phone, the Sheet head's ✕ and ✓; {} on a computer. */
|
|
73
|
+
head: Pick<SheetHeadProps, "close" | "left" | "right">;
|
|
74
|
+
}
|
|
75
|
+
/** The Links editor's state and the parts a shell pours in. */
|
|
76
|
+
export declare function useLinksEditor(props: LinksEditorProps): LinksEditorParts;
|
|
77
|
+
/** The body alone, for a shell that holds only a body (the Popover). */
|
|
78
|
+
export declare function LinksEditor(props: LinksEditorProps): import("react/jsx-runtime").JSX.Element;
|