@kanso-labs/react-native-kanso-ui 0.9.0 → 0.11.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 +4 -3
- package/dist/autocomplete/index.js +15 -1
- package/dist/autocomplete/index.js.map +1 -1
- package/dist/button/group.d.ts +5 -0
- package/dist/button/group.js +115 -0
- package/dist/button/group.js.map +1 -0
- package/dist/button/index.d.ts +4 -1
- package/dist/button/index.js +44 -22
- package/dist/button/index.js.map +1 -1
- package/dist/button/slots.js +2 -1
- package/dist/button/slots.js.map +1 -1
- package/dist/calendar/index.js +351 -182
- package/dist/calendar/index.js.map +1 -1
- package/dist/calendar/styles.js +33 -2
- package/dist/calendar/styles.js.map +1 -1
- package/dist/carousel/arrangement.d.ts +5 -0
- package/dist/carousel/arrangement.js +123 -0
- package/dist/carousel/arrangement.js.map +1 -0
- package/dist/chequer/index.js +95 -0
- package/dist/chequer/index.js.map +1 -0
- package/dist/collection/index.d.ts +157 -0
- package/dist/collection/index.js +1358 -0
- package/dist/collection/index.js.map +1 -0
- package/dist/color-thumb/index.js +56 -0
- package/dist/color-thumb/index.js.map +1 -0
- package/dist/components/button/index.d.ts +4 -2
- package/dist/components/button/index.js +227 -188
- package/dist/components/button/index.js.map +1 -1
- package/dist/components/button-group/index.d.ts +87 -0
- package/dist/components/button-group/index.js +275 -0
- package/dist/components/button-group/index.js.map +1 -0
- package/dist/components/calendar/index.d.ts +11 -3
- package/dist/components/calendar/index.js +60 -45
- package/dist/components/calendar/index.js.map +1 -1
- package/dist/components/carousel/index.d.ts +72 -0
- package/dist/components/carousel/index.js +496 -0
- package/dist/components/carousel/index.js.map +1 -0
- package/dist/components/checkbox-group/index.d.ts +3 -4
- package/dist/components/checkbox-group/index.js +1 -1
- package/dist/components/checkbox-group/index.js.map +1 -1
- package/dist/components/chip/index.d.ts +4 -1
- package/dist/components/chip/index.js +229 -161
- package/dist/components/chip/index.js.map +1 -1
- package/dist/components/color-area/index.d.ts +85 -0
- package/dist/components/color-area/index.js +630 -0
- package/dist/components/color-area/index.js.map +1 -0
- package/dist/components/color-field/index.d.ts +144 -0
- package/dist/components/color-field/index.js +516 -0
- package/dist/components/color-field/index.js.map +1 -0
- package/dist/components/color-picker/index.d.ts +74 -0
- package/dist/components/color-picker/index.js +317 -0
- package/dist/components/color-picker/index.js.map +1 -0
- package/dist/components/color-slider/index.d.ts +82 -0
- package/dist/components/color-slider/index.js +456 -0
- package/dist/components/color-slider/index.js.map +1 -0
- package/dist/components/color-swatch/index.d.ts +46 -0
- package/dist/components/color-swatch/index.js +127 -0
- package/dist/components/color-swatch/index.js.map +1 -0
- package/dist/components/color-swatch-picker/index.d.ts +81 -0
- package/dist/components/color-swatch-picker/index.js +287 -0
- package/dist/components/color-swatch-picker/index.js.map +1 -0
- package/dist/components/color-wheel/index.d.ts +71 -0
- package/dist/components/color-wheel/index.js +407 -0
- package/dist/components/color-wheel/index.js.map +1 -0
- package/dist/components/combo-box/index.d.ts +193 -0
- package/dist/components/combo-box/index.js +616 -0
- package/dist/components/combo-box/index.js.map +1 -0
- package/dist/components/date-field/index.d.ts +120 -0
- package/dist/components/date-field/index.js +111 -0
- package/dist/components/date-field/index.js.map +1 -0
- package/dist/components/date-picker/index.d.ts +130 -0
- package/dist/components/date-picker/index.js +310 -0
- package/dist/components/date-picker/index.js.map +1 -0
- package/dist/components/date-range-picker/index.d.ts +139 -0
- package/dist/components/date-range-picker/index.js +421 -0
- package/dist/components/date-range-picker/index.js.map +1 -0
- package/dist/components/dialog/index.d.ts +5 -5
- package/dist/components/dialog/index.js +5 -5
- package/dist/components/dialog/index.js.map +1 -1
- package/dist/components/disclosure/index.d.ts +94 -0
- package/dist/components/disclosure/index.js +365 -0
- package/dist/components/disclosure/index.js.map +1 -0
- package/dist/components/disclosure-group/index.d.ts +61 -0
- package/dist/components/disclosure-group/index.js +100 -0
- package/dist/components/disclosure-group/index.js.map +1 -0
- package/dist/components/drop-zone/index.d.ts +113 -0
- package/dist/components/drop-zone/index.js +304 -0
- package/dist/components/drop-zone/index.js.map +1 -0
- package/dist/components/fab/index.d.ts +1 -1
- package/dist/components/fab/index.js +91 -76
- package/dist/components/fab/index.js.map +1 -1
- package/dist/components/form/index.d.ts +3 -2
- package/dist/components/form/index.js.map +1 -1
- package/dist/components/icon-button/index.d.ts +4 -2
- package/dist/components/icon-button/index.js +204 -171
- package/dist/components/icon-button/index.js.map +1 -1
- package/dist/components/list/index.d.ts +15 -158
- package/dist/components/list/index.js +21 -1047
- package/dist/components/list/index.js.map +1 -1
- package/dist/components/list-box/index.d.ts +73 -0
- package/dist/components/list-box/index.js +82 -0
- package/dist/components/list-box/index.js.map +1 -0
- package/dist/components/loading-indicator/index.d.ts +32 -0
- package/dist/components/loading-indicator/index.js +174 -0
- package/dist/components/loading-indicator/index.js.map +1 -0
- package/dist/components/menu/index.d.ts +3 -3
- package/dist/components/menu/index.js +3 -3
- package/dist/components/menu/index.js.map +1 -1
- package/dist/components/navigation-tree/index.d.ts +117 -0
- package/dist/components/navigation-tree/index.js +135 -0
- package/dist/components/navigation-tree/index.js.map +1 -0
- package/dist/components/number-field/index.js +132 -143
- package/dist/components/number-field/index.js.map +1 -1
- package/dist/components/popover/index.d.ts +2 -2
- package/dist/components/popover/index.js +2 -2
- package/dist/components/popover/index.js.map +1 -1
- package/dist/components/range-calendar/index.d.ts +69 -0
- package/dist/components/range-calendar/index.js +144 -0
- package/dist/components/range-calendar/index.js.map +1 -0
- package/dist/components/search-view/index.d.ts +79 -0
- package/dist/components/search-view/index.js +571 -0
- package/dist/components/search-view/index.js.map +1 -0
- package/dist/components/select/index.d.ts +152 -0
- package/dist/components/select/index.js +419 -0
- package/dist/components/select/index.js.map +1 -0
- package/dist/components/sheet/index.d.ts +16 -7
- package/dist/components/sheet/index.js +157 -152
- package/dist/components/sheet/index.js.map +1 -1
- package/dist/components/slider/index.d.ts +111 -0
- package/dist/components/slider/index.js +673 -0
- package/dist/components/slider/index.js.map +1 -0
- package/dist/components/split-button/index.d.ts +77 -0
- package/dist/components/split-button/index.js +354 -0
- package/dist/components/split-button/index.js.map +1 -0
- package/dist/components/table/index.d.ts +391 -0
- package/dist/components/table/index.js +1708 -0
- package/dist/components/table/index.js.map +1 -0
- package/dist/components/tabs/index.d.ts +196 -0
- package/dist/components/tabs/index.js +1137 -0
- package/dist/components/tabs/index.js.map +1 -0
- package/dist/components/time-field/index.d.ts +43 -0
- package/dist/components/time-field/index.js +107 -0
- package/dist/components/time-field/index.js.map +1 -0
- package/dist/components/time-picker/index.d.ts +65 -0
- package/dist/components/time-picker/index.js +1168 -0
- package/dist/components/time-picker/index.js.map +1 -0
- package/dist/components/token-field/index.d.ts +105 -0
- package/dist/components/token-field/index.js +574 -0
- package/dist/components/token-field/index.js.map +1 -0
- package/dist/components/tooltip/index.d.ts +102 -0
- package/dist/components/tooltip/index.js +223 -0
- package/dist/components/tooltip/index.js.map +1 -0
- package/dist/components/tree/index.d.ts +112 -0
- package/dist/components/tree/index.js +157 -0
- package/dist/components/tree/index.js.map +1 -0
- package/dist/disclosure/chevron.js +75 -0
- package/dist/disclosure/chevron.js.map +1 -0
- package/dist/disclosure/index.js +7 -0
- package/dist/disclosure/index.js.map +1 -0
- package/dist/drop/index.d.ts +54 -0
- package/dist/drop/index.js +161 -0
- package/dist/drop/index.js.map +1 -0
- package/dist/field/chevron.js +74 -0
- package/dist/field/chevron.js.map +1 -0
- package/dist/field/index.d.ts +2 -1
- package/dist/field/index.js +359 -154
- package/dist/field/index.js.map +1 -1
- package/dist/field/styles.js +18 -1
- package/dist/field/styles.js.map +1 -1
- package/dist/files/index.d.ts +18 -0
- package/dist/files/index.js +107 -0
- package/dist/files/index.js.map +1 -0
- package/dist/form/index.d.ts +5 -2
- package/dist/form/index.js +64 -85
- package/dist/form/index.js.map +1 -1
- package/dist/glyphs/index.js +128 -1
- package/dist/glyphs/index.js.map +1 -1
- package/dist/i18n/index.js +36 -1
- package/dist/i18n/index.js.map +1 -1
- package/dist/i18n/messages.js +1734 -34
- package/dist/i18n/messages.js.map +1 -1
- package/dist/index.d.ts +37 -3
- package/dist/index.js +36 -3
- package/dist/indicator/paths.js +23 -1
- package/dist/indicator/paths.js.map +1 -1
- package/dist/modal/index.js +92 -77
- package/dist/modal/index.js.map +1 -1
- package/dist/number/keyboard.js +16 -0
- package/dist/number/keyboard.js.map +1 -0
- package/dist/overlay/anchored.js +68 -38
- package/dist/overlay/anchored.js.map +1 -1
- package/dist/overlay/keyboard.js +57 -0
- package/dist/overlay/keyboard.js.map +1 -0
- package/dist/overlay/panel.js +173 -19
- package/dist/overlay/panel.js.map +1 -1
- package/dist/overlay/placement.js +13 -1
- package/dist/overlay/placement.js.map +1 -1
- package/dist/picker/index.js +322 -0
- package/dist/picker/index.js.map +1 -0
- package/dist/press/index.d.ts +2 -0
- package/dist/press/index.js +102 -100
- package/dist/press/index.js.map +1 -1
- package/dist/row/index.js +77 -69
- package/dist/row/index.js.map +1 -1
- package/dist/row/styles.js +13 -2
- package/dist/row/styles.js.map +1 -1
- package/dist/segments/field.js +277 -0
- package/dist/segments/field.js.map +1 -0
- package/dist/segments/index.js +574 -0
- package/dist/segments/index.js.map +1 -0
- package/dist/segments/styles.js +24 -0
- package/dist/segments/styles.js.map +1 -0
- package/dist/slider/index.js +145 -0
- package/dist/slider/index.js.map +1 -0
- package/dist/swatch/index.js +56 -0
- package/dist/swatch/index.js.map +1 -0
- package/package.json +11 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["DocumentPickerAsset","ImagePickerAsset","DocumentPicker","ImagePicker","PickedFile","name","size","type","uri","PickOptions","acceptedFileTypes","allowsMultiple","defaultCamera","documentPicker","Promise","imagePicker","fromCamera","asset","fileName","split","at","fileSize","mimeType","fromDocument","importDocumentPicker","importImagePicker","loadDocumentPicker","loadImagePicker","mediaTypesOf","accepted","videos","some","startsWith","images","const","pickFiles","options","undefined","camera","Error","requestCameraPermissionsAsync","granted","shot","launchCameraAsync","cameraType","mediaTypes","canceled","assets","map","picker","picked","getDocumentAsync","base64","multiple","length","pickThen","then","files","error","console","preparePicker"],"sources":["../../src/files/index.ts"],"sourcesContent":["import type { DocumentPickerAsset } from 'expo-document-picker'\nimport type { ImagePickerAsset } from 'expo-image-picker'\n\ntype DocumentPicker = typeof import('expo-document-picker')\n\ntype ImagePicker = typeof import('expo-image-picker')\n\n/**\n * A file a person picked: what it is called, how big it is and what it is,\n * as web's `File` says, and where it is, which a call site reads it or\n * uploads it from. On iOS and Android that is a `file://` URI in the app's\n * cache, a copy the chooser made, and under React Native Web an object URL.\n */\ntype PickedFile = {\n readonly name: string\n /** Its size in bytes, where the platform says. */\n readonly size: number | undefined\n /** Its MIME type, or an empty string where the platform does not say, as on web. */\n readonly type: string\n readonly uri: string\n}\n/** What the chooser is asked for, in web's FileTrigger's words. */\ntype PickOptions = {\n /** The MIME types the chooser offers, such as `image/png` or `image/*`. Every type when left out. */\n readonly acceptedFileTypes?: readonly string[] | undefined\n /** Whether more than one file can be picked. */\n readonly allowsMultiple?: boolean | undefined\n /**\n * Opens the camera rather than the chooser, facing away from the person\n * for `environment` or towards them for `user`, as web's `capture` does.\n */\n readonly defaultCamera?: 'environment' | 'user' | undefined\n}\n\n// The two pickers are optional peers, so each is imported where its absence\n// can be caught, as src/clipboard imports expo-clipboard: Metro takes an\n// import inside a `try` as optional and bundles an app without it, which it\n// would not for an import wrapped any other way. Each is imported once, and\n// first when a component that picks mounts, so a press finds it loaded:\n// under React Native Web a chooser opens only while the press that asked for\n// it still counts as one.\nlet documentPicker: Promise<DocumentPicker | null> | undefined\nlet imagePicker: Promise<ImagePicker | null> | undefined\n\n// A photo the camera took is named by the platform where it names one, and\n// by the last part of its URI where it does not.\nfunction fromCamera(asset: ImagePickerAsset): PickedFile {\n return {\n name: asset.fileName ?? asset.uri.split('/').at(-1) ?? asset.uri,\n size: asset.fileSize,\n type: asset.mimeType ?? '',\n uri: asset.uri,\n }\n}\n\nfunction fromDocument(asset: DocumentPickerAsset): PickedFile {\n return {\n name: asset.name,\n size: asset.size,\n type: asset.mimeType ?? '',\n uri: asset.uri,\n }\n}\n\nasync function importDocumentPicker(): Promise<DocumentPicker | null> {\n try {\n return await import(/* @vite-ignore */ 'expo-document-picker')\n } catch {\n return null\n }\n}\n\nasync function importImagePicker(): Promise<ImagePicker | null> {\n try {\n return await import(/* @vite-ignore */ 'expo-image-picker')\n } catch {\n return null\n }\n}\n\nasync function loadDocumentPicker() {\n documentPicker ??= importDocumentPicker()\n return documentPicker\n}\n\nasync function loadImagePicker() {\n imagePicker ??= importImagePicker()\n return imagePicker\n}\n\n// The camera takes photos and videos alone, so it is asked for videos when\n// the accepted types name one and for photos unless they name only videos.\nfunction mediaTypesOf(accepted: readonly string[]) {\n const videos = accepted.some((type) => type.startsWith('video/'))\n const images = !videos || accepted.some((type) => type.startsWith('image/'))\n\n return [\n ...(images ? (['images'] as const) : []),\n ...(videos ? (['videos'] as const) : []),\n ]\n}\n\n/**\n * Opens the system's chooser, or its camera for `defaultCamera`, and settles\n * on the files picked, or on `null` when the person backed out. A camera the\n * person will not let the app use is backing out too.\n *\n * It rejects, naming the package, when the one it needs is not installed:\n * expo-document-picker for the chooser, expo-image-picker for the camera.\n */\nasync function pickFiles(\n options: PickOptions,\n): Promise<null | readonly PickedFile[]> {\n const accepted = options.acceptedFileTypes ?? []\n\n if (options.defaultCamera !== undefined) {\n const camera = await loadImagePicker()\n\n if (camera === null) {\n throw new Error(\n 'Taking a photo needs expo-image-picker, which is not installed',\n )\n }\n if (!(await camera.requestCameraPermissionsAsync()).granted) {\n return null\n }\n\n const shot = await camera.launchCameraAsync({\n cameraType: options.defaultCamera === 'user' ? 'front' : 'back',\n mediaTypes: mediaTypesOf(accepted),\n })\n\n return shot.canceled ? null : shot.assets.map(fromCamera)\n }\n\n const picker = await loadDocumentPicker()\n\n if (picker === null) {\n throw new Error(\n 'Picking a file needs expo-document-picker, which is not installed',\n )\n }\n\n // base64 is off, since the package otherwise reads every file picked into\n // memory, which nothing here asks of it.\n const picked = await picker.getDocumentAsync({\n base64: false,\n multiple: options.allowsMultiple ?? false,\n type: accepted.length === 0 ? '*/*' : [...accepted],\n })\n\n return picked.canceled ? null : picked.assets.map(fromDocument)\n}\n\n/**\n * Picks as `pickFiles` does and hands what was picked to `then`, saying\n * nothing when the person backed out. A failure, a missing package among\n * them, is written to the console, where a missing package is a mistake in\n * the app's setup rather than something the person can do anything about.\n */\nasync function pickThen(\n options: PickOptions,\n then: (files: readonly PickedFile[]) => void,\n): Promise<void> {\n let files: null | readonly PickedFile[]\n\n try {\n files = await pickFiles(options)\n } catch (error) {\n console.error(error)\n return\n }\n if (files !== null) {\n then(files)\n }\n}\n\n/**\n * Starts importing the picker the options open, so that a press finds it\n * there. A component that picks calls it once it mounts.\n */\nfunction preparePicker(options: PickOptions) {\n void (options.defaultCamera === undefined\n ? loadDocumentPicker()\n : loadImagePicker())\n}\n\nexport { pickFiles, pickThen, preparePicker }\nexport type { PickedFile, PickOptions }\n"],"mappings":";AAyCA,IAAIa;AACJ,IAAIE;AAIJ,SAASC,WAAWC,OAAqC;CACvD,OAAO;EACLZ,MAAMY,MAAMC,YAAYD,MAAMT,IAAIW,MAAM,GAAG,CAAC,CAACC,GAAG,EAAE,KAAKH,MAAMT;EAC7DF,MAAMW,MAAMI;EACZd,MAAMU,MAAMK,YAAY;EACxBd,KAAKS,MAAMT;CACb;AACF;AAEA,SAASe,aAAaN,OAAwC;CAC5D,OAAO;EACLZ,MAAMY,MAAMZ;EACZC,MAAMW,MAAMX;EACZC,MAAMU,MAAMK,YAAY;EACxBd,KAAKS,MAAMT;CACb;AACF;AAEA,eAAegB,uBAAuD;CACpE,IAAI;EACF,OAAO,MAAM;;GAA0B;;CACzC,QAAQ;EACN,OAAO;CACT;AACF;AAEA,eAAeC,oBAAiD;CAC9D,IAAI;EACF,OAAO,MAAM;;GAA0B;;CACzC,QAAQ;EACN,OAAO;CACT;AACF;AAEA,eAAeC,qBAAqB;C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J,IAAI;EACFA,QAAQ,MAAMtB,UAAUC,OAAO;CACjC,SAASsB,OAAO;EACdC,QAAQD,MAAMA,KAAK;EACnB;CACF;CACA,IAAID,UAAU,MACZD,KAAKC,KAAK;AAEd;;;;;AAMA,SAASG,cAAcxB,SAAsB;CAC3C,QAAcxB,kBAAkByB,KAAAA,IAC5BX,mBAAmB,IACnBC,gBAAgB;AACtB"}
|
package/dist/form/index.d.ts
CHANGED
|
@@ -7,8 +7,11 @@ import { RefObject } from "react";
|
|
|
7
7
|
* error once a submission is tried.
|
|
8
8
|
*/
|
|
9
9
|
type FormValidationBehavior = 'aria' | 'native';
|
|
10
|
-
/**
|
|
11
|
-
|
|
10
|
+
/**
|
|
11
|
+
* The values a form submits by each field's `name`: a string, or a list of
|
|
12
|
+
* them for a field holding several, as a checkbox group does.
|
|
13
|
+
*/
|
|
14
|
+
type FormValues = Readonly<Record<string, readonly string[] | string>>;
|
|
12
15
|
/** A field's problem in words: one message, or several read as one line. */
|
|
13
16
|
type ValidationError = readonly string[] | string;
|
|
14
17
|
/** Errors keyed by each field's `name`, such as a server's answer. */
|
package/dist/form/index.js
CHANGED
|
@@ -11,6 +11,8 @@ const FIELD_VALIDATION_BEHAVIOR = "aria";
|
|
|
11
11
|
const REQUIRED_ERROR = "Fill out this field.";
|
|
12
12
|
const NO_ERRORS = {};
|
|
13
13
|
const NO_MESSAGES = [];
|
|
14
|
+
const NO_SUBMISSION = [void 0, void 0];
|
|
15
|
+
const NO_SUBMISSIONS = [];
|
|
14
16
|
const FormContext = createContext(null);
|
|
15
17
|
/**
|
|
16
18
|
* The fields a form holds, in the order they registered. A field that is
|
|
@@ -58,7 +60,7 @@ function submitOf(registry, validationBehavior, onSubmit) {
|
|
|
58
60
|
return;
|
|
59
61
|
}
|
|
60
62
|
}
|
|
61
|
-
onSubmit?.(Object.fromEntries(entries.flatMap((entry) => entry.submits
|
|
63
|
+
onSubmit?.(Object.fromEntries(entries.flatMap((entry) => entry.submits)));
|
|
62
64
|
};
|
|
63
65
|
}
|
|
64
66
|
/**
|
|
@@ -82,8 +84,8 @@ function submitOf(registry, validationBehavior, onSubmit) {
|
|
|
82
84
|
* leaves a disabled input out of what a form submits.
|
|
83
85
|
*/
|
|
84
86
|
function useFieldValidation(t0) {
|
|
85
|
-
const $ = c(
|
|
86
|
-
const { control, error, isDisabled, isEmpty, isReadOnly, isRequired, name, submitted, validate, value } = t0;
|
|
87
|
+
const $ = c(14);
|
|
88
|
+
const { alongside, control, error, isDisabled, isEmpty, isReadOnly, isRequired, name, submitted, validate, value } = t0;
|
|
87
89
|
const form = use(FormContext);
|
|
88
90
|
const id = useId();
|
|
89
91
|
const behavior = form?.validationBehavior ?? "aria";
|
|
@@ -94,112 +96,89 @@ function useFieldValidation(t0) {
|
|
|
94
96
|
const edited = useRef(false);
|
|
95
97
|
const native = behavior === "native";
|
|
96
98
|
const barred = isDisabled || isReadOnly;
|
|
97
|
-
const
|
|
99
|
+
const submissions = [[name, submitted], alongside ?? NO_SUBMISSION];
|
|
100
|
+
const server = clearedFrom === serverErrors ? NO_MESSAGES : submissions.flatMap((t1) => {
|
|
101
|
+
const [each] = t1;
|
|
102
|
+
return each === void 0 ? NO_MESSAGES : messagesOf(serverErrors[each]);
|
|
103
|
+
});
|
|
98
104
|
const client = validate === void 0 ? NO_MESSAGES : messagesOf(validate(value));
|
|
99
105
|
const own = client.length > 0 ? client : native && isRequired && isEmpty && !barred ? [REQUIRED_ERROR] : NO_MESSAGES;
|
|
100
106
|
if (showing && own.length === 0) setShowing(false);
|
|
101
107
|
const shown = native ? showing ? own : NO_MESSAGES : client;
|
|
102
|
-
const t1 = !barred && (error !== void 0 || server.length > 0 || own.length > 0);
|
|
103
108
|
let t2;
|
|
104
|
-
if ($[0]
|
|
105
|
-
t2 =
|
|
106
|
-
$[0] = control;
|
|
107
|
-
$[1] = t2;
|
|
108
|
-
} else t2 = $[1];
|
|
109
|
-
let t3;
|
|
110
|
-
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
|
|
111
|
-
t3 = () => {
|
|
109
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
110
|
+
t2 = () => {
|
|
112
111
|
setShowing(true);
|
|
113
112
|
};
|
|
114
|
-
$[
|
|
115
|
-
} else
|
|
113
|
+
$[0] = t2;
|
|
114
|
+
} else t2 = $[0];
|
|
115
|
+
const entry = {
|
|
116
|
+
blocks: !barred && (error !== void 0 || server.length > 0 || own.length > 0),
|
|
117
|
+
focus: focusOf(control),
|
|
118
|
+
show: t2,
|
|
119
|
+
submits: isDisabled ? NO_SUBMISSIONS : submissions.flatMap(_temp)
|
|
120
|
+
};
|
|
121
|
+
useEffect(() => {
|
|
122
|
+
registry?.set(id, entry);
|
|
123
|
+
});
|
|
124
|
+
let t3;
|
|
116
125
|
let t4;
|
|
117
|
-
if ($[
|
|
118
|
-
|
|
119
|
-
$[3] = isDisabled;
|
|
120
|
-
$[4] = name;
|
|
121
|
-
$[5] = submitted;
|
|
122
|
-
$[6] = t4;
|
|
123
|
-
} else t4 = $[6];
|
|
124
|
-
let t5;
|
|
125
|
-
if ($[7] !== t1 || $[8] !== t2 || $[9] !== t4) {
|
|
126
|
-
t5 = {
|
|
127
|
-
blocks: t1,
|
|
128
|
-
focus: t2,
|
|
129
|
-
show: t3,
|
|
130
|
-
submits: t4
|
|
131
|
-
};
|
|
132
|
-
$[7] = t1;
|
|
133
|
-
$[8] = t2;
|
|
134
|
-
$[9] = t4;
|
|
135
|
-
$[10] = t5;
|
|
136
|
-
} else t5 = $[10];
|
|
137
|
-
const entry = t5;
|
|
138
|
-
let t6;
|
|
139
|
-
if ($[11] !== entry || $[12] !== id || $[13] !== registry) {
|
|
140
|
-
t6 = () => {
|
|
141
|
-
registry?.set(id, entry);
|
|
142
|
-
};
|
|
143
|
-
$[11] = entry;
|
|
144
|
-
$[12] = id;
|
|
145
|
-
$[13] = registry;
|
|
146
|
-
$[14] = t6;
|
|
147
|
-
} else t6 = $[14];
|
|
148
|
-
useEffect(t6);
|
|
149
|
-
let t7;
|
|
150
|
-
let t8;
|
|
151
|
-
if ($[15] !== id || $[16] !== registry) {
|
|
152
|
-
t7 = () => () => {
|
|
126
|
+
if ($[1] !== id || $[2] !== registry) {
|
|
127
|
+
t3 = () => () => {
|
|
153
128
|
registry?.remove(id);
|
|
154
129
|
};
|
|
155
|
-
|
|
156
|
-
$[
|
|
157
|
-
$[
|
|
158
|
-
$[
|
|
159
|
-
$[
|
|
130
|
+
t4 = [id, registry];
|
|
131
|
+
$[1] = id;
|
|
132
|
+
$[2] = registry;
|
|
133
|
+
$[3] = t3;
|
|
134
|
+
$[4] = t4;
|
|
160
135
|
} else {
|
|
161
|
-
|
|
162
|
-
|
|
136
|
+
t3 = $[3];
|
|
137
|
+
t4 = $[4];
|
|
163
138
|
}
|
|
164
|
-
useEffect(
|
|
165
|
-
const
|
|
166
|
-
let
|
|
167
|
-
if ($[
|
|
168
|
-
|
|
139
|
+
useEffect(t3, t4);
|
|
140
|
+
const t5 = error ?? lineOf(server) ?? lineOf(shown);
|
|
141
|
+
let t6;
|
|
142
|
+
if ($[5] !== native || $[6] !== serverErrors) {
|
|
143
|
+
t6 = () => {
|
|
169
144
|
if (edited.current) {
|
|
170
145
|
edited.current = false;
|
|
171
146
|
setClearedFrom(serverErrors);
|
|
172
147
|
setShowing(native);
|
|
173
148
|
}
|
|
174
149
|
};
|
|
175
|
-
$[
|
|
176
|
-
$[
|
|
177
|
-
$[
|
|
178
|
-
} else
|
|
179
|
-
let
|
|
180
|
-
if ($[
|
|
181
|
-
|
|
150
|
+
$[5] = native;
|
|
151
|
+
$[6] = serverErrors;
|
|
152
|
+
$[7] = t6;
|
|
153
|
+
} else t6 = $[7];
|
|
154
|
+
let t7;
|
|
155
|
+
if ($[8] !== serverErrors) {
|
|
156
|
+
t7 = () => {
|
|
182
157
|
edited.current = true;
|
|
183
158
|
setClearedFrom(serverErrors);
|
|
184
159
|
};
|
|
185
|
-
$[
|
|
186
|
-
$[
|
|
187
|
-
} else
|
|
188
|
-
let
|
|
189
|
-
if ($[
|
|
190
|
-
|
|
191
|
-
error:
|
|
192
|
-
onBlur:
|
|
193
|
-
onEdit:
|
|
160
|
+
$[8] = serverErrors;
|
|
161
|
+
$[9] = t7;
|
|
162
|
+
} else t7 = $[9];
|
|
163
|
+
let t8;
|
|
164
|
+
if ($[10] !== t5 || $[11] !== t6 || $[12] !== t7) {
|
|
165
|
+
t8 = {
|
|
166
|
+
error: t5,
|
|
167
|
+
onBlur: t6,
|
|
168
|
+
onEdit: t7
|
|
194
169
|
};
|
|
195
|
-
$[
|
|
196
|
-
$[
|
|
197
|
-
$[
|
|
198
|
-
$[
|
|
199
|
-
} else
|
|
200
|
-
return
|
|
170
|
+
$[10] = t5;
|
|
171
|
+
$[11] = t6;
|
|
172
|
+
$[12] = t7;
|
|
173
|
+
$[13] = t8;
|
|
174
|
+
} else t8 = $[13];
|
|
175
|
+
return t8;
|
|
201
176
|
}
|
|
202
177
|
/** Whether the field is inside a form, which keeps its message line drawn. */
|
|
178
|
+
function _temp(t0) {
|
|
179
|
+
const [each_0, sent] = t0;
|
|
180
|
+
return each_0 === void 0 || sent === void 0 ? [] : [[each_0, sent]];
|
|
181
|
+
}
|
|
203
182
|
function useInsideForm() {
|
|
204
183
|
return use(FormContext) !== null;
|
|
205
184
|
}
|
package/dist/form/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["RefObject","createContext","use","useEffect","useId","useRef","useState","FieldValidationOptions","control","Focusable","error","isDisabled","isEmpty","isReadOnly","isRequired","name","submitted","validate","value","T","ValidationResult","focus","FormEntry","blocks","show","submits","FormRegistry","entries","remove","id","set","entry","FormState","registry","requestSubmit","validationBehavior","FormValidationBehavior","validationErrors","ValidationErrors","FormValues","Readonly","Record","ValidationError","FIELD_VALIDATION_BEHAVIOR","REQUIRED_ERROR","NO_ERRORS","NO_MESSAGES","FormContext","createRegistry","fields","Map","values","delete","focusOf","current","lineOf","messages","length","undefined","join","messagesOf","result","submitOf","onSubmit","blocking","filter","first","at","Object","fromEntries","flatMap","useFieldValidation","t0","$","_c","form","behavior","serverErrors","clearedFrom","setClearedFrom","showing","setShowing","edited","native","barred","server","client","own","shown","t1","t2","t3","Symbol","for","t4","t5","t6","t7","t8","t9","t10","t11","t12","onBlur","onEdit","useInsideForm","_c"],"sources":["../../src/form/index.ts"],"sourcesContent":["import type { RefObject } from 'react'\n\nimport { createContext, use, useEffect, useId, useRef, useState } from 'react'\n\n// What a Form tells the fields inside it, and what each field tells it back,\n// as React Aria's Form and its fields do through context on web. The form\n// hands down how its fields validate and the errors a server sent back, by\n// field name. Each field registers with the form around it while it is\n// mounted, in the order the tree mounts them, which is the order they are\n// drawn in, and the form reads that list when it is submitted: the values by\n// name, and under `native` which fields hold it back and which of them takes\n// focus.\n\ntype FieldValidationOptions<T> = {\n /** The control a failed native submission focuses. */\n readonly control: RefObject<Focusable | null>\n /** The field's own error, which wins over anything the form says. */\n readonly error: string | undefined\n readonly isDisabled: boolean\n /** Whether the value is what a required field must not be left as. */\n readonly isEmpty: boolean\n readonly isReadOnly: boolean\n readonly isRequired: boolean\n readonly name: string | undefined\n /**\n * The value as the form submits it, or `undefined` for a field whose value\n * is not one string, which submits nothing.\n */\n readonly submitted: string | undefined\n readonly validate: ((value: T) => ValidationResult) | undefined\n readonly value: T\n}\n\n/** What a failed native submission moves focus to: a field's control. */\ntype Focusable = {\n readonly focus: () => void\n}\n\n/** What a field tells the form it is in, as of its last render. */\ntype FormEntry = {\n /** Whether the field holds a native submission back. */\n readonly blocks: boolean\n /** Moves focus to the field's control. */\n readonly focus: () => void\n /** Shows the field's own error, once a submission it held back is tried. */\n readonly show: () => void\n /** The name and value the field submits, where it submits one. */\n readonly submits: readonly [string, string] | undefined\n}\n\ntype FormRegistry = {\n readonly entries: () => readonly FormEntry[]\n readonly remove: (id: string) => void\n readonly set: (id: string, entry: FormEntry) => void\n}\n\ntype FormState = {\n readonly registry: FormRegistry\n readonly requestSubmit: () => void\n readonly validationBehavior: FormValidationBehavior\n readonly validationErrors: ValidationErrors\n}\n\n/**\n * `aria` shows a field's error as soon as the field says so, and lets the\n * form submit regardless. `native` holds the form back while a field in it is\n * required and empty, or rejected by its `validate`, and shows that field's\n * error once a submission is tried.\n */\ntype FormValidationBehavior = 'aria' | 'native'\n\n/** The values a form submits, as strings by each field's `name`. */\ntype FormValues = Readonly<Record<string, string>>\n\n/** A field's problem in words: one message, or several read as one line. */\ntype ValidationError = readonly string[] | string\n\n/** Errors keyed by each field's `name`, such as a server's answer. */\ntype ValidationErrors = Readonly<Record<string, ValidationError>>\n\n/**\n * What a field's `validate` returns for a value: its problem in words, or\n * `true`, `null` or `undefined` where there is none, as on web.\n */\ntype ValidationResult = null | true | undefined | ValidationError\n\n/**\n * What a field outside a form, and a form told nothing, validates by. The\n * library shows its own message under a field, so an error shows as the\n * field reports it rather than once a submission is tried.\n */\nconst FIELD_VALIDATION_BEHAVIOR: FormValidationBehavior = 'aria'\n\n/** The error a required field left empty shows under `native`. */\nconst REQUIRED_ERROR = 'Fill out this field.'\n\nconst NO_ERRORS: ValidationErrors = {}\n\nconst NO_MESSAGES: readonly string[] = []\n\nconst FormContext = createContext<FormState | null>(null)\n\n/**\n * The fields a form holds, in the order they registered. A field that is\n * already in it keeps its place as it reports again, so the order is the one\n * they mounted in.\n */\nfunction createRegistry(): FormRegistry {\n const fields = new Map<string, FormEntry>()\n\n return {\n entries: () => [...fields.values()],\n remove: (id) => {\n fields.delete(id)\n },\n set: (id, entry) => {\n fields.set(id, entry)\n },\n }\n}\n\n// Focuses a field's control, through the ref the field holds it in.\nfunction focusOf(control: RefObject<Focusable | null>) {\n return () => {\n control.current?.focus()\n }\n}\n\n// One line of a field's messages, or nothing where there are none.\nfunction lineOf(messages: readonly string[]): string | undefined {\n return messages.length === 0 ? undefined : messages.join(' ')\n}\n\n// A validation result as the messages it holds.\nfunction messagesOf(result: ValidationResult): readonly string[] {\n if (typeof result === 'string') {\n return result === '' ? NO_MESSAGES : [result]\n }\n\n return result === null || result === undefined || result === true\n ? NO_MESSAGES\n : result\n}\n\n/**\n * Submits a form: under `native`, holds it back while any field blocks,\n * showing each blocking field's error and focusing the first, and otherwise\n * hands `onSubmit` every named field's value.\n */\nfunction submitOf(\n registry: FormRegistry,\n validationBehavior: FormValidationBehavior,\n onSubmit: ((values: FormValues) => void) | undefined,\n) {\n return () => {\n const entries = registry.entries()\n\n if (validationBehavior === 'native') {\n const blocking = entries.filter((entry) => entry.blocks)\n const first = blocking.at(0)\n\n if (first !== undefined) {\n for (const entry of blocking) {\n entry.show()\n }\n first.focus()\n return\n }\n }\n\n onSubmit?.(\n Object.fromEntries(\n entries.flatMap((entry) =>\n entry.submits === undefined ? [] : [entry.submits],\n ),\n ),\n )\n }\n}\n\n/**\n * A field's validation, as React Aria's is on web, and its place in the form\n * around it. It hands back the error the field shows, and two handlers the\n * field calls: `onEdit` as its value is edited, and `onBlur` as its control\n * loses focus.\n *\n * The error is the field's own `error` where it has one. Otherwise it is the\n * server's, from the form's `validationErrors` under the field's `name`,\n * until the field is edited; a new `validationErrors` from the form shows it\n * again. Otherwise, under `aria`, it is what `validate` says about the value\n * as it changes.\n *\n * Under `native` that last one, or the required field's own error when it is\n * empty, is shown late and taken back early, as on web: once a submission it\n * holds back is tried, or once the control loses focus after an edit, and no\n * longer once the value is right, so a field shows nothing new in the middle\n * of being typed in. A disabled or read-only field holds nothing back, and a\n * disabled one submits nothing, as a browser bars both from validation and\n * leaves a disabled input out of what a form submits.\n */\nfunction useFieldValidation<T>({\n control,\n error,\n isDisabled,\n isEmpty,\n isReadOnly,\n isRequired,\n name,\n submitted,\n validate,\n value,\n}: FieldValidationOptions<T>) {\n const form = use(FormContext)\n const id = useId()\n const behavior = form?.validationBehavior ?? FIELD_VALIDATION_BEHAVIOR\n const serverErrors = form?.validationErrors ?? NO_ERRORS\n const registry = form?.registry\n // The errors object the field was edited under. Its server error stays\n // cleared until the form is handed a new one.\n const [clearedFrom, setClearedFrom] = useState<null | ValidationErrors>(null)\n const [showing, setShowing] = useState(false)\n // Whether the value has been edited since the control last lost focus,\n // which is when a browser fires `change`, and so when React Aria commits.\n const edited = useRef(false)\n const native = behavior === 'native'\n const barred = isDisabled || isReadOnly\n const server =\n name === undefined || clearedFrom === serverErrors\n ? NO_MESSAGES\n : messagesOf(serverErrors[name])\n const client =\n validate === undefined ? NO_MESSAGES : messagesOf(validate(value))\n const own =\n client.length > 0\n ? client\n : native && isRequired && isEmpty && !barred\n ? [REQUIRED_ERROR]\n : NO_MESSAGES\n\n // Taken back as soon as the value is right, however it got there.\n if (showing && own.length === 0) {\n setShowing(false)\n }\n\n const shown = native ? (showing ? own : NO_MESSAGES) : client\n const entry: FormEntry = {\n blocks:\n !barred && (error !== undefined || server.length > 0 || own.length > 0),\n focus: focusOf(control),\n show: () => {\n setShowing(true)\n },\n submits:\n isDisabled || name === undefined || submitted === undefined\n ? undefined\n : [name, submitted],\n }\n\n // Reported after every render, so the form reads what the field shows.\n useEffect(() => {\n registry?.set(id, entry)\n })\n\n useEffect(\n () => () => {\n registry?.remove(id)\n },\n [id, registry],\n )\n\n return {\n error: error ?? lineOf(server) ?? lineOf(shown),\n onBlur: () => {\n if (edited.current) {\n edited.current = false\n setClearedFrom(serverErrors)\n setShowing(native)\n }\n },\n onEdit: () => {\n edited.current = true\n setClearedFrom(serverErrors)\n },\n }\n}\n\n/** Whether the field is inside a form, which keeps its message line drawn. */\nfunction useInsideForm() {\n return use(FormContext) !== null\n}\n\nexport {\n createRegistry,\n FIELD_VALIDATION_BEHAVIOR,\n FormContext,\n submitOf,\n useFieldValidation,\n useInsideForm,\n}\nexport type {\n Focusable,\n FormValidationBehavior,\n FormValues,\n ValidationError,\n ValidationErrors,\n ValidationResult,\n}\n"],"mappings":";;;;;;;;AA2FA,MAAM2C,4BAAoD;;AAG1D,MAAMC,iBAAiB;AAEvB,MAAMC,YAA8B,CAAC;AAErC,MAAMC,cAAiC,CAAA;AAE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EAAA;EAAAyB,KAAAzB,EAAA;CAAA;CAJhBtE,UACE8F,IAGAC,EACF;CAGS,MAAAC,KAAAzF,SAAS6C,OAAO8B,MAAM,KAAK9B,OAAOiC,KAAK;CAAC,IAAAY;CAAA,IAAA3B,EAAA,QAAAU,UAAAV,EAAA,QAAAI,cAAA;EACvCuB,YAAA;GACN,IAAIlB,OAAM5B,SAAQ;IAChB4B,OAAM5B,UAAW;IACjByB,eAAeF,YAAY;IAC3BI,WAAWE,MAAM;GAAC;EACnB;EACFV,EAAA,MAAAU;EAAAV,EAAA,MAAAI;EAAAJ,EAAA,MAAA2B;CAAA,OAAAA,MAAA3B,EAAA;CAAA,IAAA4B;CAAA,IAAA5B,EAAA,QAAAI,cAAA;EACOwB,YAAA;GACNnB,OAAM5B,UAAW;GACjByB,eAAeF,YAAY;EAAC;EAC7BJ,EAAA,MAAAI;EAAAJ,EAAA,MAAA4B;CAAA,OAAAA,MAAA5B,EAAA;CAAA,IAAA6B;CAAA,IAAA7B,EAAA,QAAA2B,OAAA3B,EAAA,QAAA4B,OAAA5B,EAAA,QAAA0B,IAAA;EAZIG,MAAA;GAAA5F,OACEyF;GAAwCI,QACvCH;GAMPI,QACOH;EAIV;EAAC5B,EAAA,MAAA2B;EAAA3B,EAAA,MAAA4B;EAAA5B,EAAA,MAAA0B;EAAA1B,EAAA,MAAA6B;CAAA,OAAAA,MAAA7B,EAAA;CAAA,OAbM6B;AAaN;;AAIH,SAASG,gBAAgB;CACvB,OAAOvG,IAAI6C,WAAW,MAAM;AAC9B"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["RefObject","createContext","use","useEffect","useId","useRef","useState","FieldValidationOptions","alongside","name","submitted","control","Focusable","error","isDisabled","isEmpty","isReadOnly","isRequired","FormValues","validate","value","T","ValidationResult","focus","FormEntry","blocks","show","submits","FormRegistry","entries","remove","id","set","entry","FormState","registry","requestSubmit","validationBehavior","FormValidationBehavior","validationErrors","ValidationErrors","Readonly","Record","ValidationError","FIELD_VALIDATION_BEHAVIOR","REQUIRED_ERROR","NO_ERRORS","NO_MESSAGES","NO_SUBMISSION","undefined","const","NO_SUBMISSIONS","FormContext","createRegistry","fields","Map","values","delete","focusOf","current","lineOf","messages","length","join","messagesOf","result","submitOf","onSubmit","blocking","filter","first","at","Object","fromEntries","flatMap","useFieldValidation","t0","$","_c","form","behavior","serverErrors","clearedFrom","setClearedFrom","showing","setShowing","edited","native","barred","submissions","server","t1","each","client","own","shown","t2","Symbol","for","_temp","t3","t4","t5","t6","t7","t8","onBlur","onEdit","each_0","sent","useInsideForm","_c"],"sources":["../../src/form/index.ts"],"sourcesContent":["import type { RefObject } from 'react'\n\nimport { createContext, use, useEffect, useId, useRef, useState } from 'react'\n\n// What a Form tells the fields inside it, and what each field tells it back,\n// as React Aria's Form and its fields do through context on web. The form\n// hands down how its fields validate and the errors a server sent back, by\n// field name. Each field registers with the form around it while it is\n// mounted, in the order the tree mounts them, which is the order they are\n// drawn in, and the form reads that list when it is submitted: the values by\n// name, and under `native` which fields hold it back and which of them takes\n// focus.\n\ntype FieldValidationOptions<T> = {\n /**\n * A second name the field submits a value under, beside `name`'s, with\n * that value, as a date range picker submits its end beside its start.\n * The form's `validationErrors` reach the field under either name.\n */\n readonly alongside?: readonly [name: string | undefined, submitted: string]\n /** The control a failed native submission focuses. */\n readonly control: RefObject<Focusable | null>\n /** The field's own error, which wins over anything the form says. */\n readonly error: string | undefined\n readonly isDisabled: boolean\n /** Whether the value is what a required field must not be left as. */\n readonly isEmpty: boolean\n readonly isReadOnly: boolean\n readonly isRequired: boolean\n readonly name: string | undefined\n /**\n * The value as the form submits it: one string, a list of them for a field\n * holding several, as a checkbox group does, or `undefined` for a field\n * that submits nothing.\n */\n readonly submitted: FormValues[string] | undefined\n readonly validate: ((value: T) => ValidationResult) | undefined\n readonly value: T\n}\n\n/** What a failed native submission moves focus to: a field's control. */\ntype Focusable = {\n readonly focus: () => void\n}\n\n/** What a field tells the form it is in, as of its last render. */\ntype FormEntry = {\n /** Whether the field holds a native submission back. */\n readonly blocks: boolean\n /** Moves focus to the field's control. */\n readonly focus: () => void\n /** Shows the field's own error, once a submission it held back is tried. */\n readonly show: () => void\n /** The names and values the field submits: none, one, or a range's two. */\n readonly submits: readonly (readonly [string, FormValues[string]])[]\n}\n\ntype FormRegistry = {\n readonly entries: () => readonly FormEntry[]\n readonly remove: (id: string) => void\n readonly set: (id: string, entry: FormEntry) => void\n}\n\ntype FormState = {\n readonly registry: FormRegistry\n readonly requestSubmit: () => void\n readonly validationBehavior: FormValidationBehavior\n readonly validationErrors: ValidationErrors\n}\n\n/**\n * `aria` shows a field's error as soon as the field says so, and lets the\n * form submit regardless. `native` holds the form back while a field in it is\n * required and empty, or rejected by its `validate`, and shows that field's\n * error once a submission is tried.\n */\ntype FormValidationBehavior = 'aria' | 'native'\n\n/**\n * The values a form submits by each field's `name`: a string, or a list of\n * them for a field holding several, as a checkbox group does.\n */\ntype FormValues = Readonly<Record<string, readonly string[] | string>>\n\n/** A field's problem in words: one message, or several read as one line. */\ntype ValidationError = readonly string[] | string\n\n/** Errors keyed by each field's `name`, such as a server's answer. */\ntype ValidationErrors = Readonly<Record<string, ValidationError>>\n\n/**\n * What a field's `validate` returns for a value: its problem in words, or\n * `true`, `null` or `undefined` where there is none, as on web.\n */\ntype ValidationResult = null | true | undefined | ValidationError\n\n/**\n * What a field outside a form, and a form told nothing, validates by. The\n * library shows its own message under a field, so an error shows as the\n * field reports it rather than once a submission is tried.\n */\nconst FIELD_VALIDATION_BEHAVIOR: FormValidationBehavior = 'aria'\n\n/** The error a required field left empty shows under `native`. */\nconst REQUIRED_ERROR = 'Fill out this field.'\n\nconst NO_ERRORS: ValidationErrors = {}\n\nconst NO_MESSAGES: readonly string[] = []\n\n// What a field with no second name submits beside its first: nothing.\nconst NO_SUBMISSION = [undefined, undefined] as const\n\nconst NO_SUBMISSIONS: FormEntry['submits'] = []\n\nconst FormContext = createContext<FormState | null>(null)\n\n/**\n * The fields a form holds, in the order they registered. A field that is\n * already in it keeps its place as it reports again, so the order is the one\n * they mounted in.\n */\nfunction createRegistry(): FormRegistry {\n const fields = new Map<string, FormEntry>()\n\n return {\n entries: () => [...fields.values()],\n remove: (id) => {\n fields.delete(id)\n },\n set: (id, entry) => {\n fields.set(id, entry)\n },\n }\n}\n\n// Focuses a field's control, through the ref the field holds it in.\nfunction focusOf(control: RefObject<Focusable | null>) {\n return () => {\n control.current?.focus()\n }\n}\n\n// One line of a field's messages, or nothing where there are none.\nfunction lineOf(messages: readonly string[]): string | undefined {\n return messages.length === 0 ? undefined : messages.join(' ')\n}\n\n// A validation result as the messages it holds.\nfunction messagesOf(result: ValidationResult): readonly string[] {\n if (typeof result === 'string') {\n return result === '' ? NO_MESSAGES : [result]\n }\n\n return result === null || result === undefined || result === true\n ? NO_MESSAGES\n : result\n}\n\n/**\n * Submits a form: under `native`, holds it back while any field blocks,\n * showing each blocking field's error and focusing the first, and otherwise\n * hands `onSubmit` every named field's value.\n */\nfunction submitOf(\n registry: FormRegistry,\n validationBehavior: FormValidationBehavior,\n onSubmit: ((values: FormValues) => void) | undefined,\n) {\n return () => {\n const entries = registry.entries()\n\n if (validationBehavior === 'native') {\n const blocking = entries.filter((entry) => entry.blocks)\n const first = blocking.at(0)\n\n if (first !== undefined) {\n for (const entry of blocking) {\n entry.show()\n }\n first.focus()\n return\n }\n }\n\n onSubmit?.(Object.fromEntries(entries.flatMap((entry) => entry.submits)))\n }\n}\n\n/**\n * A field's validation, as React Aria's is on web, and its place in the form\n * around it. It hands back the error the field shows, and two handlers the\n * field calls: `onEdit` as its value is edited, and `onBlur` as its control\n * loses focus.\n *\n * The error is the field's own `error` where it has one. Otherwise it is the\n * server's, from the form's `validationErrors` under the field's `name`,\n * until the field is edited; a new `validationErrors` from the form shows it\n * again. Otherwise, under `aria`, it is what `validate` says about the value\n * as it changes.\n *\n * Under `native` that last one, or the required field's own error when it is\n * empty, is shown late and taken back early, as on web: once a submission it\n * holds back is tried, or once the control loses focus after an edit, and no\n * longer once the value is right, so a field shows nothing new in the middle\n * of being typed in. A disabled or read-only field holds nothing back, and a\n * disabled one submits nothing, as a browser bars both from validation and\n * leaves a disabled input out of what a form submits.\n */\nfunction useFieldValidation<T>({\n alongside,\n control,\n error,\n isDisabled,\n isEmpty,\n isReadOnly,\n isRequired,\n name,\n submitted,\n validate,\n value,\n}: FieldValidationOptions<T>) {\n const form = use(FormContext)\n const id = useId()\n const behavior = form?.validationBehavior ?? FIELD_VALIDATION_BEHAVIOR\n const serverErrors = form?.validationErrors ?? NO_ERRORS\n const registry = form?.registry\n // The errors object the field was edited under. Its server error stays\n // cleared until the form is handed a new one.\n const [clearedFrom, setClearedFrom] = useState<null | ValidationErrors>(null)\n const [showing, setShowing] = useState(false)\n // Whether the value has been edited since the control last lost focus,\n // which is when a browser fires `change`, and so when React Aria commits.\n const edited = useRef(false)\n const native = behavior === 'native'\n const barred = isDisabled || isReadOnly\n const submissions = [[name, submitted], alongside ?? NO_SUBMISSION] as const\n const server =\n clearedFrom === serverErrors\n ? NO_MESSAGES\n : submissions.flatMap(([each]) =>\n each === undefined ? NO_MESSAGES : messagesOf(serverErrors[each]),\n )\n const client =\n validate === undefined ? NO_MESSAGES : messagesOf(validate(value))\n const own =\n client.length > 0\n ? client\n : native && isRequired && isEmpty && !barred\n ? [REQUIRED_ERROR]\n : NO_MESSAGES\n\n // Taken back as soon as the value is right, however it got there.\n if (showing && own.length === 0) {\n setShowing(false)\n }\n\n const shown = native ? (showing ? own : NO_MESSAGES) : client\n const entry: FormEntry = {\n blocks:\n !barred && (error !== undefined || server.length > 0 || own.length > 0),\n focus: focusOf(control),\n show: () => {\n setShowing(true)\n },\n submits: isDisabled\n ? NO_SUBMISSIONS\n : submissions.flatMap(([each, sent]) =>\n each === undefined || sent === undefined ? [] : [[each, sent]],\n ),\n }\n\n // Reported after every render, so the form reads what the field shows.\n useEffect(() => {\n registry?.set(id, entry)\n })\n\n useEffect(\n () => () => {\n registry?.remove(id)\n },\n [id, registry],\n )\n\n return {\n error: error ?? lineOf(server) ?? lineOf(shown),\n onBlur: () => {\n if (edited.current) {\n edited.current = false\n setClearedFrom(serverErrors)\n setShowing(native)\n }\n },\n onEdit: () => {\n edited.current = true\n setClearedFrom(serverErrors)\n },\n }\n}\n\n/** Whether the field is inside a form, which keeps its message line drawn. */\nfunction useInsideForm() {\n return use(FormContext) !== null\n}\n\nexport {\n createRegistry,\n FIELD_VALIDATION_BEHAVIOR,\n FormContext,\n submitOf,\n useFieldValidation,\n useInsideForm,\n}\nexport type {\n Focusable,\n FormValidationBehavior,\n FormValues,\n ValidationError,\n ValidationErrors,\n ValidationResult,\n}\n"],"mappings":";;;;;;;;AAqGA,MAAM4C,4BAAoD;;AAG1D,MAAMC,iBAAiB;AAEvB,MAAMC,YAA8B,CAAC;AAErC,MAAMC,cAAiC,CAAA;AAGvC,MAAMC,gBAAgB,CAACC,KAAAA,GAAWA,KAAAA,CAAS;AAE3C,MAAME,iBAAuC,CAAA;AAE7C,MAAMC,cAAcnD,cAAgC,IAAI;;;;;;AAOxD,SAASoD,iBAA+B;CACtC,MAAMC,yBAAS,IAAIC,IAAuB;CAE1C,OAAO;EACL1B,eAAe,CAAC,GAAGyB,OAAOE,OAAO,CAAC;EAClC1B,SAASC,OAAO;GACduB,OAAOG,OAAO1B,EAAE;EAClB;EACAC,MAAMD,IAAIE,UAAU;GAClBqB,OAAOtB,IAAID,IAAIE,KAAK;EACtB;CACF;AACF;AAGA,SAASyB,QAAQ/C,SAAsC;CACrD,aAAa;EACXA,QAAQgD,SAASpC,MAAM;CACzB;AACF;AAGA,SAASqC,OAAOC,UAAiD;CAC/D,OAAOA,SAASC,WAAW,IAAIb,KAAAA,IAAYY,SAASE,KAAK,GAAG;AAC9D;AAGA,SAASC,WAAWC,QAA6C;CAC/D,IAAI,OAAOA,WAAW,UACpB,OAAOA,WAAW,KAAKlB,cAAc,CAACkB,MAAM;CAG9C,OAAOA,WAAW,QAAQA,WAAWhB,KAAAA,KAAagB,WAA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EAAA,OAAAI,cAAA;EACvCsB,WAAA;GACN,IAAIjB,OAAM3B,SAAQ;IAChB2B,OAAM3B,UAAW;IACjBwB,eAAeF,YAAY;IAC3BI,WAAWE,MAAM;GAAC;EACnB;EACFV,EAAA,KAAAU;EAAAV,EAAA,KAAAI;EAAAJ,EAAA,KAAA0B;CAAA,OAAAA,KAAA1B,EAAA;CAAA,IAAA2B;CAAA,IAAA3B,EAAA,OAAAI,cAAA;EACOuB,WAAA;GACNlB,OAAM3B,UAAW;GACjBwB,eAAeF,YAAY;EAAC;EAC7BJ,EAAA,KAAAI;EAAAJ,EAAA,KAAA2B;CAAA,OAAAA,KAAA3B,EAAA;CAAA,IAAA4B;CAAA,IAAA5B,EAAA,QAAAyB,MAAAzB,EAAA,QAAA0B,MAAA1B,EAAA,QAAA2B,IAAA;EAZIC,KAAA;GAAA5F,OACEyF;GAAwCI,QACvCH;GAMPI,QACOH;EAIV;EAAC3B,EAAA,MAAAyB;EAAAzB,EAAA,MAAA0B;EAAA1B,EAAA,MAAA2B;EAAA3B,EAAA,MAAA4B;CAAA,OAAAA,KAAA5B,EAAA;CAAA,OAbM4B;AAaN;;AAxFH,SAAAN,MAAAvB,IAAA;CA0D6B,MAAA,CAAAgC,QAAAC,QAAAjC;CAAY,OAC/BgB,WAAS3C,KAAAA,KAAa4D,SAAS5D,KAAAA,IAA/B,CAAA,IAAA,CAAiD,CAAC2C,QAAMiB,IAAI,CAAC;AAAC;AAiCxE,SAASC,gBAAgB;CACvB,OAAO5G,IAAIkD,WAAW,MAAM;AAC9B"}
|
package/dist/glyphs/index.js
CHANGED
|
@@ -6,6 +6,43 @@ import { I18nManager, StyleSheet } from "react-native";
|
|
|
6
6
|
import { jsx } from "react/jsx-runtime";
|
|
7
7
|
import Svg, { Path } from "react-native-svg";
|
|
8
8
|
//#region src/glyphs/index.tsx
|
|
9
|
+
function ArrowBackGlyph(props) {
|
|
10
|
+
const $ = c(3);
|
|
11
|
+
let t0;
|
|
12
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
13
|
+
t0 = /* @__PURE__ */ jsx(Path, { d: "M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z" });
|
|
14
|
+
$[0] = t0;
|
|
15
|
+
} else t0 = $[0];
|
|
16
|
+
let t1;
|
|
17
|
+
if ($[1] !== props) {
|
|
18
|
+
t1 = /* @__PURE__ */ jsx(Glyph, {
|
|
19
|
+
...props,
|
|
20
|
+
mirrored: true,
|
|
21
|
+
children: t0
|
|
22
|
+
});
|
|
23
|
+
$[1] = props;
|
|
24
|
+
$[2] = t1;
|
|
25
|
+
} else t1 = $[2];
|
|
26
|
+
return t1;
|
|
27
|
+
}
|
|
28
|
+
function ArrowDownwardGlyph(props) {
|
|
29
|
+
const $ = c(3);
|
|
30
|
+
let t0;
|
|
31
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
32
|
+
t0 = /* @__PURE__ */ jsx(Path, { d: "M20 12l-1.41-1.41L13 16.17V4h-2v12.17l-5.58-5.59L4 12l8 8 8-8z" });
|
|
33
|
+
$[0] = t0;
|
|
34
|
+
} else t0 = $[0];
|
|
35
|
+
let t1;
|
|
36
|
+
if ($[1] !== props) {
|
|
37
|
+
t1 = /* @__PURE__ */ jsx(Glyph, {
|
|
38
|
+
...props,
|
|
39
|
+
children: t0
|
|
40
|
+
});
|
|
41
|
+
$[1] = props;
|
|
42
|
+
$[2] = t1;
|
|
43
|
+
} else t1 = $[2];
|
|
44
|
+
return t1;
|
|
45
|
+
}
|
|
9
46
|
function ArrowDropDownGlyph(props) {
|
|
10
47
|
const $ = c(3);
|
|
11
48
|
let t0;
|
|
@@ -24,6 +61,42 @@ function ArrowDropDownGlyph(props) {
|
|
|
24
61
|
} else t1 = $[2];
|
|
25
62
|
return t1;
|
|
26
63
|
}
|
|
64
|
+
function ArrowUpwardGlyph(props) {
|
|
65
|
+
const $ = c(3);
|
|
66
|
+
let t0;
|
|
67
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
68
|
+
t0 = /* @__PURE__ */ jsx(Path, { d: "M4 12l1.41 1.41L11 7.83V20h2V7.83l5.58 5.59L20 12l-8-8-8 8z" });
|
|
69
|
+
$[0] = t0;
|
|
70
|
+
} else t0 = $[0];
|
|
71
|
+
let t1;
|
|
72
|
+
if ($[1] !== props) {
|
|
73
|
+
t1 = /* @__PURE__ */ jsx(Glyph, {
|
|
74
|
+
...props,
|
|
75
|
+
children: t0
|
|
76
|
+
});
|
|
77
|
+
$[1] = props;
|
|
78
|
+
$[2] = t1;
|
|
79
|
+
} else t1 = $[2];
|
|
80
|
+
return t1;
|
|
81
|
+
}
|
|
82
|
+
function CalendarGlyph(props) {
|
|
83
|
+
const $ = c(3);
|
|
84
|
+
let t0;
|
|
85
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
86
|
+
t0 = /* @__PURE__ */ jsx(Path, { d: "M19 4h-1V2h-2v2H8V2H6v2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2zm0 16H5V10h14v10zm0-12H5V6h14v2z" });
|
|
87
|
+
$[0] = t0;
|
|
88
|
+
} else t0 = $[0];
|
|
89
|
+
let t1;
|
|
90
|
+
if ($[1] !== props) {
|
|
91
|
+
t1 = /* @__PURE__ */ jsx(Glyph, {
|
|
92
|
+
...props,
|
|
93
|
+
children: t0
|
|
94
|
+
});
|
|
95
|
+
$[1] = props;
|
|
96
|
+
$[2] = t1;
|
|
97
|
+
} else t1 = $[2];
|
|
98
|
+
return t1;
|
|
99
|
+
}
|
|
27
100
|
function CheckGlyph(props) {
|
|
28
101
|
const $ = c(3);
|
|
29
102
|
let t0;
|
|
@@ -42,6 +115,24 @@ function CheckGlyph(props) {
|
|
|
42
115
|
} else t1 = $[2];
|
|
43
116
|
return t1;
|
|
44
117
|
}
|
|
118
|
+
function ChevronDownGlyph(props) {
|
|
119
|
+
const $ = c(3);
|
|
120
|
+
let t0;
|
|
121
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
122
|
+
t0 = /* @__PURE__ */ jsx(Path, { d: "M16.59 8.59 12 13.17 7.41 8.59 6 10l6 6 6-6z" });
|
|
123
|
+
$[0] = t0;
|
|
124
|
+
} else t0 = $[0];
|
|
125
|
+
let t1;
|
|
126
|
+
if ($[1] !== props) {
|
|
127
|
+
t1 = /* @__PURE__ */ jsx(Glyph, {
|
|
128
|
+
...props,
|
|
129
|
+
children: t0
|
|
130
|
+
});
|
|
131
|
+
$[1] = props;
|
|
132
|
+
$[2] = t1;
|
|
133
|
+
} else t1 = $[2];
|
|
134
|
+
return t1;
|
|
135
|
+
}
|
|
45
136
|
function ChevronEndGlyph(props) {
|
|
46
137
|
const $ = c(3);
|
|
47
138
|
let t0;
|
|
@@ -61,6 +152,24 @@ function ChevronEndGlyph(props) {
|
|
|
61
152
|
} else t1 = $[2];
|
|
62
153
|
return t1;
|
|
63
154
|
}
|
|
155
|
+
function ClockGlyph(props) {
|
|
156
|
+
const $ = c(3);
|
|
157
|
+
let t0;
|
|
158
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
159
|
+
t0 = /* @__PURE__ */ jsx(Path, { d: "M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8zm.5-13H11v6l5.25 3.15.75-1.23-4.5-2.67z" });
|
|
160
|
+
$[0] = t0;
|
|
161
|
+
} else t0 = $[0];
|
|
162
|
+
let t1;
|
|
163
|
+
if ($[1] !== props) {
|
|
164
|
+
t1 = /* @__PURE__ */ jsx(Glyph, {
|
|
165
|
+
...props,
|
|
166
|
+
children: t0
|
|
167
|
+
});
|
|
168
|
+
$[1] = props;
|
|
169
|
+
$[2] = t1;
|
|
170
|
+
} else t1 = $[2];
|
|
171
|
+
return t1;
|
|
172
|
+
}
|
|
64
173
|
function CloseGlyph(props) {
|
|
65
174
|
const $ = c(3);
|
|
66
175
|
let t0;
|
|
@@ -122,6 +231,24 @@ function Glyph(t0) {
|
|
|
122
231
|
} else t4 = $[8];
|
|
123
232
|
return t4;
|
|
124
233
|
}
|
|
234
|
+
function KeyboardGlyph(props) {
|
|
235
|
+
const $ = c(3);
|
|
236
|
+
let t0;
|
|
237
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
238
|
+
t0 = /* @__PURE__ */ jsx(Path, { d: "M20 5H4c-1.1 0-1.99.9-1.99 2L2 17c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 12H4V7h16v10zm-9-9h2v2h-2zm0 3h2v2h-2zM8 8h2v2H8zm0 3h2v2H8zm-3 0h2v2H5zm0-3h2v2H5zm3 6h8v2H8zm6-3h2v2h-2zm0-3h2v2h-2zm3 3h2v2h-2zm0-3h2v2h-2z" });
|
|
239
|
+
$[0] = t0;
|
|
240
|
+
} else t0 = $[0];
|
|
241
|
+
let t1;
|
|
242
|
+
if ($[1] !== props) {
|
|
243
|
+
t1 = /* @__PURE__ */ jsx(Glyph, {
|
|
244
|
+
...props,
|
|
245
|
+
children: t0
|
|
246
|
+
});
|
|
247
|
+
$[1] = props;
|
|
248
|
+
$[2] = t1;
|
|
249
|
+
} else t1 = $[2];
|
|
250
|
+
return t1;
|
|
251
|
+
}
|
|
125
252
|
function MinusGlyph(props) {
|
|
126
253
|
const $ = c(3);
|
|
127
254
|
let t0;
|
|
@@ -196,6 +323,6 @@ function SearchGlyph(props) {
|
|
|
196
323
|
return t1;
|
|
197
324
|
}
|
|
198
325
|
//#endregion
|
|
199
|
-
export { ArrowDropDownGlyph, CheckGlyph, ChevronEndGlyph, CloseGlyph, IndeterminateGlyph, MinusGlyph, PersonGlyph, PlusGlyph, SearchGlyph };
|
|
326
|
+
export { ArrowBackGlyph, ArrowDownwardGlyph, ArrowDropDownGlyph, ArrowUpwardGlyph, CalendarGlyph, CheckGlyph, ChevronDownGlyph, ChevronEndGlyph, ClockGlyph, CloseGlyph, IndeterminateGlyph, KeyboardGlyph, MinusGlyph, PersonGlyph, PlusGlyph, SearchGlyph };
|
|
200
327
|
|
|
201
328
|
//# sourceMappingURL=index.js.map
|
package/dist/glyphs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["ReactNode","ColorValue","StyleProp","ViewStyle","I18nManager","StyleSheet","Svg","Path","HIDDEN","useIconStyle","glyphStyles","GlyphProps","color","size","style","testID","ArrowBackGlyph","props","$","_c","t0","Symbol","for","t1","ArrowDownwardGlyph","ArrowDropDownGlyph","ArrowUpwardGlyph","CalendarGlyph","CheckGlyph","ChevronDownGlyph","ChevronEndGlyph","ClockGlyph","CloseGlyph","Glyph","children","mirrored","undefined","slot","side","t2","t3","compose","isRTL","t4","KeyboardGlyph","MinusGlyph","IndeterminateGlyph","PersonGlyph","PlusGlyph","SearchGlyph","_c"],"sources":["../../src/glyphs/index.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport type { ColorValue, StyleProp, ViewStyle } from 'react-native'\n\nimport { I18nManager, StyleSheet } from 'react-native'\nimport Svg, { Path } from 'react-native-svg'\n\nimport { HIDDEN } from './hidden'\nimport { useIconStyle } from './icon-style'\nimport { glyphStyles } from './styles'\n\n// The glyphs the library's own controls draw, the same set kanso-ui draws on\n// web: the check and the dash a checkbox shows, the plus and minus a number\n// field's steppers show, the magnifier and cross a search field shows, and the\n// rest named beside each one. Private to the library, as on web: a call site\n// with icons of its own passes them to the slots that take a node, and reads\n// the slot's colour and size through `useIconStyle()`.\n//\n// The paths are kanso-ui's, unchanged: Material Symbols on their 24-unit grid,\n// which is what the checkbox page draws at 18dp, the icon buttons page at 20\n// and the search, menus, date picker and time picker pages at 24.\n\ntype GlyphProps = {\n /** The fill. Defaults to the colour of the slot the glyph sits in. */\n readonly color?: ColorValue\n /** The square's side in dp. Defaults to the size of the slot. */\n readonly size?: number\n readonly style?: StyleProp<ViewStyle>\n readonly testID?: string\n}\n\n// What a search view's back button draws, pointing at the page it returns to.\n// It says \"back\" rather than \"to the left\", so it mirrors under a right-to-left\n// layout.\nfunction ArrowBackGlyph(props: GlyphProps) {\n return (\n <Glyph {...props} mirrored>\n <Path d=\"M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z\" />\n </Glyph>\n )\n}\n\n// Which way a sorted column is ordered. Up is ascending and down is\n// descending. Neither mirrors under a right-to-left layout: they say \"up\" and\n// \"down\" rather than \"onward\", and those do not flip.\nfunction ArrowDownwardGlyph(props: GlyphProps) {\n return (\n <Glyph {...props}>\n <Path d=\"M20 12l-1.41-1.41L13 16.17V4h-2v12.17l-5.58-5.59L4 12l8 8 8-8z\" />\n </Glyph>\n )\n}\n\n// What a menu button draws after its label, pointing at the list it opens.\n// Down is down in either writing direction, so it does not mirror.\nfunction ArrowDropDownGlyph(props: GlyphProps) {\n return (\n <Glyph {...props}>\n <Path d=\"M7 10l5 5 5-5z\" />\n </Glyph>\n )\n}\n\nfunction ArrowUpwardGlyph(props: GlyphProps) {\n return (\n <Glyph {...props}>\n <Path d=\"M4 12l1.41 1.41L11 7.83V20h2V7.83l5.58 5.59L20 12l-8-8-8 8z\" />\n </Glyph>\n )\n}\n\n// What the date picker's trigger draws: the calendar a date is picked from.\nfunction CalendarGlyph(props: GlyphProps) {\n return (\n <Glyph {...props}>\n <Path d=\"M19 4h-1V2h-2v2H8V2H6v2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2zm0 16H5V10h14v10zm0-12H5V6h14v2z\" />\n </Glyph>\n )\n}\n\nfunction CheckGlyph(props: GlyphProps) {\n return (\n <Glyph {...props}>\n <Path d=\"M9 16.17 4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z\" />\n </Glyph>\n )\n}\n\n// Points down at the menu a split button's second half opens.\nfunction ChevronDownGlyph(props: GlyphProps) {\n return (\n <Glyph {...props}>\n <Path d=\"M16.59 8.59 12 13.17 7.41 8.59 6 10l6 6 6-6z\" />\n </Glyph>\n )\n}\n\n// Points at the submenu a menu item opens. It says \"further in\" rather than\n// \"to the right\", so it mirrors under a right-to-left layout.\nfunction ChevronEndGlyph(props: GlyphProps) {\n return (\n <Glyph {...props} mirrored>\n <Path d=\"M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z\" />\n </Glyph>\n )\n}\n\n// What the time picker's trigger draws, and the button that takes its keyboard\n// entry back to the dial: the clock a time is picked from.\nfunction ClockGlyph(props: GlyphProps) {\n return (\n <Glyph {...props}>\n <Path d=\"M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8zm.5-13H11v6l5.25 3.15.75-1.23-4.5-2.67z\" />\n </Glyph>\n )\n}\n\nfunction CloseGlyph(props: GlyphProps) {\n return (\n <Glyph {...props}>\n <Path d=\"M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z\" />\n </Glyph>\n )\n}\n\n/**\n * The svg every glyph draws: the 24-unit grid its path is on, a square of the\n * slot's size filled in the slot's colour, and nothing a screen reader\n * announces, since the control around a glyph carries the name. A glyph whose\n * direction means \"onward\" or \"back\" passes `mirrored`, which turns it over\n * under a right-to-left layout as `:dir(rtl)` does on web.\n */\nfunction Glyph({\n children,\n color,\n mirrored = false,\n size,\n style,\n testID,\n}: GlyphProps & { readonly children: ReactNode; readonly mirrored?: boolean }) {\n const slot = useIconStyle()\n const side = size ?? slot.size\n return (\n <Svg\n {...HIDDEN}\n color={color ?? slot.color}\n fill=\"currentColor\"\n height={side}\n style={StyleSheet.compose(\n mirrored && I18nManager.isRTL ? glyphStyles.mirrored : undefined,\n style,\n )}\n testID={testID}\n viewBox=\"0 0 24 24\"\n width={side}\n >\n {children}\n </Svg>\n )\n}\n\n// What the time picker's dial draws on the button that switches it to typed\n// entry.\nfunction KeyboardGlyph(props: GlyphProps) {\n return (\n <Glyph {...props}>\n <Path d=\"M20 5H4c-1.1 0-1.99.9-1.99 2L2 17c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 12H4V7h16v10zm-9-9h2v2h-2zm0 3h2v2h-2zM8 8h2v2H8zm0 3h2v2H8zm-3 0h2v2H5zm0-3h2v2H5zm3 6h8v2H8zm6-3h2v2h-2zm0-3h2v2h-2zm3 3h2v2h-2zm0-3h2v2h-2z\" />\n </Glyph>\n )\n}\n\n// The same rule stands for a partly selected checkbox and for a stepper's\n// decrement; the two names say which is meant at the call site.\nfunction MinusGlyph(props: GlyphProps) {\n return (\n <Glyph {...props}>\n <Path d=\"M19 13H5v-2h14v2z\" />\n </Glyph>\n )\n}\n\nconst IndeterminateGlyph = MinusGlyph\n\n// What an avatar with no name to take initials from draws: Material Design's\n// anonymous person, a head over shoulders.\nfunction PersonGlyph(props: GlyphProps) {\n return (\n <Glyph {...props}>\n <Path d=\"M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z\" />\n </Glyph>\n )\n}\n\nfunction PlusGlyph(props: GlyphProps) {\n return (\n <Glyph {...props}>\n <Path d=\"M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z\" />\n </Glyph>\n )\n}\n\nfunction SearchGlyph(props: GlyphProps) {\n return (\n <Glyph {...props}>\n <Path d=\"M15.5 14h-.79l-.28-.27A6.471 6.471 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z\" />\n </Glyph>\n )\n}\n\nexport {\n ArrowBackGlyph,\n ArrowDownwardGlyph,\n ArrowDropDownGlyph,\n ArrowUpwardGlyph,\n CalendarGlyph,\n CheckGlyph,\n ChevronDownGlyph,\n ChevronEndGlyph,\n ClockGlyph,\n CloseGlyph,\n IndeterminateGlyph,\n KeyboardGlyph,\n MinusGlyph,\n PersonGlyph,\n PlusGlyph,\n SearchGlyph,\n}\nexport type { GlyphProps }\n"],"mappings":";;;;;;;;AAsDA,SAAAyB,mBAAAR,OAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CAAA,IAAAC;CAAA,IAAAF,EAAA,OAAAG,OAAAC,IAAA,2BAAA,GAAA;EAGMF,KAAA,oBAAC,MAAD,EAAQ,GAAA,iBAAgB,CAAA;EAAGF,EAAA,KAAAE;CAAA,OAAAA,KAAAF,EAAA;CAAA,IAAAK;CAAA,IAAAL,EAAA,OAAAD,OAAA;EAD7BM,KAAA,oBAAC,OAAD;GAAM,GAAKN;GACTG,UAAAA;EADI,CAAA;EAEEF,EAAA,KAAAD;EAAAC,EAAA,KAAAK;CAAA,OAAAA,KAAAL,EAAA;CAAA,OAFRK;AAEQ;AAqBZ,SAAAK,WAAAX,OAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CAAA,IAAAC;CAAA,IAAAF,EAAA,OAAAG,OAAAC,IAAA,2BAAA,GAAA;EAGMF,KAAA,oBAAC,MAAD,EAAQ,GAAA,oDAAmD,CAAA;EAAGF,EAAA,KAAAE;CAAA,OAAAA,KAAAF,EAAA;CAAA,IAAAK;CAAA,IAAAL,EAAA,OAAAD,OAAA;EADhEM,KAAA,oBAAC,OAAD;GAAM,GAAKN;GACTG,UAAAA;EADI,CAAA;EAEEF,EAAA,KAAAD;EAAAC,EAAA,KAAAK;CAAA,OAAAA,KAAAL,EAAA;CAAA,OAFRK;AAEQ;AAeZ,SAAAO,gBAAAb,OAAA;CAAA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ps","color","size","style","testID","ArrowBackGlyph","props","$","_c","t0","Symbol","for","t1","ArrowDownwardGlyph","ArrowDropDownGlyph","ArrowUpwardGlyph","CalendarGlyph","CheckGlyph","ChevronDownGlyph","ChevronEndGlyph","ClockGlyph","CloseGlyph","Glyph","children","mirrored","undefined","slot","side","t2","t3","compose","isRTL","t4","KeyboardGlyph","MinusGlyph","IndeterminateGlyph","PersonGlyph","PlusGlyph","SearchGlyph","_c"],"sources":["../../src/glyphs/index.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport type { ColorValue, StyleProp, ViewStyle } from 'react-native'\n\nimport { I18nManager, StyleSheet } from 'react-native'\nimport Svg, { Path } from 'react-native-svg'\n\nimport { HIDDEN } from './hidden'\nimport { useIconStyle } from './icon-style'\nimport { glyphStyles } from './styles'\n\n// The glyphs the library's own controls draw, the same set kanso-ui draws on\n// web: the check and the dash a checkbox shows, the plus and minus a number\n// field's steppers show, the magnifier and cross a search field shows, and the\n// rest named beside each one. Private to the library, as on web: a call site\n// with icons of its own passes them to the slots that take a node, and reads\n// the slot's colour and size through `useIconStyle()`.\n//\n// The paths are kanso-ui's, unchanged: Material Symbols on their 24-unit grid,\n// which is what the checkbox page draws at 18dp, the icon buttons page at 20\n// and the search, menus, date picker and time picker pages at 24.\n\ntype GlyphProps = {\n /** The fill. Defaults to the colour of the slot the glyph sits in. */\n readonly color?: ColorValue\n /** The square's side in dp. Defaults to the size of the slot. */\n readonly size?: number\n readonly style?: StyleProp<ViewStyle>\n readonly testID?: string\n}\n\n// What a search view's back button draws, pointing at the page it returns to.\n// It says \"back\" rather than \"to the left\", so it mirrors under a right-to-left\n// layout.\nfunction ArrowBackGlyph(props: GlyphProps) {\n return (\n <Glyph {...props} mirrored>\n <Path d=\"M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z\" />\n </Glyph>\n )\n}\n\n// Which way a sorted column is ordered. Up is ascending and down is\n// descending. Neither mirrors under a right-to-left layout: they say \"up\" and\n// \"down\" rather than \"onward\", and those do not flip.\nfunction ArrowDownwardGlyph(props: GlyphProps) {\n return (\n <Glyph {...props}>\n <Path d=\"M20 12l-1.41-1.41L13 16.17V4h-2v12.17l-5.58-5.59L4 12l8 8 8-8z\" />\n </Glyph>\n )\n}\n\n// What a menu button draws after its label, pointing at the list it opens.\n// Down is down in either writing direction, so it does not mirror.\nfunction ArrowDropDownGlyph(props: GlyphProps) {\n return (\n <Glyph {...props}>\n <Path d=\"M7 10l5 5 5-5z\" />\n </Glyph>\n )\n}\n\nfunction ArrowUpwardGlyph(props: GlyphProps) {\n return (\n <Glyph {...props}>\n <Path d=\"M4 12l1.41 1.41L11 7.83V20h2V7.83l5.58 5.59L20 12l-8-8-8 8z\" />\n </Glyph>\n )\n}\n\n// What the date picker's trigger draws: the calendar a date is picked from.\nfunction CalendarGlyph(props: GlyphProps) {\n return (\n <Glyph {...props}>\n <Path d=\"M19 4h-1V2h-2v2H8V2H6v2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2zm0 16H5V10h14v10zm0-12H5V6h14v2z\" />\n </Glyph>\n )\n}\n\nfunction CheckGlyph(props: GlyphProps) {\n return (\n <Glyph {...props}>\n <Path d=\"M9 16.17 4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z\" />\n </Glyph>\n )\n}\n\n// Points down at the menu a split button's second half opens, and at the\n// list a select opens.\nfunction ChevronDownGlyph(props: GlyphProps) {\n return (\n <Glyph {...props}>\n <Path d=\"M16.59 8.59 12 13.17 7.41 8.59 6 10l6 6 6-6z\" />\n </Glyph>\n )\n}\n\n// Points at the submenu a menu item opens. It says \"further in\" rather than\n// \"to the right\", so it mirrors under a right-to-left layout.\nfunction ChevronEndGlyph(props: GlyphProps) {\n return (\n <Glyph {...props} mirrored>\n <Path d=\"M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z\" />\n </Glyph>\n )\n}\n\n// What the time picker's trigger draws, and the button that takes its keyboard\n// entry back to the dial: the clock a time is picked from.\nfunction ClockGlyph(props: GlyphProps) {\n return (\n <Glyph {...props}>\n <Path d=\"M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8zm.5-13H11v6l5.25 3.15.75-1.23-4.5-2.67z\" />\n </Glyph>\n )\n}\n\nfunction CloseGlyph(props: GlyphProps) {\n return (\n <Glyph {...props}>\n <Path d=\"M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z\" />\n </Glyph>\n )\n}\n\n/**\n * The svg every glyph draws: the 24-unit grid its path is on, a square of the\n * slot's size filled in the slot's colour, and nothing a screen reader\n * announces, since the control around a glyph carries the name. A glyph whose\n * direction means \"onward\" or \"back\" passes `mirrored`, which turns it over\n * under a right-to-left layout as `:dir(rtl)` does on web.\n */\nfunction Glyph({\n children,\n color,\n mirrored = false,\n size,\n style,\n testID,\n}: GlyphProps & { readonly children: ReactNode; readonly mirrored?: boolean }) {\n const slot = useIconStyle()\n const side = size ?? slot.size\n return (\n <Svg\n {...HIDDEN}\n color={color ?? slot.color}\n fill=\"currentColor\"\n height={side}\n style={StyleSheet.compose(\n mirrored && I18nManager.isRTL ? glyphStyles.mirrored : undefined,\n style,\n )}\n testID={testID}\n viewBox=\"0 0 24 24\"\n width={side}\n >\n {children}\n </Svg>\n )\n}\n\n// What the time picker's dial draws on the button that switches it to typed\n// entry.\nfunction KeyboardGlyph(props: GlyphProps) {\n return (\n <Glyph {...props}>\n <Path d=\"M20 5H4c-1.1 0-1.99.9-1.99 2L2 17c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 12H4V7h16v10zm-9-9h2v2h-2zm0 3h2v2h-2zM8 8h2v2H8zm0 3h2v2H8zm-3 0h2v2H5zm0-3h2v2H5zm3 6h8v2H8zm6-3h2v2h-2zm0-3h2v2h-2zm3 3h2v2h-2zm0-3h2v2h-2z\" />\n </Glyph>\n )\n}\n\n// The same rule stands for a partly selected checkbox and for a stepper's\n// decrement; the two names say which is meant at the call site.\nfunction MinusGlyph(props: GlyphProps) {\n return (\n <Glyph {...props}>\n <Path d=\"M19 13H5v-2h14v2z\" />\n </Glyph>\n )\n}\n\nconst IndeterminateGlyph = MinusGlyph\n\n// What an avatar with no name to take initials from draws: Material Design's\n// anonymous person, a head over shoulders.\nfunction PersonGlyph(props: GlyphProps) {\n return (\n <Glyph {...props}>\n <Path d=\"M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z\" />\n </Glyph>\n )\n}\n\nfunction PlusGlyph(props: GlyphProps) {\n return (\n <Glyph {...props}>\n <Path d=\"M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z\" />\n </Glyph>\n )\n}\n\nfunction SearchGlyph(props: GlyphProps) {\n return (\n <Glyph {...props}>\n <Path d=\"M15.5 14h-.79l-.28-.27A6.471 6.471 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z\" />\n </Glyph>\n )\n}\n\nexport {\n ArrowBackGlyph,\n ArrowDownwardGlyph,\n ArrowDropDownGlyph,\n ArrowUpwardGlyph,\n CalendarGlyph,\n CheckGlyph,\n ChevronDownGlyph,\n ChevronEndGlyph,\n ClockGlyph,\n CloseGlyph,\n IndeterminateGlyph,\n KeyboardGlyph,\n MinusGlyph,\n PersonGlyph,\n PlusGlyph,\n SearchGlyph,\n}\nexport type { GlyphProps }\n"],"mappings":";;;;;;;;AAiCA,SA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AAA,KAAAK;CAAA,OAAAA,KAAAL,EAAA;CAAA,OAFRK;AAEQ"}
|
package/dist/i18n/index.js
CHANGED
|
@@ -5,6 +5,14 @@ import { MESSAGES } from "./messages.js";
|
|
|
5
5
|
const TABLE = new Map(Object.entries(MESSAGES));
|
|
6
6
|
const cache = /* @__PURE__ */ new Map();
|
|
7
7
|
/**
|
|
8
|
+
* A column's width as its resize handle reads it, "120 pixels" in English,
|
|
9
|
+
* in `locale` or the device's, with the width in the locale's digits.
|
|
10
|
+
*/
|
|
11
|
+
function columnSizeFor(value, locale) {
|
|
12
|
+
const resolved = localeOf(locale);
|
|
13
|
+
return messagesFor(resolved).table.columnSize.replace("{value}", formatCount(value, resolved));
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
8
16
|
* A field's character limit in words, in `locale` or the device's, for a
|
|
9
17
|
* screen reader: the limit in the locale's digits, in the plural form its
|
|
10
18
|
* rules give it.
|
|
@@ -14,6 +22,16 @@ function limitFor(count, locale) {
|
|
|
14
22
|
const forms = messagesFor(resolved).characterLimit;
|
|
15
23
|
return (forms[pluralOf(resolved, count)] ?? forms.other).replace("{count}", formatCount(count, resolved));
|
|
16
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Several values written as one list in the locale's words, "First item and
|
|
27
|
+
* Second item" in English, as a field holding several chosen options shows
|
|
28
|
+
* them. Hermes may lack `Intl.ListFormat`, and a comma between them is the
|
|
29
|
+
* list there.
|
|
30
|
+
*/
|
|
31
|
+
function listFor(values, locale) {
|
|
32
|
+
if (typeof Intl.ListFormat === "function") return new Intl.ListFormat(localeOf(locale), { type: "conjunction" }).format(values);
|
|
33
|
+
return values.join(", ");
|
|
34
|
+
}
|
|
17
35
|
function lookUp(locale) {
|
|
18
36
|
const tag = locale.split("-u-")[0];
|
|
19
37
|
const language = tag.split("-")[0];
|
|
@@ -43,7 +61,24 @@ function resultsFor(count, locale) {
|
|
|
43
61
|
if (count === 0) return messages.noResults;
|
|
44
62
|
return (pluralOf(resolved, count) === "one" ? messages.results.one : messages.results.other).replace("{count}", new Intl.NumberFormat(resolved).format(count));
|
|
45
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* What a carousel's item is called, "2 of 6" in English, in `locale` or the
|
|
66
|
+
* device's: its place and how many items there are, both in the locale's
|
|
67
|
+
* digits, as web's carousel writes them.
|
|
68
|
+
*/
|
|
69
|
+
function slideLabelFor(index, count, locale) {
|
|
70
|
+
const resolved = localeOf(locale);
|
|
71
|
+
return messagesFor(resolved).slideLabel.replace("{index}", formatCount(index, resolved)).replace("{count}", formatCount(count, resolved));
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* What a table says once its rows are sorted, "sorted by column Label in
|
|
75
|
+
* ascending order" in English, in `locale` or the device's.
|
|
76
|
+
*/
|
|
77
|
+
function sortedFor(direction, columnName, locale) {
|
|
78
|
+
const { table } = messagesFor(locale);
|
|
79
|
+
return (direction === "ascending" ? table.ascendingSort : table.descendingSort).replace("{columnName}", columnName);
|
|
80
|
+
}
|
|
46
81
|
//#endregion
|
|
47
|
-
export { limitFor, messagesFor, resultsFor };
|
|
82
|
+
export { columnSizeFor, limitFor, listFor, messagesFor, resultsFor, slideLabelFor, sortedFor };
|
|
48
83
|
|
|
49
84
|
//# sourceMappingURL=index.js.map
|