@panneau/fields 4.1.1 → 5.0.0-alpha.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 +72 -0
- package/dist/boolean/BooleanField.d.ts +11 -0
- package/dist/boolean/BooleanField.d.ts.map +1 -0
- package/dist/boolean/BooleanField.js +67 -0
- package/dist/boolean/BooleanField.js.map +1 -0
- package/dist/boolean/index.d.ts +2 -0
- package/dist/boolean/index.d.ts.map +1 -0
- package/dist/boolean/index.js +1 -0
- package/dist/color/ColorField.css +33 -0
- package/dist/color/ColorField.d.ts +16 -0
- package/dist/color/ColorField.d.ts.map +1 -0
- package/dist/color/ColorField.js +187 -0
- package/dist/color/ColorField.js.map +1 -0
- package/dist/color/ColorField.module.js +14 -0
- package/dist/color/ColorField.module.js.map +1 -0
- package/dist/color/index.d.ts +2 -0
- package/dist/color/index.d.ts.map +1 -0
- package/dist/color/index.js +1 -0
- package/dist/date/DateField.d.ts +16 -0
- package/dist/date/DateField.d.ts.map +1 -0
- package/dist/date/DateField.js +132 -0
- package/dist/date/DateField.js.map +1 -0
- package/dist/date/index.d.ts +2 -0
- package/dist/date/index.d.ts.map +1 -0
- package/dist/date/index.js +1 -0
- package/dist/datetime/DateTimeField.d.ts +22 -0
- package/dist/datetime/DateTimeField.d.ts.map +1 -0
- package/dist/datetime/DateTimeField.js +78 -0
- package/dist/datetime/DateTimeField.js.map +1 -0
- package/dist/datetime/index.d.ts +2 -0
- package/dist/datetime/index.d.ts.map +1 -0
- package/dist/datetime/index.js +1 -0
- package/dist/email/EmailField.d.ts +8 -0
- package/dist/email/EmailField.d.ts.map +1 -0
- package/dist/email/EmailField.js +84 -0
- package/dist/email/EmailField.js.map +1 -0
- package/dist/email/index.d.ts +2 -0
- package/dist/email/index.d.ts.map +1 -0
- package/dist/email/index.js +1 -0
- package/dist/group/GroupField.css +14 -0
- package/dist/group/GroupField.d.ts +19 -0
- package/dist/group/GroupField.d.ts.map +1 -0
- package/dist/group/GroupField.js +140 -0
- package/dist/group/GroupField.js.map +1 -0
- package/dist/group/GroupField.module.js +8 -0
- package/dist/group/GroupField.module.js.map +1 -0
- package/dist/group/index.d.ts +2 -0
- package/dist/group/index.d.ts.map +1 -0
- package/dist/group/index.js +1 -0
- package/dist/index.d.ts +8 -12
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -134
- package/dist/locales/index.d.ts +15 -0
- package/dist/locales/index.d.ts.map +1 -0
- package/dist/locales/index.js +21 -0
- package/dist/locales/index.js.map +1 -0
- package/dist/localized/LocalizedField.css +9 -0
- package/dist/localized/LocalizedField.d.ts +36 -0
- package/dist/localized/LocalizedField.d.ts.map +1 -0
- package/dist/localized/LocalizedField.js +207 -0
- package/dist/localized/LocalizedField.js.map +1 -0
- package/dist/localized/LocalizedField.module.js +12 -0
- package/dist/localized/LocalizedField.module.js.map +1 -0
- package/dist/localized/index.d.ts +2 -0
- package/dist/localized/index.d.ts.map +1 -0
- package/dist/localized/index.js +1 -0
- package/dist/missing/MissingField.css +18 -0
- package/dist/missing/MissingField.d.ts +7 -0
- package/dist/missing/MissingField.d.ts.map +1 -0
- package/dist/missing/MissingField.js +68 -0
- package/dist/missing/MissingField.js.map +1 -0
- package/dist/missing/MissingField.module.js +14 -0
- package/dist/missing/MissingField.module.js.map +1 -0
- package/dist/number/NumberField.d.ts +23 -0
- package/dist/number/NumberField.d.ts.map +1 -0
- package/dist/number/NumberField.js +175 -0
- package/dist/number/NumberField.js.map +1 -0
- package/dist/number/index.d.ts +2 -0
- package/dist/number/index.d.ts.map +1 -0
- package/dist/number/index.js +1 -0
- package/dist/relation/RelationField.css +43 -0
- package/dist/relation/RelationField.d.ts +40 -0
- package/dist/relation/RelationField.d.ts.map +1 -0
- package/dist/relation/RelationField.js +293 -0
- package/dist/relation/RelationField.js.map +1 -0
- package/dist/relation/RelationField.module.js +20 -0
- package/dist/relation/RelationField.module.js.map +1 -0
- package/dist/relation/index.d.ts +3 -0
- package/dist/relation/index.d.ts.map +1 -0
- package/dist/relation/index.js +3 -0
- package/dist/repeater/RepeaterField.css +80 -0
- package/dist/repeater/RepeaterField.d.ts +29 -0
- package/dist/repeater/RepeaterField.d.ts.map +1 -0
- package/dist/repeater/RepeaterField.js +220 -0
- package/dist/repeater/RepeaterField.js.map +1 -0
- package/dist/repeater/RepeaterField.module.js +26 -0
- package/dist/repeater/RepeaterField.module.js.map +1 -0
- package/dist/repeater/index.d.ts +2 -0
- package/dist/repeater/index.d.ts.map +1 -0
- package/dist/repeater/index.js +1 -0
- package/dist/select/SelectField.css +5 -0
- package/dist/select/SelectField.d.ts +38 -0
- package/dist/select/SelectField.d.ts.map +1 -0
- package/dist/select/SelectField.js +434 -0
- package/dist/select/SelectField.js.map +1 -0
- package/dist/select/SelectField.module.js +8 -0
- package/dist/select/SelectField.module.js.map +1 -0
- package/dist/select/index.d.ts +2 -0
- package/dist/select/index.d.ts.map +1 -0
- package/dist/select/index.js +1 -0
- package/dist/shared/DefinitionField.d.ts +32 -0
- package/dist/shared/DefinitionField.d.ts.map +1 -0
- package/dist/shared/DefinitionField.js +153 -0
- package/dist/shared/DefinitionField.js.map +1 -0
- package/dist/shared/builtIn.d.ts +17 -0
- package/dist/shared/builtIn.d.ts.map +1 -0
- package/dist/shared/builtIn.js +52 -0
- package/dist/shared/builtIn.js.map +1 -0
- package/dist/shared/context.d.ts +55 -0
- package/dist/shared/context.d.ts.map +1 -0
- package/dist/shared/context.js +72 -0
- package/dist/shared/context.js.map +1 -0
- package/dist/shared/cx.d.ts +3 -0
- package/dist/shared/cx.d.ts.map +1 -0
- package/dist/shared/cx.js +9 -0
- package/dist/shared/cx.js.map +1 -0
- package/dist/shared/dates.d.ts +15 -0
- package/dist/shared/dates.d.ts.map +1 -0
- package/dist/shared/dates.js +49 -0
- package/dist/shared/dates.js.map +1 -0
- package/dist/shared/entry.d.ts +23 -0
- package/dist/shared/entry.d.ts.map +1 -0
- package/dist/shared/entry.js +45 -0
- package/dist/shared/entry.js.map +1 -0
- package/dist/shared/messages.d.ts +2 -0
- package/dist/shared/messages.d.ts.map +1 -0
- package/dist/shared/messages.js +1 -0
- package/dist/shared/relation.d.ts +37 -0
- package/dist/shared/relation.d.ts.map +1 -0
- package/dist/shared/relation.js +49 -0
- package/dist/shared/relation.js.map +1 -0
- package/dist/shared/types.d.ts +50 -0
- package/dist/shared/types.d.ts.map +1 -0
- package/dist/slug/SlugField.d.ts +24 -0
- package/dist/slug/SlugField.d.ts.map +1 -0
- package/dist/slug/SlugField.js +216 -0
- package/dist/slug/SlugField.js.map +1 -0
- package/dist/slug/index.d.ts +2 -0
- package/dist/slug/index.d.ts.map +1 -0
- package/dist/slug/index.js +1 -0
- package/dist/text/TextField.d.ts +24 -0
- package/dist/text/TextField.d.ts.map +1 -0
- package/dist/text/TextField.js +179 -0
- package/dist/text/TextField.js.map +1 -0
- package/dist/text/index.d.ts +2 -0
- package/dist/text/index.d.ts.map +1 -0
- package/dist/text/index.js +1 -0
- package/dist/textarea/TextAreaField.d.ts +14 -0
- package/dist/textarea/TextAreaField.d.ts.map +1 -0
- package/dist/textarea/TextAreaField.js +126 -0
- package/dist/textarea/TextAreaField.js.map +1 -0
- package/dist/textarea/index.d.ts +2 -0
- package/dist/textarea/index.d.ts.map +1 -0
- package/dist/textarea/index.js +1 -0
- package/dist/time/TimeField.d.ts +13 -0
- package/dist/time/TimeField.d.ts.map +1 -0
- package/dist/time/TimeField.js +49 -0
- package/dist/time/TimeField.js.map +1 -0
- package/dist/time/index.d.ts +2 -0
- package/dist/time/index.d.ts.map +1 -0
- package/dist/time/index.js +1 -0
- package/dist/url/UrlField.css +11 -0
- package/dist/url/UrlField.d.ts +16 -0
- package/dist/url/UrlField.d.ts.map +1 -0
- package/dist/url/UrlField.js +94 -0
- package/dist/url/UrlField.js.map +1 -0
- package/dist/url/UrlField.module.js +8 -0
- package/dist/url/UrlField.module.js.map +1 -0
- package/dist/url/index.d.ts +2 -0
- package/dist/url/index.d.ts.map +1 -0
- package/dist/url/index.js +1 -0
- package/package.json +108 -79
- package/assets/css/styles.css +0 -14
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { FieldEntryProps } from '../shared/types';
|
|
2
|
+
import { type TextFieldProps } from '../text/TextField';
|
|
3
|
+
/**
|
|
4
|
+
* Turns a text into a slug: lowercase ASCII letters and digits separated by dashes, without
|
|
5
|
+
* accents (`Été à Montréal` gives `ete-a-montreal`).
|
|
6
|
+
*/
|
|
7
|
+
export declare function slugify(text: string): string;
|
|
8
|
+
export interface SlugFieldProps extends Omit<TextFieldProps, 'type' | 'suffix'> {
|
|
9
|
+
/**
|
|
10
|
+
* The text the slug is made from (a title). While the slug is empty or still matches it, the
|
|
11
|
+
* slug follows it.
|
|
12
|
+
*/
|
|
13
|
+
source?: string | null;
|
|
14
|
+
/** Name of the source, for the button that generates the slug from it. */
|
|
15
|
+
sourceLabel?: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* A slug for URLs. Typed text is cleaned up on blur. With a `source`, the slug follows it until
|
|
19
|
+
* it is edited, and a button generates it again.
|
|
20
|
+
*/
|
|
21
|
+
export declare function SlugField({ value, onChange, onBlur, source, sourceLabel, disabled, readOnly, ...props }: SlugFieldProps): import("react").JSX.Element;
|
|
22
|
+
/** The `slug` type: `from` names the field it follows, and setting `prefix` shows a URL prefix. */
|
|
23
|
+
export declare function SlugFieldEntry(props: FieldEntryProps): import("react").JSX.Element;
|
|
24
|
+
//# sourceMappingURL=SlugField.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SlugField.d.ts","sourceRoot":"","sources":["../../src/slug/SlugField.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAa,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnE;;;GAGG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAO5C;AAED,MAAM,WAAW,cAAe,SAAQ,IAAI,CAAC,cAAc,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC3E;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,0EAA0E;IAC1E,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,EACtB,KAAK,EACL,QAAQ,EACR,MAAM,EACN,MAAM,EACN,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,GAAG,KAAK,EACX,EAAE,cAAc,+BAqDhB;AAcD,mGAAmG;AACnG,wBAAgB,cAAc,CAAC,KAAK,EAAE,eAAe,+BAgBpD"}
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { getFieldProps, getSetting, isString } from "../shared/entry.js";
|
|
2
|
+
import { messages } from "../shared/messages.js";
|
|
3
|
+
import { TextField } from "../text/TextField.js";
|
|
4
|
+
import { c } from "react/compiler-runtime";
|
|
5
|
+
import { IconButton, usePanneauIntl } from "@panneau/ui";
|
|
6
|
+
import { useEffect, useRef } from "react";
|
|
7
|
+
import { jsx } from "react/jsx-runtime";
|
|
8
|
+
import { WandSparkles } from "lucide-react";
|
|
9
|
+
//#region src/slug/SlugField.tsx
|
|
10
|
+
/**
|
|
11
|
+
* Turns a text into a slug: lowercase ASCII letters and digits separated by dashes, without
|
|
12
|
+
* accents (`Été à Montréal` gives `ete-a-montreal`).
|
|
13
|
+
*/
|
|
14
|
+
function slugify(text) {
|
|
15
|
+
return text.normalize("NFKD").replace(/[̀-ͯ]/g, "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* A slug for URLs. Typed text is cleaned up on blur. With a `source`, the slug follows it until
|
|
19
|
+
* it is edited, and a button generates it again.
|
|
20
|
+
*/
|
|
21
|
+
function SlugField(t0) {
|
|
22
|
+
const $ = c(37);
|
|
23
|
+
let disabled;
|
|
24
|
+
let onBlur;
|
|
25
|
+
let onChange;
|
|
26
|
+
let props;
|
|
27
|
+
let readOnly;
|
|
28
|
+
let source;
|
|
29
|
+
let sourceLabel;
|
|
30
|
+
let value;
|
|
31
|
+
if ($[0] !== t0) {
|
|
32
|
+
({value, onChange, onBlur, source, sourceLabel, disabled, readOnly, ...props} = t0);
|
|
33
|
+
$[0] = t0;
|
|
34
|
+
$[1] = disabled;
|
|
35
|
+
$[2] = onBlur;
|
|
36
|
+
$[3] = onChange;
|
|
37
|
+
$[4] = props;
|
|
38
|
+
$[5] = readOnly;
|
|
39
|
+
$[6] = source;
|
|
40
|
+
$[7] = sourceLabel;
|
|
41
|
+
$[8] = value;
|
|
42
|
+
} else {
|
|
43
|
+
disabled = $[1];
|
|
44
|
+
onBlur = $[2];
|
|
45
|
+
onChange = $[3];
|
|
46
|
+
props = $[4];
|
|
47
|
+
readOnly = $[5];
|
|
48
|
+
source = $[6];
|
|
49
|
+
sourceLabel = $[7];
|
|
50
|
+
value = $[8];
|
|
51
|
+
}
|
|
52
|
+
const intl = usePanneauIntl();
|
|
53
|
+
const previousSource = useRef(source);
|
|
54
|
+
const editable = disabled !== true && readOnly !== true;
|
|
55
|
+
let t1;
|
|
56
|
+
let t2;
|
|
57
|
+
if ($[9] !== editable || $[10] !== onChange || $[11] !== source || $[12] !== value) {
|
|
58
|
+
t1 = () => {
|
|
59
|
+
const previous = previousSource.current;
|
|
60
|
+
previousSource.current = source;
|
|
61
|
+
if (!editable || source === previous || source === void 0) return;
|
|
62
|
+
const current = value ?? "";
|
|
63
|
+
if (current === "" || current === slugify(previous ?? "")) {
|
|
64
|
+
const next = slugify(source ?? "");
|
|
65
|
+
if (next !== current) onChange?.(next === "" ? null : next);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
t2 = [
|
|
69
|
+
source,
|
|
70
|
+
value,
|
|
71
|
+
onChange,
|
|
72
|
+
editable
|
|
73
|
+
];
|
|
74
|
+
$[9] = editable;
|
|
75
|
+
$[10] = onChange;
|
|
76
|
+
$[11] = source;
|
|
77
|
+
$[12] = value;
|
|
78
|
+
$[13] = t1;
|
|
79
|
+
$[14] = t2;
|
|
80
|
+
} else {
|
|
81
|
+
t1 = $[13];
|
|
82
|
+
t2 = $[14];
|
|
83
|
+
}
|
|
84
|
+
useEffect(t1, t2);
|
|
85
|
+
const t3 = source ?? "";
|
|
86
|
+
let t4;
|
|
87
|
+
if ($[15] !== t3) {
|
|
88
|
+
t4 = slugify(t3);
|
|
89
|
+
$[15] = t3;
|
|
90
|
+
$[16] = t4;
|
|
91
|
+
} else t4 = $[16];
|
|
92
|
+
const generated = t4;
|
|
93
|
+
let t5;
|
|
94
|
+
if ($[17] !== onBlur || $[18] !== onChange || $[19] !== value) {
|
|
95
|
+
t5 = () => {
|
|
96
|
+
if (value !== null && value !== void 0) {
|
|
97
|
+
const next_0 = slugify(value);
|
|
98
|
+
if (next_0 !== value) onChange?.(next_0 === "" ? null : next_0);
|
|
99
|
+
}
|
|
100
|
+
onBlur?.();
|
|
101
|
+
};
|
|
102
|
+
$[17] = onBlur;
|
|
103
|
+
$[18] = onChange;
|
|
104
|
+
$[19] = value;
|
|
105
|
+
$[20] = t5;
|
|
106
|
+
} else t5 = $[20];
|
|
107
|
+
let t6;
|
|
108
|
+
if ($[21] !== editable || $[22] !== generated || $[23] !== intl || $[24] !== onChange || $[25] !== source || $[26] !== sourceLabel || $[27] !== value) {
|
|
109
|
+
t6 = source !== void 0 && editable ? /* @__PURE__ */ jsx(IconButton, {
|
|
110
|
+
icon: WandSparkles,
|
|
111
|
+
size: "sm",
|
|
112
|
+
label: intl.formatMessage(messages.generateSlug, { field: sourceLabel ?? "" }),
|
|
113
|
+
isDisabled: generated === "" || generated === value,
|
|
114
|
+
onPress: () => onChange?.(generated === "" ? null : generated)
|
|
115
|
+
}) : void 0;
|
|
116
|
+
$[21] = editable;
|
|
117
|
+
$[22] = generated;
|
|
118
|
+
$[23] = intl;
|
|
119
|
+
$[24] = onChange;
|
|
120
|
+
$[25] = source;
|
|
121
|
+
$[26] = sourceLabel;
|
|
122
|
+
$[27] = value;
|
|
123
|
+
$[28] = t6;
|
|
124
|
+
} else t6 = $[28];
|
|
125
|
+
let t7;
|
|
126
|
+
if ($[29] !== disabled || $[30] !== onChange || $[31] !== props || $[32] !== readOnly || $[33] !== t5 || $[34] !== t6 || $[35] !== value) {
|
|
127
|
+
t7 = /* @__PURE__ */ jsx(TextField, {
|
|
128
|
+
autoComplete: "off",
|
|
129
|
+
...props,
|
|
130
|
+
value,
|
|
131
|
+
onChange,
|
|
132
|
+
disabled,
|
|
133
|
+
readOnly,
|
|
134
|
+
onBlur: t5,
|
|
135
|
+
suffix: t6
|
|
136
|
+
});
|
|
137
|
+
$[29] = disabled;
|
|
138
|
+
$[30] = onChange;
|
|
139
|
+
$[31] = props;
|
|
140
|
+
$[32] = readOnly;
|
|
141
|
+
$[33] = t5;
|
|
142
|
+
$[34] = t6;
|
|
143
|
+
$[35] = value;
|
|
144
|
+
$[36] = t7;
|
|
145
|
+
} else t7 = $[36];
|
|
146
|
+
return t7;
|
|
147
|
+
}
|
|
148
|
+
function sourceText(value) {
|
|
149
|
+
if (typeof value === "string") return value;
|
|
150
|
+
if (value !== null && typeof value === "object") return Object.values(value).find(isString) ?? null;
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
153
|
+
/** The `slug` type: `from` names the field it follows, and setting `prefix` shows a URL prefix. */
|
|
154
|
+
function SlugFieldEntry(props) {
|
|
155
|
+
const $ = c(18);
|
|
156
|
+
const { field, parentValue } = props;
|
|
157
|
+
let t0;
|
|
158
|
+
if ($[0] !== field) {
|
|
159
|
+
t0 = getSetting(field, "prefix", isString);
|
|
160
|
+
$[0] = field;
|
|
161
|
+
$[1] = t0;
|
|
162
|
+
} else t0 = $[1];
|
|
163
|
+
const prefix = t0;
|
|
164
|
+
let t1;
|
|
165
|
+
if ($[2] !== field.from || $[3] !== parentValue) {
|
|
166
|
+
t1 = field.from !== void 0 && parentValue !== null && typeof parentValue === "object" ? sourceText(parentValue[field.from]) : void 0;
|
|
167
|
+
$[2] = field.from;
|
|
168
|
+
$[3] = parentValue;
|
|
169
|
+
$[4] = t1;
|
|
170
|
+
} else t1 = $[4];
|
|
171
|
+
const source = t1;
|
|
172
|
+
let t2;
|
|
173
|
+
if ($[5] !== props) {
|
|
174
|
+
t2 = getFieldProps(props);
|
|
175
|
+
$[5] = props;
|
|
176
|
+
$[6] = t2;
|
|
177
|
+
} else t2 = $[6];
|
|
178
|
+
const t3 = isString(props.value) ? props.value : null;
|
|
179
|
+
let t4;
|
|
180
|
+
if ($[7] !== field.from || $[8] !== source) {
|
|
181
|
+
t4 = source !== void 0 ? {
|
|
182
|
+
source,
|
|
183
|
+
sourceLabel: field.from ?? ""
|
|
184
|
+
} : {};
|
|
185
|
+
$[7] = field.from;
|
|
186
|
+
$[8] = source;
|
|
187
|
+
$[9] = t4;
|
|
188
|
+
} else t4 = $[9];
|
|
189
|
+
let t5;
|
|
190
|
+
if ($[10] !== prefix) {
|
|
191
|
+
t5 = prefix !== void 0 ? { prefix } : {};
|
|
192
|
+
$[10] = prefix;
|
|
193
|
+
$[11] = t5;
|
|
194
|
+
} else t5 = $[11];
|
|
195
|
+
let t6;
|
|
196
|
+
if ($[12] !== props.onChange || $[13] !== t2 || $[14] !== t3 || $[15] !== t4 || $[16] !== t5) {
|
|
197
|
+
t6 = /* @__PURE__ */ jsx(SlugField, {
|
|
198
|
+
...t2,
|
|
199
|
+
value: t3,
|
|
200
|
+
onChange: props.onChange,
|
|
201
|
+
...t4,
|
|
202
|
+
...t5
|
|
203
|
+
});
|
|
204
|
+
$[12] = props.onChange;
|
|
205
|
+
$[13] = t2;
|
|
206
|
+
$[14] = t3;
|
|
207
|
+
$[15] = t4;
|
|
208
|
+
$[16] = t5;
|
|
209
|
+
$[17] = t6;
|
|
210
|
+
} else t6 = $[17];
|
|
211
|
+
return t6;
|
|
212
|
+
}
|
|
213
|
+
//#endregion
|
|
214
|
+
export { SlugField, SlugFieldEntry, slugify };
|
|
215
|
+
|
|
216
|
+
//# sourceMappingURL=SlugField.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SlugField.js","names":["next","WandSparkles","value","onChange","disabled","readOnly","_c"],"sources":["../../src/slug/SlugField.tsx"],"sourcesContent":["import { WandSparkles } from 'lucide-react';\nimport { useEffect, useRef } from 'react';\n\nimport { IconButton, usePanneauIntl } from '@panneau/ui';\n\nimport { getFieldProps, getSetting, isString } from '../shared/entry';\nimport { messages } from '../shared/messages';\nimport type { FieldEntryProps } from '../shared/types';\nimport { TextField, type TextFieldProps } from '../text/TextField';\n\n/**\n * Turns a text into a slug: lowercase ASCII letters and digits separated by dashes, without\n * accents (`Été à Montréal` gives `ete-a-montreal`).\n */\nexport function slugify(text: string): string {\n return text\n .normalize('NFKD')\n .replace(/[̀-ͯ]/g, '')\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-+|-+$/g, '');\n}\n\nexport interface SlugFieldProps extends Omit<TextFieldProps, 'type' | 'suffix'> {\n /**\n * The text the slug is made from (a title). While the slug is empty or still matches it, the\n * slug follows it.\n */\n source?: string | null;\n /** Name of the source, for the button that generates the slug from it. */\n sourceLabel?: string;\n}\n\n/**\n * A slug for URLs. Typed text is cleaned up on blur. With a `source`, the slug follows it until\n * it is edited, and a button generates it again.\n */\nexport function SlugField({\n value,\n onChange,\n onBlur,\n source,\n sourceLabel,\n disabled,\n readOnly,\n ...props\n}: SlugFieldProps) {\n const intl = usePanneauIntl();\n const previousSource = useRef(source);\n const editable = disabled !== true && readOnly !== true;\n\n useEffect(() => {\n const previous = previousSource.current;\n previousSource.current = source;\n if (!editable || source === previous || source === undefined) {\n return;\n }\n const current = value ?? '';\n if (current === '' || current === slugify(previous ?? '')) {\n const next = slugify(source ?? '');\n if (next !== current) {\n onChange?.(next === '' ? null : next);\n }\n }\n }, [source, value, onChange, editable]);\n\n const generated = slugify(source ?? '');\n return (\n <TextField\n autoComplete=\"off\"\n {...props}\n value={value}\n onChange={onChange}\n disabled={disabled}\n readOnly={readOnly}\n onBlur={() => {\n if (value !== null && value !== undefined) {\n const next = slugify(value);\n if (next !== value) {\n onChange?.(next === '' ? null : next);\n }\n }\n onBlur?.();\n }}\n suffix={\n source !== undefined && editable ? (\n <IconButton\n icon={WandSparkles}\n size=\"sm\"\n label={intl.formatMessage(messages.generateSlug, {\n field: sourceLabel ?? '',\n })}\n isDisabled={generated === '' || generated === value}\n onPress={() => onChange?.(generated === '' ? null : generated)}\n />\n ) : undefined\n }\n />\n );\n}\n\nfunction sourceText(value: unknown): string | null {\n if (typeof value === 'string') {\n return value;\n }\n // A localized source: its first locale.\n if (value !== null && typeof value === 'object') {\n const first = Object.values(value as Record<string, unknown>).find(isString);\n return first ?? null;\n }\n return null;\n}\n\n/** The `slug` type: `from` names the field it follows, and setting `prefix` shows a URL prefix. */\nexport function SlugFieldEntry(props: FieldEntryProps) {\n const { field, parentValue } = props;\n const prefix = getSetting(field, 'prefix', isString);\n const source =\n field.from !== undefined && parentValue !== null && typeof parentValue === 'object'\n ? sourceText((parentValue as Record<string, unknown>)[field.from])\n : undefined;\n return (\n <SlugField\n {...getFieldProps(props)}\n value={isString(props.value) ? props.value : null}\n onChange={props.onChange}\n {...(source !== undefined ? { source, sourceLabel: field.from ?? '' } : {})}\n {...(prefix !== undefined ? { prefix } : {})}\n />\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAcA,SAAgB,QAAQ,MAAsB;CAC1C,OAAO,KACF,UAAU,MAAM,CAAC,CACjB,QAAQ,UAAU,EAAE,CAAC,CACrB,YAAY,CAAC,CACb,QAAQ,eAAe,GAAG,CAAC,CAC3B,QAAQ,YAAY,EAAE;AAC/B;;;;;AAgBA,SAAO,UAAA,IAAA;CAAA,MAAA,IAAAM,EAAA,EAAA;CAAA,IAAA;CAAA,IAAA;CAAA,IAAA;CAAA,IAAA;CAAA,IAAA;CAAA,IAAA;CAAA,IAA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MAAK,QAAL;EAAsB,IAApE,CAAoE;EAAC,EAAA,KAAA,MAAA;EAAA,EAAA,KAAA;EAAA,EAAA,KAAA;CAAA,OAAA,KAAA,EAAA;CAAA,IAAA;CAAA,IAAA,EAAA,QAAA,QAAA;EACrE,KAAA,WAAW,KAAA,IAAX,EAAA,OAAqC,IAArC,CAAqC;EAAC,EAAA,MAAA;EAAA,EAAA,MAAA;CAAA,OAAA,KAAA,EAAA;CAAA,IAAA;CAAA,IAAA,EAAA,QAAA,MAAA,YAAA,EAAA,QAAA,MAAA,EAAA,QAAA,MAAA,EAAA,QAAA,MAAA,EAAA,QAAA,IAAA;EAL/C,KAAA,oBAAC,WAAD;GAAU,GACF;GACG,OAAA;GACG,UAAA,MAAK;GAAS,GACnB;GAAqE,GACrE;EAAsC,CAAA;EAC7C,EAAA,MAAA,MAAA;EAAA,EAAA,MAAA;EAAA,EAAA,MAAA;EAAA,EAAA,MAAA;EAAA,EAAA,MAAA;EAAA,EAAA,MAAA;CAAA,OAAA,KAAA,EAAA;CAAA,OANF;AAME"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/slug/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,KAAK,cAAc,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SlugField, SlugFieldEntry, slugify } from "./SlugField.js";
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { FieldEntryProps, FieldProps } from '../shared/types';
|
|
3
|
+
export interface TextFieldProps extends FieldProps<string> {
|
|
4
|
+
placeholder?: string;
|
|
5
|
+
/** Shows a count of characters against this maximum. It doesn't stop typing. */
|
|
6
|
+
maxLength?: number;
|
|
7
|
+
/** Content before the text, inside the control. */
|
|
8
|
+
prefix?: ReactNode;
|
|
9
|
+
/** Content after the text, inside the control. */
|
|
10
|
+
suffix?: ReactNode;
|
|
11
|
+
/** Type of the input. Defaults to `text`. */
|
|
12
|
+
type?: 'text' | 'email' | 'url' | 'tel' | 'password' | 'search';
|
|
13
|
+
inputMode?: 'text' | 'email' | 'url' | 'tel' | 'search' | 'numeric' | 'decimal' | 'none';
|
|
14
|
+
autoComplete?: string;
|
|
15
|
+
controlClassName?: string;
|
|
16
|
+
inputClassName?: string;
|
|
17
|
+
}
|
|
18
|
+
/** The description of a text field, with its character count. */
|
|
19
|
+
export declare function useCountedDescription(description: ReactNode, value: string | null | undefined, maxLength: number | undefined): ReactNode;
|
|
20
|
+
/** A single-line text. An empty text is `null`. */
|
|
21
|
+
export declare function TextField({ value, onChange, description, maxLength, disabled, readOnly, required, ...props }: TextFieldProps): import("react").JSX.Element;
|
|
22
|
+
/** The `text` type: settings `prefix` and `suffix`, and a character count from the `max` rule. */
|
|
23
|
+
export declare function TextFieldEntry(props: FieldEntryProps): import("react").JSX.Element;
|
|
24
|
+
//# sourceMappingURL=TextField.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextField.d.ts","sourceRoot":"","sources":["../../src/text/TextField.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAMvC,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAEnE,MAAM,WAAW,cAAe,SAAQ,UAAU,CAAC,MAAM,CAAC;IACtD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gFAAgF;IAChF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,mDAAmD;IACnD,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,kDAAkD;IAClD,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,6CAA6C;IAC7C,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,KAAK,GAAG,UAAU,GAAG,QAAQ,CAAC;IAChE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,KAAK,GAAG,QAAQ,GAAG,SAAS,GAAG,SAAS,GAAG,MAAM,CAAC;IACzF,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,iEAAiE;AACjE,wBAAgB,qBAAqB,CACjC,WAAW,EAAE,SAAS,EACtB,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAChC,SAAS,EAAE,MAAM,GAAG,SAAS,GAC9B,SAAS,CAiBX;AAED,mDAAmD;AACnD,wBAAgB,SAAS,CAAC,EACtB,KAAK,EACL,QAAQ,EACR,WAAW,EACX,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,GAAG,KAAK,EACX,EAAE,cAAc,+BAahB;AAED,kGAAkG;AAClG,wBAAgB,cAAc,CAAC,KAAK,EAAE,eAAe,+BAepD"}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { getFieldProps, getRuleNumber, getSetting, isString } from "../shared/entry.js";
|
|
2
|
+
import { messages } from "../shared/messages.js";
|
|
3
|
+
import { c } from "react/compiler-runtime";
|
|
4
|
+
import { TextInput, usePanneauIntl } from "@panneau/ui";
|
|
5
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
//#region src/text/TextField.tsx
|
|
7
|
+
/** The description of a text field, with its character count. */
|
|
8
|
+
function useCountedDescription(description, value, maxLength) {
|
|
9
|
+
const $ = c(9);
|
|
10
|
+
const intl = usePanneauIntl();
|
|
11
|
+
if (maxLength === void 0) return description;
|
|
12
|
+
let t0;
|
|
13
|
+
if ($[0] !== intl || $[1] !== maxLength || $[2] !== value) {
|
|
14
|
+
t0 = intl.formatMessage(messages.characterCount, {
|
|
15
|
+
count: (value ?? "").length,
|
|
16
|
+
max: maxLength
|
|
17
|
+
});
|
|
18
|
+
$[0] = intl;
|
|
19
|
+
$[1] = maxLength;
|
|
20
|
+
$[2] = value;
|
|
21
|
+
$[3] = t0;
|
|
22
|
+
} else t0 = $[3];
|
|
23
|
+
const count = t0;
|
|
24
|
+
if (description === void 0 || description === null) return count;
|
|
25
|
+
let t1;
|
|
26
|
+
if ($[4] !== count) {
|
|
27
|
+
t1 = /* @__PURE__ */ jsx("span", { children: count });
|
|
28
|
+
$[4] = count;
|
|
29
|
+
$[5] = t1;
|
|
30
|
+
} else t1 = $[5];
|
|
31
|
+
let t2;
|
|
32
|
+
if ($[6] !== description || $[7] !== t1) {
|
|
33
|
+
t2 = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
34
|
+
description,
|
|
35
|
+
" ",
|
|
36
|
+
t1
|
|
37
|
+
] });
|
|
38
|
+
$[6] = description;
|
|
39
|
+
$[7] = t1;
|
|
40
|
+
$[8] = t2;
|
|
41
|
+
} else t2 = $[8];
|
|
42
|
+
return t2;
|
|
43
|
+
}
|
|
44
|
+
/** A single-line text. An empty text is `null`. */
|
|
45
|
+
function TextField(t0) {
|
|
46
|
+
const $ = c(19);
|
|
47
|
+
let description;
|
|
48
|
+
let disabled;
|
|
49
|
+
let maxLength;
|
|
50
|
+
let onChange;
|
|
51
|
+
let props;
|
|
52
|
+
let readOnly;
|
|
53
|
+
let required;
|
|
54
|
+
let value;
|
|
55
|
+
if ($[0] !== t0) {
|
|
56
|
+
({value, onChange, description, maxLength, disabled, readOnly, required, ...props} = t0);
|
|
57
|
+
$[0] = t0;
|
|
58
|
+
$[1] = description;
|
|
59
|
+
$[2] = disabled;
|
|
60
|
+
$[3] = maxLength;
|
|
61
|
+
$[4] = onChange;
|
|
62
|
+
$[5] = props;
|
|
63
|
+
$[6] = readOnly;
|
|
64
|
+
$[7] = required;
|
|
65
|
+
$[8] = value;
|
|
66
|
+
} else {
|
|
67
|
+
description = $[1];
|
|
68
|
+
disabled = $[2];
|
|
69
|
+
maxLength = $[3];
|
|
70
|
+
onChange = $[4];
|
|
71
|
+
props = $[5];
|
|
72
|
+
readOnly = $[6];
|
|
73
|
+
required = $[7];
|
|
74
|
+
value = $[8];
|
|
75
|
+
}
|
|
76
|
+
const shownDescription = useCountedDescription(description, value, maxLength);
|
|
77
|
+
const t1 = value ?? "";
|
|
78
|
+
let t2;
|
|
79
|
+
if ($[9] !== onChange) {
|
|
80
|
+
t2 = (next) => onChange?.(next === "" ? null : next);
|
|
81
|
+
$[9] = onChange;
|
|
82
|
+
$[10] = t2;
|
|
83
|
+
} else t2 = $[10];
|
|
84
|
+
let t3;
|
|
85
|
+
if ($[11] !== disabled || $[12] !== props || $[13] !== readOnly || $[14] !== required || $[15] !== shownDescription || $[16] !== t1 || $[17] !== t2) {
|
|
86
|
+
t3 = /* @__PURE__ */ jsx(TextInput, {
|
|
87
|
+
...props,
|
|
88
|
+
value: t1,
|
|
89
|
+
onChange: t2,
|
|
90
|
+
description: shownDescription,
|
|
91
|
+
isDisabled: disabled,
|
|
92
|
+
isReadOnly: readOnly,
|
|
93
|
+
isRequired: required
|
|
94
|
+
});
|
|
95
|
+
$[11] = disabled;
|
|
96
|
+
$[12] = props;
|
|
97
|
+
$[13] = readOnly;
|
|
98
|
+
$[14] = required;
|
|
99
|
+
$[15] = shownDescription;
|
|
100
|
+
$[16] = t1;
|
|
101
|
+
$[17] = t2;
|
|
102
|
+
$[18] = t3;
|
|
103
|
+
} else t3 = $[18];
|
|
104
|
+
return t3;
|
|
105
|
+
}
|
|
106
|
+
/** The `text` type: settings `prefix` and `suffix`, and a character count from the `max` rule. */
|
|
107
|
+
function TextFieldEntry(props) {
|
|
108
|
+
const $ = c(21);
|
|
109
|
+
const { field } = props;
|
|
110
|
+
let t0;
|
|
111
|
+
if ($[0] !== field) {
|
|
112
|
+
t0 = getSetting(field, "prefix", isString);
|
|
113
|
+
$[0] = field;
|
|
114
|
+
$[1] = t0;
|
|
115
|
+
} else t0 = $[1];
|
|
116
|
+
const prefix = t0;
|
|
117
|
+
let t1;
|
|
118
|
+
if ($[2] !== field) {
|
|
119
|
+
t1 = getSetting(field, "suffix", isString);
|
|
120
|
+
$[2] = field;
|
|
121
|
+
$[3] = t1;
|
|
122
|
+
} else t1 = $[3];
|
|
123
|
+
const suffix = t1;
|
|
124
|
+
let t2;
|
|
125
|
+
if ($[4] !== field) {
|
|
126
|
+
t2 = getRuleNumber(field, "max");
|
|
127
|
+
$[4] = field;
|
|
128
|
+
$[5] = t2;
|
|
129
|
+
} else t2 = $[5];
|
|
130
|
+
const max = t2;
|
|
131
|
+
let t3;
|
|
132
|
+
if ($[6] !== props) {
|
|
133
|
+
t3 = getFieldProps(props);
|
|
134
|
+
$[6] = props;
|
|
135
|
+
$[7] = t3;
|
|
136
|
+
} else t3 = $[7];
|
|
137
|
+
const t4 = isString(props.value) ? props.value : null;
|
|
138
|
+
let t5;
|
|
139
|
+
if ($[8] !== max) {
|
|
140
|
+
t5 = max !== void 0 ? { maxLength: max } : {};
|
|
141
|
+
$[8] = max;
|
|
142
|
+
$[9] = t5;
|
|
143
|
+
} else t5 = $[9];
|
|
144
|
+
let t6;
|
|
145
|
+
if ($[10] !== prefix) {
|
|
146
|
+
t6 = prefix !== void 0 ? { prefix } : {};
|
|
147
|
+
$[10] = prefix;
|
|
148
|
+
$[11] = t6;
|
|
149
|
+
} else t6 = $[11];
|
|
150
|
+
let t7;
|
|
151
|
+
if ($[12] !== suffix) {
|
|
152
|
+
t7 = suffix !== void 0 ? { suffix } : {};
|
|
153
|
+
$[12] = suffix;
|
|
154
|
+
$[13] = t7;
|
|
155
|
+
} else t7 = $[13];
|
|
156
|
+
let t8;
|
|
157
|
+
if ($[14] !== props.onChange || $[15] !== t3 || $[16] !== t4 || $[17] !== t5 || $[18] !== t6 || $[19] !== t7) {
|
|
158
|
+
t8 = /* @__PURE__ */ jsx(TextField, {
|
|
159
|
+
...t3,
|
|
160
|
+
value: t4,
|
|
161
|
+
onChange: props.onChange,
|
|
162
|
+
...t5,
|
|
163
|
+
...t6,
|
|
164
|
+
...t7
|
|
165
|
+
});
|
|
166
|
+
$[14] = props.onChange;
|
|
167
|
+
$[15] = t3;
|
|
168
|
+
$[16] = t4;
|
|
169
|
+
$[17] = t5;
|
|
170
|
+
$[18] = t6;
|
|
171
|
+
$[19] = t7;
|
|
172
|
+
$[20] = t8;
|
|
173
|
+
} else t8 = $[20];
|
|
174
|
+
return t8;
|
|
175
|
+
}
|
|
176
|
+
//#endregion
|
|
177
|
+
export { TextField, TextFieldEntry, useCountedDescription };
|
|
178
|
+
|
|
179
|
+
//# sourceMappingURL=TextField.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextField.js","names":["count","description","shownDescription","disabled","readOnly","required","_c","_Fragment"],"sources":["../../src/text/TextField.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\n\nimport { TextInput, usePanneauIntl } from '@panneau/ui';\n\nimport { getFieldProps, getRuleNumber, getSetting, isString } from '../shared/entry';\nimport { messages } from '../shared/messages';\nimport type { FieldEntryProps, FieldProps } from '../shared/types';\n\nexport interface TextFieldProps extends FieldProps<string> {\n placeholder?: string;\n /** Shows a count of characters against this maximum. It doesn't stop typing. */\n maxLength?: number;\n /** Content before the text, inside the control. */\n prefix?: ReactNode;\n /** Content after the text, inside the control. */\n suffix?: ReactNode;\n /** Type of the input. Defaults to `text`. */\n type?: 'text' | 'email' | 'url' | 'tel' | 'password' | 'search';\n inputMode?: 'text' | 'email' | 'url' | 'tel' | 'search' | 'numeric' | 'decimal' | 'none';\n autoComplete?: string;\n controlClassName?: string;\n inputClassName?: string;\n}\n\n/** The description of a text field, with its character count. */\nexport function useCountedDescription(\n description: ReactNode,\n value: string | null | undefined,\n maxLength: number | undefined,\n): ReactNode {\n const intl = usePanneauIntl();\n if (maxLength === undefined) {\n return description;\n }\n const count = intl.formatMessage(messages.characterCount, {\n count: (value ?? '').length,\n max: maxLength,\n });\n if (description === undefined || description === null) {\n return count;\n }\n return (\n <>\n {description} <span>{count}</span>\n </>\n );\n}\n\n/** A single-line text. An empty text is `null`. */\nexport function TextField({\n value,\n onChange,\n description,\n maxLength,\n disabled,\n readOnly,\n required,\n ...props\n}: TextFieldProps) {\n const shownDescription = useCountedDescription(description, value, maxLength);\n return (\n <TextInput\n {...props}\n value={value ?? ''}\n onChange={(next) => onChange?.(next === '' ? null : next)}\n description={shownDescription}\n isDisabled={disabled}\n isReadOnly={readOnly}\n isRequired={required}\n />\n );\n}\n\n/** The `text` type: settings `prefix` and `suffix`, and a character count from the `max` rule. */\nexport function TextFieldEntry(props: FieldEntryProps) {\n const { field } = props;\n const prefix = getSetting(field, 'prefix', isString);\n const suffix = getSetting(field, 'suffix', isString);\n const max = getRuleNumber(field, 'max');\n return (\n <TextField\n {...getFieldProps(props)}\n value={isString(props.value) ? props.value : null}\n onChange={props.onChange}\n {...(max !== undefined ? { maxLength: max } : {})}\n {...(prefix !== undefined ? { prefix } : {})}\n {...(suffix !== undefined ? { suffix } : {})}\n />\n );\n}\n"],"mappings":";;;;;;;AAyBA,SAAO,sBAAA,aAAA,OAAA,WAAA;CAAA,MAAA,IAAAM,EAAA,CAAA;CAKH,MAAA,OAAa,eAAe;CAC5B,IAAI,cAAc,KAAA,GAAS,OAChB;CACV,IAAA;CAAA,IAAA,EAAA,OAAA,QAAA,EAAA,OAAA,aAAA,EAAA,OAAA,OAAA;EACa,KAAA,KAAI,cAAe,SAAQ,gBAAiB;GAAA,QAC9C,SAAA,GAAA,CAAW;GAAQ,KACtB;EACT,CAAC;EAAC,EAAA,KAAA;EAAA,EAAA,KAAA;EAAA,EAAA,KAAA;EAAA,EAAA,KAAA;CAAA,OAAA,KAAA,EAAA;CAHF,MAAA,QAAc;CAId,IAAI,gBAAgB,KAAA,KAAa,gBAAgB,MAAI,OAC1C;CACV,IAAA;CAAA,IAAA,EAAA,OAAA,OAAA;EAGqB,KAAA,oBAAA,QAAA,EAAA,UAAO,MAAa,CAAA;EAAA,EAAA,KAAA;EAAA,EAAA,KAAA;CAAA,O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AA,WAAW,KAAA,IAAX,EAAA,OAAqC,IAArC,CAAqC;EAAC,EAAA,MAAA;EAAA,EAAA,MAAA;CAAA,OAAA,KAAA,EAAA;CAAA,IAAA;CAAA,IAAA,EAAA,QAAA,QAAA;EACtC,KAAA,WAAW,KAAA,IAAX,EAAA,OAAqC,IAArC,CAAqC;EAAC,EAAA,MAAA;EAAA,EAAA,MAAA;CAAA,OAAA,KAAA,EAAA;CAAA,IAAA;CAAA,IAAA,EAAA,QAAA,MAAA,YAAA,EAAA,QAAA,MAAA,EAAA,QAAA,MAAA,EAAA,QAAA,MAAA,EAAA,QAAA,MAAA,EAAA,QAAA,IAAA;EAN/C,KAAA,oBAAC,WAAD;GAAU,GACF;GACG,OAAA;GACG,UAAA,MAAK;GAAS,GACnB;GAA2C,GAC3C;GAAsC,GACtC;EAAsC,CAAA;EAC7C,EAAA,MAAA,MAAA;EAAA,EAAA,MAAA;EAAA,EAAA,MAAA;EAAA,EAAA,MAAA;EAAA,EAAA,MAAA;EAAA,EAAA,MAAA;EAAA,EAAA,MAAA;CAAA,OAAA,KAAA,EAAA;CAAA,OAPF;AAOE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/text/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { TextField, TextFieldEntry } from "./TextField.js";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { FieldEntryProps, FieldProps } from '../shared/types';
|
|
2
|
+
export interface TextAreaFieldProps extends FieldProps<string> {
|
|
3
|
+
placeholder?: string;
|
|
4
|
+
/** Shows a count of characters against this maximum. It doesn't stop typing. */
|
|
5
|
+
maxLength?: number;
|
|
6
|
+
/** Visible lines. Defaults to 4. */
|
|
7
|
+
rows?: number;
|
|
8
|
+
textAreaClassName?: string;
|
|
9
|
+
}
|
|
10
|
+
/** A text of several lines. An empty text is `null`. */
|
|
11
|
+
export declare function TextAreaField({ value, onChange, description, maxLength, disabled, readOnly, required, ...props }: TextAreaFieldProps): import("react").JSX.Element;
|
|
12
|
+
/** The `textarea` type: setting `rows`, and a character count from the `max` rule. */
|
|
13
|
+
export declare function TextAreaFieldEntry(props: FieldEntryProps): import("react").JSX.Element;
|
|
14
|
+
//# sourceMappingURL=TextAreaField.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextAreaField.d.ts","sourceRoot":"","sources":["../../src/textarea/TextAreaField.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAGnE,MAAM,WAAW,kBAAmB,SAAQ,UAAU,CAAC,MAAM,CAAC;IAC1D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gFAAgF;IAChF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oCAAoC;IACpC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,wDAAwD;AACxD,wBAAgB,aAAa,CAAC,EAC1B,KAAK,EACL,QAAQ,EACR,WAAW,EACX,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,GAAG,KAAK,EACX,EAAE,kBAAkB,+BAapB;AAED,sFAAsF;AACtF,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,eAAe,+BAYxD"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { getFieldProps, getRuleNumber, getSetting, isNumber, isString } from "../shared/entry.js";
|
|
2
|
+
import { useCountedDescription } from "../text/TextField.js";
|
|
3
|
+
import { c } from "react/compiler-runtime";
|
|
4
|
+
import { TextArea } from "@panneau/ui";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
//#region src/textarea/TextAreaField.tsx
|
|
7
|
+
/** A text of several lines. An empty text is `null`. */
|
|
8
|
+
function TextAreaField(t0) {
|
|
9
|
+
const $ = c(19);
|
|
10
|
+
let description;
|
|
11
|
+
let disabled;
|
|
12
|
+
let maxLength;
|
|
13
|
+
let onChange;
|
|
14
|
+
let props;
|
|
15
|
+
let readOnly;
|
|
16
|
+
let required;
|
|
17
|
+
let value;
|
|
18
|
+
if ($[0] !== t0) {
|
|
19
|
+
({value, onChange, description, maxLength, disabled, readOnly, required, ...props} = t0);
|
|
20
|
+
$[0] = t0;
|
|
21
|
+
$[1] = description;
|
|
22
|
+
$[2] = disabled;
|
|
23
|
+
$[3] = maxLength;
|
|
24
|
+
$[4] = onChange;
|
|
25
|
+
$[5] = props;
|
|
26
|
+
$[6] = readOnly;
|
|
27
|
+
$[7] = required;
|
|
28
|
+
$[8] = value;
|
|
29
|
+
} else {
|
|
30
|
+
description = $[1];
|
|
31
|
+
disabled = $[2];
|
|
32
|
+
maxLength = $[3];
|
|
33
|
+
onChange = $[4];
|
|
34
|
+
props = $[5];
|
|
35
|
+
readOnly = $[6];
|
|
36
|
+
required = $[7];
|
|
37
|
+
value = $[8];
|
|
38
|
+
}
|
|
39
|
+
const shownDescription = useCountedDescription(description, value, maxLength);
|
|
40
|
+
const t1 = value ?? "";
|
|
41
|
+
let t2;
|
|
42
|
+
if ($[9] !== onChange) {
|
|
43
|
+
t2 = (next) => onChange?.(next === "" ? null : next);
|
|
44
|
+
$[9] = onChange;
|
|
45
|
+
$[10] = t2;
|
|
46
|
+
} else t2 = $[10];
|
|
47
|
+
let t3;
|
|
48
|
+
if ($[11] !== disabled || $[12] !== props || $[13] !== readOnly || $[14] !== required || $[15] !== shownDescription || $[16] !== t1 || $[17] !== t2) {
|
|
49
|
+
t3 = /* @__PURE__ */ jsx(TextArea, {
|
|
50
|
+
...props,
|
|
51
|
+
value: t1,
|
|
52
|
+
onChange: t2,
|
|
53
|
+
description: shownDescription,
|
|
54
|
+
isDisabled: disabled,
|
|
55
|
+
isReadOnly: readOnly,
|
|
56
|
+
isRequired: required
|
|
57
|
+
});
|
|
58
|
+
$[11] = disabled;
|
|
59
|
+
$[12] = props;
|
|
60
|
+
$[13] = readOnly;
|
|
61
|
+
$[14] = required;
|
|
62
|
+
$[15] = shownDescription;
|
|
63
|
+
$[16] = t1;
|
|
64
|
+
$[17] = t2;
|
|
65
|
+
$[18] = t3;
|
|
66
|
+
} else t3 = $[18];
|
|
67
|
+
return t3;
|
|
68
|
+
}
|
|
69
|
+
/** The `textarea` type: setting `rows`, and a character count from the `max` rule. */
|
|
70
|
+
function TextAreaFieldEntry(props) {
|
|
71
|
+
const $ = c(16);
|
|
72
|
+
let t0;
|
|
73
|
+
if ($[0] !== props.field) {
|
|
74
|
+
t0 = getRuleNumber(props.field, "max");
|
|
75
|
+
$[0] = props.field;
|
|
76
|
+
$[1] = t0;
|
|
77
|
+
} else t0 = $[1];
|
|
78
|
+
const max = t0;
|
|
79
|
+
let t1;
|
|
80
|
+
if ($[2] !== props.field) {
|
|
81
|
+
t1 = getSetting(props.field, "rows", isNumber);
|
|
82
|
+
$[2] = props.field;
|
|
83
|
+
$[3] = t1;
|
|
84
|
+
} else t1 = $[3];
|
|
85
|
+
const rows = t1;
|
|
86
|
+
let t2;
|
|
87
|
+
if ($[4] !== props) {
|
|
88
|
+
t2 = getFieldProps(props);
|
|
89
|
+
$[4] = props;
|
|
90
|
+
$[5] = t2;
|
|
91
|
+
} else t2 = $[5];
|
|
92
|
+
const t3 = isString(props.value) ? props.value : null;
|
|
93
|
+
let t4;
|
|
94
|
+
if ($[6] !== max) {
|
|
95
|
+
t4 = max !== void 0 ? { maxLength: max } : {};
|
|
96
|
+
$[6] = max;
|
|
97
|
+
$[7] = t4;
|
|
98
|
+
} else t4 = $[7];
|
|
99
|
+
let t5;
|
|
100
|
+
if ($[8] !== rows) {
|
|
101
|
+
t5 = rows !== void 0 ? { rows } : {};
|
|
102
|
+
$[8] = rows;
|
|
103
|
+
$[9] = t5;
|
|
104
|
+
} else t5 = $[9];
|
|
105
|
+
let t6;
|
|
106
|
+
if ($[10] !== props.onChange || $[11] !== t2 || $[12] !== t3 || $[13] !== t4 || $[14] !== t5) {
|
|
107
|
+
t6 = /* @__PURE__ */ jsx(TextAreaField, {
|
|
108
|
+
...t2,
|
|
109
|
+
value: t3,
|
|
110
|
+
onChange: props.onChange,
|
|
111
|
+
...t4,
|
|
112
|
+
...t5
|
|
113
|
+
});
|
|
114
|
+
$[10] = props.onChange;
|
|
115
|
+
$[11] = t2;
|
|
116
|
+
$[12] = t3;
|
|
117
|
+
$[13] = t4;
|
|
118
|
+
$[14] = t5;
|
|
119
|
+
$[15] = t6;
|
|
120
|
+
} else t6 = $[15];
|
|
121
|
+
return t6;
|
|
122
|
+
}
|
|
123
|
+
//#endregion
|
|
124
|
+
export { TextAreaField, TextAreaFieldEntry };
|
|
125
|
+
|
|
126
|
+
//# sourceMappingURL=TextAreaField.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextAreaField.js","names":["shownDescription","disabled","readOnly","required","_c"],"sources":["../../src/textarea/TextAreaField.tsx"],"sourcesContent":["import { TextArea } from '@panneau/ui';\n\nimport { getFieldProps, getRuleNumber, getSetting, isNumber, isString } from '../shared/entry';\nimport type { FieldEntryProps, FieldProps } from '../shared/types';\nimport { useCountedDescription } from '../text/TextField';\n\nexport interface TextAreaFieldProps extends FieldProps<string> {\n placeholder?: string;\n /** Shows a count of characters against this maximum. It doesn't stop typing. */\n maxLength?: number;\n /** Visible lines. Defaults to 4. */\n rows?: number;\n textAreaClassName?: string;\n}\n\n/** A text of several lines. An empty text is `null`. */\nexport function TextAreaField({\n value,\n onChange,\n description,\n maxLength,\n disabled,\n readOnly,\n required,\n ...props\n}: TextAreaFieldProps) {\n const shownDescription = useCountedDescription(description, value, maxLength);\n return (\n <TextArea\n {...props}\n value={value ?? ''}\n onChange={(next) => onChange?.(next === '' ? null : next)}\n description={shownDescription}\n isDisabled={disabled}\n isReadOnly={readOnly}\n isRequired={required}\n />\n );\n}\n\n/** The `textarea` type: setting `rows`, and a character count from the `max` rule. */\nexport function TextAreaFieldEntry(props: FieldEntryProps) {\n const max = getRuleNumber(props.field, 'max');\n const rows = getSetting(props.field, 'rows', isNumber);\n return (\n <TextAreaField\n {...getFieldProps(props)}\n value={isString(props.value) ? props.value : null}\n onChange={props.onChange}\n {...(max !== undefined ? { maxLength: max } : {})}\n {...(rows !== undefined ? { rows } : {})}\n />\n );\n}\n"],"mappings":";;;;;;;AAgBA,SAAO,cAAA,IAAA;CAAA,MAAA,IAAAI,EAAA,EAAA;CAAA,IAAA;CAAA,IAAA;CAAA,IAAA;CAAA,IAAA;CAAA,IAAA;CAAA,IAAA;CAAA,IAAA;CAAA,IAAA;CAAA,IAAA,EAAA,OAAA,IAAA;EAAuB,CAAA,CAAA,OAAA,UAAA,aAAA,WAAA,UAAA,UAAA,UAAA,GAAA,SAAA;EAST,EAAA,KAAA;EAAA,EAAA,KAAA;EAAA,EAAA,KAAA;EAAA,EAAA,KAAA;EAAA,EAAA,KAAA;EAAA,EAAA,KAAA;EAAA,EAAA,KAAA;EAAA,EAAA,KAAA;EAAA,EAAA,KAAA;CAAA,OAAA;EAAA,cAAA,EAAA;EAAA,WAAA,EAAA;EAAA,YAAA,EAAA;EAAA,WAAA,EAAA;EAAA,QAAA,EAAA;EAAA,WAAA,EAAA;EAAA,WAAA,EAAA;EAAA,QAAA,EAAA;CAAA;CACjB,MAAA,mBAAyB,sBAAsB,aAAa,OAAO,SAAS;CAI7D,MAAA,KAAA,SAAA;CAAW,IAAA;CAAA,IAAA,EAAA,OAAA,UAAA;EACR,MAAA,SAAU,WAAW,SAAS,KAAT,OAAA,IAAyB;EAAC,EAAA,KAAA;EAAA,EAAA,MAAA;CAAA,OAAA,KAAA,EAAA;CAAA,IAAA;CAAA,IAAA,EAAA,QAAA,YAAA,EAAA,QAAA,SAAA,EAAA,QAAA,YAAA,EAAA,QAAA,YAAA,EAAA,QAAA,oBAAA,EAAA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