payload-intl 0.2.4 → 1.0.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 +8 -12
- package/dist/components/MessageController.d.ts +2 -1
- package/dist/components/MessageController.d.ts.map +1 -0
- package/dist/components/MessageController.js +26 -48
- package/dist/components/MessageController.js.map +1 -1
- package/dist/components/MessagesForm.d.ts +2 -1
- package/dist/components/MessagesForm.d.ts.map +1 -0
- package/dist/components/MessagesForm.js +28 -32
- package/dist/components/MessagesForm.js.map +1 -1
- package/dist/components/actions/JsonImport.d.ts +1 -0
- package/dist/components/actions/JsonImport.d.ts.map +1 -0
- package/dist/components/actions/JsonImport.js +4 -4
- package/dist/components/actions/JsonImport.js.map +1 -1
- package/dist/components/actions/Move.d.ts +2 -3
- package/dist/components/actions/Move.d.ts.map +1 -0
- package/dist/components/inputs/InputWrapper.d.ts +1 -0
- package/dist/components/inputs/InputWrapper.d.ts.map +1 -0
- package/dist/components/inputs/InputWrapper.js.map +1 -1
- package/dist/components/inputs/LexicalInput.d.ts +1 -0
- package/dist/components/inputs/LexicalInput.d.ts.map +1 -0
- package/dist/components/inputs/MessageInput.d.ts +2 -1
- package/dist/components/inputs/MessageInput.d.ts.map +1 -0
- package/dist/components/inputs/MessageInput.js +1 -1
- package/dist/components/inputs/MessageInput.js.map +1 -1
- package/dist/components/inputs/variables/VariableChip.d.ts +1 -0
- package/dist/components/inputs/variables/VariableChip.d.ts.map +1 -0
- package/dist/components/inputs/variables/VariableChip.js +3 -3
- package/dist/components/inputs/variables/VariableChip.js.map +1 -1
- package/dist/components/inputs/variables/VariableIcon.d.ts +3 -2
- package/dist/components/inputs/variables/VariableIcon.d.ts.map +1 -0
- package/dist/components/inputs/variables/VariableSuggestion.d.ts +2 -1
- package/dist/components/inputs/variables/VariableSuggestion.d.ts.map +1 -0
- package/dist/components/inputs/variables/VariableSuggestion.js +2 -2
- package/dist/components/inputs/variables/VariableSuggestion.js.map +1 -1
- package/dist/components/inputs/variables/editors/DateVariableEditor.d.ts +2 -1
- package/dist/components/inputs/variables/editors/DateVariableEditor.d.ts.map +1 -0
- package/dist/components/inputs/variables/editors/PluralVariableEditor.d.ts +2 -1
- package/dist/components/inputs/variables/editors/PluralVariableEditor.d.ts.map +1 -0
- package/dist/components/inputs/variables/editors/PluralVariableEditor.js +31 -34
- package/dist/components/inputs/variables/editors/PluralVariableEditor.js.map +1 -1
- package/dist/components/inputs/variables/editors/SelectVariableEditor.d.ts +2 -1
- package/dist/components/inputs/variables/editors/SelectVariableEditor.d.ts.map +1 -0
- package/dist/components/inputs/variables/editors/SelectVariableEditor.js +17 -10
- package/dist/components/inputs/variables/editors/SelectVariableEditor.js.map +1 -1
- package/dist/components/inputs/variables/editors/TagVariableEditor.d.ts +2 -1
- package/dist/components/inputs/variables/editors/TagVariableEditor.d.ts.map +1 -0
- package/dist/components/inputs/variables/editors/TagVariableEditor.js.map +1 -1
- package/dist/components/inputs/variables/editors/TimeVariableEditor.d.ts +2 -1
- package/dist/components/inputs/variables/editors/TimeVariableEditor.d.ts.map +1 -0
- package/dist/components/inputs/variables/extension.d.ts +2 -1
- package/dist/components/inputs/variables/extension.d.ts.map +1 -0
- package/dist/components/inputs/variables/extension.js.map +1 -1
- package/dist/components/inputs/variables/pickers/NumericVariablePicker.d.ts +2 -1
- package/dist/components/inputs/variables/pickers/NumericVariablePicker.d.ts.map +1 -0
- package/dist/components/inputs/variables/pickers/NumericVariablePicker.js +4 -4
- package/dist/components/inputs/variables/pickers/NumericVariablePicker.js.map +1 -1
- package/dist/components/inputs/variables/pickers/TemporalElementEditor.d.ts +2 -1
- package/dist/components/inputs/variables/pickers/TemporalElementEditor.d.ts.map +1 -0
- package/dist/components/layout/MessageField.d.ts +2 -1
- package/dist/components/layout/MessageField.d.ts.map +1 -0
- package/dist/components/layout/MessageField.js +12 -12
- package/dist/components/layout/MessageField.js.map +1 -1
- package/dist/components/layout/MessagesTabs.d.ts +2 -1
- package/dist/components/layout/MessagesTabs.d.ts.map +1 -0
- package/dist/components/layout/MessagesTabs.js +3 -3
- package/dist/components/layout/MessagesTabs.js.map +1 -1
- package/dist/components/layout/MessagesTree.d.ts +2 -1
- package/dist/components/layout/MessagesTree.d.ts.map +1 -0
- package/dist/components/layout/MessagesTree.js +2 -2
- package/dist/components/layout/MessagesTree.js.map +1 -1
- package/dist/context/messages-form.d.ts +2 -1
- package/dist/context/messages-form.d.ts.map +1 -0
- package/dist/context/messages-form.js.map +1 -1
- package/dist/endpoints/get-messages.d.ts +1 -0
- package/dist/endpoints/get-messages.d.ts.map +1 -0
- package/dist/endpoints/get-messages.js.map +1 -1
- package/dist/endpoints/set-messages.d.ts +1 -0
- package/dist/endpoints/set-messages.d.ts.map +1 -0
- package/dist/endpoints/set-messages.js.map +1 -1
- package/dist/exports/link.d.ts +2 -1
- package/dist/exports/link.d.ts.map +1 -0
- package/dist/exports/link.js.map +1 -1
- package/dist/exports/rsc.d.ts +1 -0
- package/dist/exports/rsc.d.ts.map +1 -0
- package/dist/exports/view.d.ts +2 -1
- package/dist/exports/view.d.ts.map +1 -0
- package/dist/exports/view.js +26 -30
- package/dist/exports/view.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -34
- package/dist/index.js.map +1 -1
- package/dist/requests/fetchMessages.d.ts +1 -0
- package/dist/requests/fetchMessages.d.ts.map +1 -0
- package/dist/requests/fetchMessages.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/types.d.ts +5 -4
- package/dist/types.d.ts.map +1 -0
- package/dist/utils/cn.d.ts +1 -0
- package/dist/utils/cn.d.ts.map +1 -0
- package/dist/utils/cn.js.map +1 -1
- package/dist/utils/config.d.ts +2 -1
- package/dist/utils/config.d.ts.map +1 -0
- package/dist/utils/config.js.map +1 -1
- package/dist/utils/error-handling.d.ts +1 -0
- package/dist/utils/error-handling.d.ts.map +1 -0
- package/dist/utils/error-handling.js.map +1 -1
- package/dist/utils/format.d.ts +2 -1
- package/dist/utils/format.d.ts.map +1 -0
- package/dist/utils/format.js.map +1 -1
- package/dist/utils/guards.d.ts +2 -0
- package/dist/utils/guards.d.ts.map +1 -0
- package/dist/utils/guards.js +14 -11
- package/dist/utils/guards.js.map +1 -1
- package/dist/utils/icu-tranform.d.ts +6 -5
- package/dist/utils/icu-tranform.d.ts.map +1 -0
- package/dist/utils/icu-tranform.js +32 -27
- package/dist/utils/icu-tranform.js.map +1 -1
- package/dist/utils/sanitize.d.ts +2 -1
- package/dist/utils/sanitize.d.ts.map +1 -0
- package/dist/utils/sanitize.js.map +1 -1
- package/dist/utils/schema.d.ts +3 -2
- package/dist/utils/schema.d.ts.map +1 -0
- package/dist/utils/schema.js +10 -9
- package/dist/utils/schema.js.map +1 -1
- package/dist/utils/validate.d.ts +2 -1
- package/dist/utils/validate.d.ts.map +1 -0
- package/dist/utils/validate.js.map +1 -1
- package/package.json +57 -72
- package/dist/components/inputs/LexicalInput.js +0 -80
- package/dist/components/inputs/LexicalInput.js.map +0 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { IconProps } from '@tabler/icons-react';
|
|
2
1
|
import { TYPE } from '@formatjs/icu-messageformat-parser';
|
|
3
|
-
|
|
2
|
+
import { IconProps } from '@tabler/icons-react';
|
|
3
|
+
export interface VariableIconProps extends Omit<IconProps, 'type'> {
|
|
4
4
|
type: TYPE;
|
|
5
5
|
}
|
|
6
6
|
export declare function VariableIcon({ type, ...props }: VariableIconProps): import("react/jsx-runtime").JSX.Element | null;
|
|
7
|
+
//# sourceMappingURL=VariableIcon.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VariableIcon.d.ts","sourceRoot":"","sources":["../../../../src/components/inputs/variables/VariableIcon.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAC1D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAUrD,MAAM,WAAW,iBAAkB,SAAQ,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC;IAChE,IAAI,EAAE,IAAI,CAAC;CACZ;AAED,wBAAgB,YAAY,CAAC,EAAE,IAAI,EAAE,GAAG,KAAK,EAAE,EAAE,iBAAiB,kDAmBjE"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { VariableMentionNodeAttrs } from '../../../types.ts';
|
|
2
1
|
import { SuggestionKeyDownProps, SuggestionProps } from '@tiptap/suggestion';
|
|
2
|
+
import { VariableMentionNodeAttrs } from '../../../types';
|
|
3
3
|
export interface VariableSuggestionProps extends SuggestionProps<VariableMentionNodeAttrs, VariableMentionNodeAttrs> {
|
|
4
4
|
ref: React.RefObject<{
|
|
5
5
|
onKeyDown: (props: SuggestionKeyDownProps) => boolean;
|
|
6
6
|
}>;
|
|
7
7
|
}
|
|
8
8
|
export declare function VariableSuggestion({ items, command, ref, }: VariableSuggestionProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
//# sourceMappingURL=VariableSuggestion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VariableSuggestion.d.ts","sourceRoot":"","sources":["../../../../src/components/inputs/variables/VariableSuggestion.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,sBAAsB,EACtB,eAAe,EAChB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAIxD,MAAM,WAAW,uBACf,SAAQ,eAAe,CAAC,wBAAwB,EAAE,wBAAwB,CAAC;IAC3E,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC;QACnB,SAAS,EAAE,CAAC,KAAK,EAAE,sBAAsB,KAAK,OAAO,CAAC;KACvD,CAAC,CAAC;CACJ;AAED,wBAAgB,kBAAkB,CAAC,EACjC,KAAK,EACL,OAAO,EACP,GAAG,GACJ,EAAE,uBAAuB,2CAiEzB"}
|
|
@@ -21,15 +21,15 @@ function x({
|
|
|
21
21
|
})), /* @__PURE__ */ a("div", { className: "flex flex-col overflow-clip rounded-md bg-elevation-100 empty:hidden", children: n.map((e, t) => /* @__PURE__ */ a(
|
|
22
22
|
"button",
|
|
23
23
|
{
|
|
24
|
-
type: "button",
|
|
25
24
|
className: b(
|
|
26
|
-
"cursor-pointer rounded-none border-none bg-transparent px-3 py-1 text-lg
|
|
25
|
+
"cursor-pointer text-nowrap rounded-none border-none bg-transparent px-3 py-1 text-lg",
|
|
27
26
|
{
|
|
28
27
|
"bg-elevation-800 text-elevation-0": t === r,
|
|
29
28
|
"hover:bg-elevation-250": t !== r
|
|
30
29
|
}
|
|
31
30
|
),
|
|
32
31
|
onClick: () => l(t),
|
|
32
|
+
type: "button",
|
|
33
33
|
children: e.label
|
|
34
34
|
},
|
|
35
35
|
t
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VariableSuggestion.js","sources":["../../../../src/components/inputs/variables/VariableSuggestion.tsx"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"VariableSuggestion.js","sources":["../../../../src/components/inputs/variables/VariableSuggestion.tsx"],"sourcesContent":["import type {\n SuggestionKeyDownProps,\n SuggestionProps,\n} from '@tiptap/suggestion';\nimport { useEffect, useImperativeHandle, useState } from 'react';\nimport type { VariableMentionNodeAttrs } from '@/types';\n\nimport { cn } from '@/utils/cn';\n\nexport interface VariableSuggestionProps\n extends SuggestionProps<VariableMentionNodeAttrs, VariableMentionNodeAttrs> {\n ref: React.RefObject<{\n onKeyDown: (props: SuggestionKeyDownProps) => boolean;\n }>;\n}\n\nexport function VariableSuggestion({\n items,\n command,\n ref,\n}: VariableSuggestionProps) {\n const [selectedIndex, setSelectedIndex] = useState(0);\n\n const selectItem = (index: number) => {\n const item = items[index];\n\n if (item) command(item);\n };\n\n const upHandler = () => {\n setSelectedIndex((selectedIndex + items.length - 1) % items.length);\n };\n\n const downHandler = () => {\n setSelectedIndex((selectedIndex + 1) % items.length);\n };\n\n const enterHandler = () => {\n selectItem(selectedIndex);\n };\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: <explanation>\n useEffect(() => setSelectedIndex(0), [items]);\n\n useImperativeHandle(ref, () => ({\n onKeyDown: ({ event }) => {\n if (event.key === 'ArrowUp') {\n upHandler();\n return true;\n }\n\n if (event.key === 'ArrowDown') {\n downHandler();\n return true;\n }\n\n if (event.key === 'Enter') {\n enterHandler();\n return true;\n }\n\n return false;\n },\n }));\n\n return (\n <div className=\"flex flex-col overflow-clip rounded-md bg-elevation-100 empty:hidden\">\n {items.map((item, index) => (\n <button\n className={cn(\n 'cursor-pointer text-nowrap rounded-none border-none bg-transparent px-3 py-1 text-lg',\n {\n 'bg-elevation-800 text-elevation-0': index === selectedIndex,\n 'hover:bg-elevation-250': index !== selectedIndex,\n },\n )}\n key={index}\n onClick={() => selectItem(index)}\n type=\"button\"\n >\n {item.label}\n </button>\n ))}\n </div>\n );\n}\n"],"names":["VariableSuggestion","items","command","ref","selectedIndex","setSelectedIndex","useState","selectItem","index","item","upHandler","downHandler","enterHandler","useEffect","useImperativeHandle","event","jsx","cn"],"mappings":";;;AAgBO,SAASA,EAAmB;AAAA,EACjC,OAAAC;AAAA,EACA,SAAAC;AAAA,EACA,KAAAC;AACF,GAA4B;AAC1B,QAAM,CAACC,GAAeC,CAAgB,IAAIC,EAAS,CAAC,GAE9CC,IAAa,CAACC,MAAkB;AACpC,UAAMC,IAAOR,EAAMO,CAAK;AAExB,IAAIC,OAAcA,CAAI;AAAA,EACxB,GAEMC,IAAY,MAAM;AACtB,IAAAL,GAAkBD,IAAgBH,EAAM,SAAS,KAAKA,EAAM,MAAM;AAAA,EACpE,GAEMU,IAAc,MAAM;AACxB,IAAAN,GAAkBD,IAAgB,KAAKH,EAAM,MAAM;AAAA,EACrD,GAEMW,IAAe,MAAM;AACzB,IAAAL,EAAWH,CAAa;AAAA,EAC1B;AAGA,SAAAS,EAAU,MAAMR,EAAiB,CAAC,GAAG,CAACJ,CAAK,CAAC,GAE5Ca,EAAoBX,GAAK,OAAO;AAAA,IAC9B,WAAW,CAAC,EAAE,OAAAY,QACRA,EAAM,QAAQ,aAChBL,EAAA,GACO,MAGLK,EAAM,QAAQ,eAChBJ,EAAA,GACO,MAGLI,EAAM,QAAQ,WAChBH,EAAA,GACO,MAGF;AAAA,EACT,EACA,GAGA,gBAAAI,EAAC,SAAI,WAAU,wEACZ,YAAM,IAAI,CAACP,GAAMD,MAChB,gBAAAQ;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAWC;AAAA,QACT;AAAA,QACA;AAAA,UACE,qCAAqCT,MAAUJ;AAAA,UAC/C,0BAA0BI,MAAUJ;AAAA,QAAA;AAAA,MACtC;AAAA,MAGF,SAAS,MAAMG,EAAWC,CAAK;AAAA,MAC/B,MAAK;AAAA,MAEJ,UAAAC,EAAK;AAAA,IAAA;AAAA,IAJDD;AAAA,EAAA,CAMR,GACH;AAEJ;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DateElement } from '../../../../types
|
|
1
|
+
import { DateElement } from '../../../../types';
|
|
2
2
|
export interface DateVariableEditorProps {
|
|
3
3
|
name: string;
|
|
4
4
|
element: DateElement | undefined;
|
|
@@ -7,3 +7,4 @@ export interface DateVariableEditorProps {
|
|
|
7
7
|
}>;
|
|
8
8
|
}
|
|
9
9
|
export declare function DateVariableEditor({ name, element, ref, }: DateVariableEditorProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
//# sourceMappingURL=DateVariableEditor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DateVariableEditor.d.ts","sourceRoot":"","sources":["../../../../../src/components/inputs/variables/editors/DateVariableEditor.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,WAAW,GAAG,SAAS,CAAC;IACjC,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC;QAAE,QAAQ,EAAE,MAAM,MAAM,CAAA;KAAE,CAAC,CAAC;CAC5C;AAED,wBAAgB,kBAAkB,CAAC,EACjC,IAAI,EACJ,OAAO,EACP,GAAG,GACJ,EAAE,uBAAuB,2CASzB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PluralElement } from '../../../../types
|
|
1
|
+
import { PluralElement } from '../../../../types';
|
|
2
2
|
export interface PluralVariableEditorProps {
|
|
3
3
|
variableName: string;
|
|
4
4
|
element: PluralElement | undefined;
|
|
@@ -7,3 +7,4 @@ export interface PluralVariableEditorProps {
|
|
|
7
7
|
}>;
|
|
8
8
|
}
|
|
9
9
|
export declare function PluralVariableEditor({ variableName, element, ref, }: PluralVariableEditorProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
//# sourceMappingURL=PluralVariableEditor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PluralVariableEditor.d.ts","sourceRoot":"","sources":["../../../../../src/components/inputs/variables/editors/PluralVariableEditor.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAO7C,MAAM,WAAW,yBAAyB;IACxC,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,aAAa,GAAG,SAAS,CAAC;IACnC,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC;QAAE,QAAQ,EAAE,MAAM,MAAM,CAAA;KAAE,CAAC,CAAC;CAC5C;AAID,wBAAgB,oBAAoB,CAAC,EACnC,YAAY,EACZ,OAAO,EACP,GAAG,GACJ,EAAE,yBAAyB,2CA8K3B"}
|
|
@@ -63,8 +63,8 @@ function A({
|
|
|
63
63
|
"button",
|
|
64
64
|
{
|
|
65
65
|
className: "ml-auto flex cursor-pointer items-center justify-center border-none bg-transparent p-0 hover:text-error",
|
|
66
|
-
type: "button",
|
|
67
66
|
onClick: () => a.remove(t),
|
|
67
|
+
type: "button",
|
|
68
68
|
children: /* @__PURE__ */ r(v, { size: 16 })
|
|
69
69
|
}
|
|
70
70
|
)
|
|
@@ -74,8 +74,8 @@ function A({
|
|
|
74
74
|
/* @__PURE__ */ r(
|
|
75
75
|
"input",
|
|
76
76
|
{
|
|
77
|
-
type: "text",
|
|
78
77
|
className: "col-span-2 focus:outline-none",
|
|
78
|
+
type: "text",
|
|
79
79
|
...d("other", { required: !0 })
|
|
80
80
|
}
|
|
81
81
|
)
|
|
@@ -88,8 +88,8 @@ function A({
|
|
|
88
88
|
"input",
|
|
89
89
|
{
|
|
90
90
|
className: "w-8 text-center",
|
|
91
|
-
type: "numeric",
|
|
92
91
|
placeholder: "0",
|
|
92
|
+
type: "numeric",
|
|
93
93
|
...d("offset")
|
|
94
94
|
}
|
|
95
95
|
)
|
|
@@ -99,8 +99,8 @@ function A({
|
|
|
99
99
|
/* @__PURE__ */ r(i.Portal, { children: /* @__PURE__ */ o(
|
|
100
100
|
i.Content,
|
|
101
101
|
{
|
|
102
|
+
className: "data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-y-auto overflow-x-hidden rounded-md border border-border bg-elevation-50 shadow-md data-[state=closed]:animate-out data-[state=open]:animate-in",
|
|
102
103
|
sideOffset: 4,
|
|
103
|
-
className: "z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border border-border bg-elevation-50 shadow-md data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95",
|
|
104
104
|
children: [
|
|
105
105
|
/* @__PURE__ */ r("div", { className: "flex flex-col", children: z.filter(
|
|
106
106
|
(e) => a.fields.every((t) => t.name !== e)
|
|
@@ -125,42 +125,39 @@ function A({
|
|
|
125
125
|
},
|
|
126
126
|
e
|
|
127
127
|
)) }),
|
|
128
|
-
/* @__PURE__ */ o("div", { className: "flex items-center justify-between gap-2 border-
|
|
128
|
+
/* @__PURE__ */ o("div", { className: "flex items-center justify-between gap-2 border-border border-t p-2", children: [
|
|
129
129
|
/* @__PURE__ */ r("label", { htmlFor: "customValue", children: "custom" }),
|
|
130
130
|
/* @__PURE__ */ r(
|
|
131
131
|
F,
|
|
132
132
|
{
|
|
133
133
|
control: c,
|
|
134
134
|
name: "customValue",
|
|
135
|
-
render: ({ field: e }) => (
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
"
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
)
|
|
135
|
+
render: ({ field: e }) => /* @__PURE__ */ r(
|
|
136
|
+
"input",
|
|
137
|
+
{
|
|
138
|
+
className: "w-8 rounded-sm border-transparent text-center focus:border-border focus:outline-none",
|
|
139
|
+
min: 0,
|
|
140
|
+
onChange: ({ currentTarget: { value: t } }) => {
|
|
141
|
+
const n = Number(t);
|
|
142
|
+
isNaN(n) || n < 0 || e.onChange(n);
|
|
143
|
+
},
|
|
144
|
+
onKeyDown: (t) => {
|
|
145
|
+
t.key !== "Enter" || e.value === void 0 || a.fields.some(
|
|
146
|
+
(s) => s.name === `=${e.value}`
|
|
147
|
+
) || (a.append(
|
|
148
|
+
{
|
|
149
|
+
name: `=${e.value}`,
|
|
150
|
+
content: ""
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
shouldFocus: !0
|
|
154
|
+
}
|
|
155
|
+
), e.onChange(void 0));
|
|
156
|
+
},
|
|
157
|
+
placeholder: "=0",
|
|
158
|
+
type: "numeric",
|
|
159
|
+
value: e.value ?? ""
|
|
160
|
+
}
|
|
164
161
|
)
|
|
165
162
|
}
|
|
166
163
|
)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PluralVariableEditor.js","sources":["../../../../../src/components/inputs/variables/editors/PluralVariableEditor.tsx"],"sourcesContent":["import type { PluralElement } from \"@/types\";\nimport { TYPE } from \"@formatjs/icu-messageformat-parser\";\nimport { IconX } from \"@tabler/icons-react\";\nimport { Popover } from \"radix-ui\";\nimport { Fragment, useImperativeHandle, useMemo } from \"react\";\nimport { Controller, useFieldArray, useForm } from \"react-hook-form\";\n\nimport { cn } from \"@/utils/cn\";\nimport { parseICUMessage, serializeICUMessage } from \"@/utils/icu-tranform\";\n\nconst NAMED_PLURAL_OPTIONS = [\"zero\", \"one\", \"two\", \"few\", \"many\"] as const;\n\nexport interface PluralVariableEditorProps {\n variableName: string;\n element: PluralElement | undefined;\n ref: React.Ref<{ getValue: () => string }>;\n}\n\n// TODO add support for selectordinal (\"pluralType\": \"ordinal\")\n\nexport function PluralVariableEditor({\n variableName,\n element,\n ref,\n}: PluralVariableEditorProps) {\n const config = useMemo<{\n offset: number;\n options: { name: string; content: string }[];\n other: string;\n }>(() => {\n const { other, ...options } = element?.options ?? {};\n return {\n offset: element?.offset ?? 0,\n options: Object.entries(options).map(([name, option]) => ({\n name,\n content: serializeICUMessage(option.value),\n })),\n other: serializeICUMessage(other ? other.value : []),\n };\n }, [element]);\n\n const { control, register, getValues } = useForm<{\n offset: number;\n options: { name: string; content: string }[];\n other: string;\n customValue?: number;\n }>({\n defaultValues: config,\n });\n\n useImperativeHandle(ref, () => ({\n getValue: () => {\n const values = getValues();\n const updatedElement: PluralElement = {\n type: TYPE.plural,\n value: variableName,\n offset: values.offset,\n pluralType: element?.pluralType ?? \"cardinal\",\n options: Object.fromEntries(\n values.options.map(({ name, content }) => [\n name,\n { value: parseICUMessage(content) },\n ]),\n ),\n };\n return serializeICUMessage([updatedElement]);\n },\n }));\n\n const options = useFieldArray({\n control,\n name: \"options\",\n });\n\n return (\n <div className=\"flex flex-col gap-3\">\n <fieldset className=\"mx-0 grid grid-cols-[3rem_8rem_1.5rem] gap-y-2 rounded-md border border-border px-2 pr-0\">\n <legend>Options</legend>\n {options.fields.map((field, index) => (\n <Fragment key={field.id}>\n <label htmlFor={`options.${index}`}>{field.name}</label>\n {/* // TODO add support for variable mentions */}\n <input\n className=\"focus:outline-none\"\n type=\"text\"\n {...register(`options.${index}.content`, { required: true })}\n />\n <button\n className=\"ml-auto flex cursor-pointer items-center justify-center border-none bg-transparent p-0 hover:text-error\"\n type=\"button\"\n onClick={() => options.remove(index)}\n >\n <IconX size={16} />\n </button>\n </Fragment>\n ))}\n\n <>\n <label htmlFor=\"other\">other</label>\n {/* // TODO add support for variable mentions */}\n <input\n type=\"text\"\n className=\"col-span-2 focus:outline-none\"\n {...register(\"other\", { required: true })}\n />\n </>\n </fieldset>\n <div className=\"grid grid-cols-2 items-center gap-2\">\n <label className=\"flex items-center gap-3 pl-2\">\n offset\n <input\n className=\"w-8 text-center\"\n type=\"numeric\"\n placeholder=\"0\"\n {...register(\"offset\")}\n />\n </label>\n <Popover.Root>\n <Popover.Trigger>Add Option</Popover.Trigger>\n <Popover.Portal>\n <Popover.Content\n sideOffset={4}\n className=\"z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border border-border bg-elevation-50 shadow-md data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95\"\n >\n <div className=\"flex flex-col\">\n {NAMED_PLURAL_OPTIONS.filter((option) =>\n options.fields.every((field) => field.name !== option),\n ).map((option) => (\n <Popover.Close\n key={option}\n className={cn(\n \"cursor-pointer border-none bg-transparent px-1 hover:bg-elevation-250\",\n )}\n onClick={() => {\n // TODO ensure the fields are always in the same order as staticPluralOptions\n options.append(\n {\n name: option,\n content: \"\",\n },\n {\n shouldFocus: true,\n },\n );\n }}\n >\n {option}\n </Popover.Close>\n ))}\n </div>\n\n <div className=\"flex items-center justify-between gap-2 border-t border-border p-2\">\n <label htmlFor=\"customValue\">custom</label>\n <Controller\n control={control}\n name=\"customValue\"\n render={({ field }) => (\n // eslint-disable-next-line jsx-a11y/control-has-associated-label\n <input\n type=\"numeric\"\n className=\"w-8 rounded-sm border-transparent text-center focus:border-border focus:outline-none\"\n placeholder=\"=0\"\n min={0}\n value={field.value ?? \"\"}\n onChange={({ currentTarget: { value } }) => {\n const number = Number(value);\n if (isNaN(number)) return;\n if (number < 0) return;\n field.onChange(number);\n }}\n onKeyDown={(e) => {\n if (e.key !== \"Enter\") return;\n if (field.value === undefined) return;\n const isUnique = !options.fields.some(\n (existingField) =>\n existingField.name === `=${field.value}`,\n );\n if (!isUnique) return; // TODO maybe show error?\n options.append(\n {\n name: `=${field.value}`,\n content: \"\",\n },\n {\n shouldFocus: true,\n },\n );\n field.onChange(undefined);\n }}\n />\n )}\n />\n </div>\n </Popover.Content>\n </Popover.Portal>\n </Popover.Root>\n </div>\n </div>\n );\n}\n"],"names":["NAMED_PLURAL_OPTIONS","PluralVariableEditor","variableName","element","ref","config","useMemo","other","options","name","option","serializeICUMessage","control","register","getValues","useForm","useImperativeHandle","values","updatedElement","TYPE","content","parseICUMessage","useFieldArray","jsxs","jsx","field","index","Fragment","IconX","Popover","cn","Controller","value","number","e","existingField"],"mappings":";;;;;;;;AAUA,MAAMA,IAAuB,CAAC,QAAQ,OAAO,OAAO,OAAO,MAAM;AAU1D,SAASC,EAAqB;AAAA,EACnC,cAAAC;AAAA,EACA,SAAAC;AAAA,EACA,KAAAC;AACF,GAA8B;AAC5B,QAAMC,IAASC,EAIZ,MAAM;AACP,UAAM,EAAE,OAAAC,GAAO,GAAGC,MAAYL,GAAS,WAAW,CAAA;AAClD,WAAO;AAAA,MACL,QAAQA,GAAS,UAAU;AAAA,MAC3B,SAAS,OAAO,QAAQK,CAAO,EAAE,IAAI,CAAC,CAACC,GAAMC,CAAM,OAAO;AAAA,QACxD,MAAAD;AAAA,QACA,SAASE,EAAoBD,EAAO,KAAK;AAAA,MAAA,EACzC;AAAA,MACF,OAAOC,EAAoBJ,IAAQA,EAAM,QAAQ,CAAA,CAAE;AAAA,IAAA;AAAA,EAEvD,GAAG,CAACJ,CAAO,CAAC,GAEN,EAAE,SAAAS,GAAS,UAAAC,GAAU,WAAAC,EAAA,IAAcC,EAKtC;AAAA,IACD,eAAeV;AAAA,EAAA,CAChB;AAED,EAAAW,EAAoBZ,GAAK,OAAO;AAAA,IAC9B,UAAU,MAAM;AACd,YAAMa,IAASH,EAAA,GACTI,IAAgC;AAAA,QACpC,MAAMC,EAAK;AAAA,QACX,OAAOjB;AAAA,QACP,QAAQe,EAAO;AAAA,QACf,YAAYd,GAAS,cAAc;AAAA,QACnC,SAAS,OAAO;AAAA,UACdc,EAAO,QAAQ,IAAI,CAAC,EAAE,MAAAR,GAAM,SAAAW,QAAc;AAAA,YACxCX;AAAA,YACA,EAAE,OAAOY,EAAgBD,CAAO,EAAA;AAAA,UAAE,CACnC;AAAA,QAAA;AAAA,MACH;AAEF,aAAOT,EAAoB,CAACO,CAAc,CAAC;AAAA,IAC7C;AAA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AAAA,sBAET,gBAAAD;AAAA,wBAAC;AAAA,wBAAA;AAAA,0BACC,MAAK;AAAA,0BACL,WAAU;AAAA,0BACV,aAAY;AAAA,0BACZ,KAAK;AAAA,0BACL,OAAOC,EAAM,SAAS;AAAA,0BACtB,UAAU,CAAC,EAAE,eAAe,EAAE,OAAAO,EAAA,QAAc;AAC1C,kCAAMC,IAAS,OAAOD,CAAK;AAC3B,4BAAI,MAAMC,CAAM,KACZA,IAAS,KACbR,EAAM,SAASQ,CAAM;AAAA,0BACvB;AAAA,0BACA,WAAW,CAACC,MAAM;AAOhB,4BANIA,EAAE,QAAQ,WACVT,EAAM,UAAU,UACFjB,EAAQ,OAAO;AAAA,8BAC/B,CAAC2B,MACCA,EAAc,SAAS,IAAIV,EAAM,KAAK;AAAA,4BAAA,MAG1CjB,EAAQ;AAAA,8BACN;AAAA,gCACE,MAAM,IAAIiB,EAAM,KAAK;AAAA,gCACrB,SAAS;AAAA,8BAAA;AAAA,8BAEX;AAAA,gCACE,aAAa;AAAA,8BAAA;AAAA,4BACf,GAEFA,EAAM,SAAS,MAAS;AAAA,0BAC1B;AAAA,wBAAA;AAAA,sBAAA;AAAA;AAAA,kBACF;AAAA,gBAAA;AAAA,cAEJ,EAAA,CACF;AAAA,YAAA;AAAA,UAAA;AAAA,QAAA,EACF,CACF;AAAA,MAAA,EAAA,CACF;AAAA,IAAA,EAAA,CACF;AAAA,EAAA,GACF;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"PluralVariableEditor.js","sources":["../../../../../src/components/inputs/variables/editors/PluralVariableEditor.tsx"],"sourcesContent":["import { TYPE } from '@formatjs/icu-messageformat-parser';\nimport { IconX } from '@tabler/icons-react';\nimport { Popover } from 'radix-ui';\nimport { Fragment, useImperativeHandle, useMemo } from 'react';\nimport { Controller, useFieldArray, useForm } from 'react-hook-form';\nimport type { PluralElement } from '@/types';\n\nimport { cn } from '@/utils/cn';\nimport { parseICUMessage, serializeICUMessage } from '@/utils/icu-tranform';\n\nconst NAMED_PLURAL_OPTIONS = ['zero', 'one', 'two', 'few', 'many'] as const;\n\nexport interface PluralVariableEditorProps {\n variableName: string;\n element: PluralElement | undefined;\n ref: React.Ref<{ getValue: () => string }>;\n}\n\n// TODO add support for selectordinal (\"pluralType\": \"ordinal\")\n\nexport function PluralVariableEditor({\n variableName,\n element,\n ref,\n}: PluralVariableEditorProps) {\n const config = useMemo<{\n offset: number;\n options: { name: string; content: string }[];\n other: string;\n }>(() => {\n const { other, ...options } = element?.options ?? {};\n return {\n offset: element?.offset ?? 0,\n options: Object.entries(options).map(([name, option]) => ({\n name,\n content: serializeICUMessage(option.value),\n })),\n other: serializeICUMessage(other ? other.value : []),\n };\n }, [element]);\n\n const { control, register, getValues } = useForm<{\n offset: number;\n options: { name: string; content: string }[];\n other: string;\n customValue?: number;\n }>({\n defaultValues: config,\n });\n\n useImperativeHandle(ref, () => ({\n getValue: () => {\n const values = getValues();\n const updatedElement: PluralElement = {\n type: TYPE.plural,\n value: variableName,\n offset: values.offset,\n pluralType: element?.pluralType ?? 'cardinal',\n options: Object.fromEntries(\n values.options.map(({ name, content }) => [\n name,\n { value: parseICUMessage(content) },\n ]),\n ),\n };\n return serializeICUMessage([updatedElement]);\n },\n }));\n\n const options = useFieldArray({\n control,\n name: 'options',\n });\n\n return (\n <div className=\"flex flex-col gap-3\">\n <fieldset className=\"mx-0 grid grid-cols-[3rem_8rem_1.5rem] gap-y-2 rounded-md border border-border px-2 pr-0\">\n <legend>Options</legend>\n {options.fields.map((field, index) => (\n <Fragment key={field.id}>\n <label htmlFor={`options.${index}`}>{field.name}</label>\n {/* // TODO add support for variable mentions */}\n <input\n className=\"focus:outline-none\"\n type=\"text\"\n {...register(`options.${index}.content`, { required: true })}\n />\n <button\n className=\"ml-auto flex cursor-pointer items-center justify-center border-none bg-transparent p-0 hover:text-error\"\n onClick={() => options.remove(index)}\n type=\"button\"\n >\n <IconX size={16} />\n </button>\n </Fragment>\n ))}\n\n <>\n <label htmlFor=\"other\">other</label>\n {/* // TODO add support for variable mentions */}\n <input\n className=\"col-span-2 focus:outline-none\"\n type=\"text\"\n {...register('other', { required: true })}\n />\n </>\n </fieldset>\n <div className=\"grid grid-cols-2 items-center gap-2\">\n <label className=\"flex items-center gap-3 pl-2\">\n offset\n <input\n className=\"w-8 text-center\"\n placeholder=\"0\"\n type=\"numeric\"\n {...register('offset')}\n />\n </label>\n <Popover.Root>\n <Popover.Trigger>Add Option</Popover.Trigger>\n <Popover.Portal>\n <Popover.Content\n className=\"data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-y-auto overflow-x-hidden rounded-md border border-border bg-elevation-50 shadow-md data-[state=closed]:animate-out data-[state=open]:animate-in\"\n sideOffset={4}\n >\n <div className=\"flex flex-col\">\n {NAMED_PLURAL_OPTIONS.filter((option) =>\n options.fields.every((field) => field.name !== option),\n ).map((option) => (\n <Popover.Close\n className={cn(\n 'cursor-pointer border-none bg-transparent px-1 hover:bg-elevation-250',\n )}\n key={option}\n onClick={() => {\n // TODO ensure the fields are always in the same order as staticPluralOptions\n options.append(\n {\n name: option,\n content: '',\n },\n {\n shouldFocus: true,\n },\n );\n }}\n >\n {option}\n </Popover.Close>\n ))}\n </div>\n\n <div className=\"flex items-center justify-between gap-2 border-border border-t p-2\">\n <label htmlFor=\"customValue\">custom</label>\n <Controller\n control={control}\n name=\"customValue\"\n render={({ field }) => (\n <input\n className=\"w-8 rounded-sm border-transparent text-center focus:border-border focus:outline-none\"\n min={0}\n onChange={({ currentTarget: { value } }) => {\n const number = Number(value);\n if (isNaN(number)) return;\n if (number < 0) return;\n field.onChange(number);\n }}\n onKeyDown={(e) => {\n if (e.key !== 'Enter') return;\n if (field.value === undefined) return;\n const isUnique = !options.fields.some(\n (existingField) =>\n existingField.name === `=${field.value}`,\n );\n if (!isUnique) return; // TODO maybe show error?\n options.append(\n {\n name: `=${field.value}`,\n content: '',\n },\n {\n shouldFocus: true,\n },\n );\n field.onChange(undefined);\n }}\n placeholder=\"=0\"\n type=\"numeric\"\n value={field.value ?? ''}\n />\n )}\n />\n </div>\n </Popover.Content>\n </Popover.Portal>\n </Popover.Root>\n </div>\n </div>\n );\n}\n"],"names":["NAMED_PLURAL_OPTIONS","PluralVariableEditor","variableName","element","ref","config","useMemo","other","options","name","option","serializeICUMessage","control","register","getValues","useForm","useImperativeHandle","values","updatedElement","TYPE","content","parseICUMessage","useFieldArray","jsxs","jsx","field","index","Fragment","IconX","Popover","cn","Controller","value","number","e","existingField"],"mappings":";;;;;;;;AAUA,MAAMA,IAAuB,CAAC,QAAQ,OAAO,OAAO,OAAO,MAAM;AAU1D,SAASC,EAAqB;AAAA,EACnC,cAAAC;AAAA,EACA,SAAAC;AAAA,EACA,KAAAC;AACF,GAA8B;AAC5B,QAAMC,IAASC,EAIZ,MAAM;AACP,UAAM,EAAE,OAAAC,GAAO,GAAGC,MAAYL,GAAS,WAAW,CAAA;AAClD,WAAO;AAAA,MACL,QAAQA,GAAS,UAAU;AAAA,MAC3B,SAAS,OAAO,QAAQK,CAAO,EAAE,IAAI,CAAC,CAACC,GAAMC,CAAM,OAAO;AAAA,QACxD,MAAAD;AAAA,QACA,SAASE,EAAoBD,EAAO,KAAK;AAAA,MAAA,EACzC;AAAA,MACF,OAAOC,EAAoBJ,IAAQA,EAAM,QAAQ,CAAA,CAAE;AAAA,IAAA;AAAA,EAEvD,GAAG,CAACJ,CAAO,CAAC,GAEN,EAAE,SAAAS,GAAS,UAAAC,GAAU,WAAAC,EAAA,IAAcC,EAKtC;AAAA,IACD,eAAeV;AAAA,EAAA,CAChB;AAED,EAAAW,EAAoBZ,GAAK,OAAO;AAAA,IAC9B,UAAU,M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,CACF;AAAA,EAAA,GACF;AAEJ;"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { SelectElement } from '../../../../types
|
|
1
|
+
import { SelectElement } from '../../../../types';
|
|
2
2
|
export interface SelectVariableEditorProps {
|
|
3
3
|
element: SelectElement;
|
|
4
4
|
onUpdate: (value: string) => void;
|
|
5
5
|
}
|
|
6
6
|
export declare function SelectVariableEditor({ element, onUpdate, }: SelectVariableEditorProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
//# sourceMappingURL=SelectVariableEditor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SelectVariableEditor.d.ts","sourceRoot":"","sources":["../../../../../src/components/inputs/variables/editors/SelectVariableEditor.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAI7C,MAAM,WAAW,yBAAyB;IACxC,OAAO,EAAE,aAAa,CAAC;IACvB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACnC;AAED,wBAAgB,oBAAoB,CAAC,EACnC,OAAO,EACP,QAAQ,GACT,EAAE,yBAAyB,2CAwD3B"}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as s, jsxs as f } from "react/jsx-runtime";
|
|
2
2
|
import { useMemo as d, useEffect as x } from "react";
|
|
3
3
|
import { useForm as g, useFieldArray as v } from "react-hook-form";
|
|
4
4
|
import { serializeICUMessage as n, parseICUMessage as b } from "../../../../utils/icu-tranform.js";
|
|
5
|
-
function
|
|
6
|
-
element:
|
|
5
|
+
function F({
|
|
6
|
+
element: t,
|
|
7
7
|
onUpdate: a
|
|
8
8
|
}) {
|
|
9
9
|
const r = d(
|
|
10
|
-
() => Object.entries(
|
|
10
|
+
() => Object.entries(t.options).map(([e, o]) => ({
|
|
11
11
|
name: e,
|
|
12
12
|
content: n(o.value)
|
|
13
13
|
})),
|
|
14
|
-
[
|
|
14
|
+
[t]
|
|
15
15
|
), { control: i, register: l, getValues: c } = g({
|
|
16
16
|
defaultValues: { options: r }
|
|
17
17
|
}), { fields: m } = v({
|
|
@@ -20,7 +20,7 @@ function M({
|
|
|
20
20
|
});
|
|
21
21
|
return x(() => () => {
|
|
22
22
|
const e = c(), o = {
|
|
23
|
-
...
|
|
23
|
+
...t,
|
|
24
24
|
options: Object.fromEntries(
|
|
25
25
|
e.options.map(({ name: p, content: u }) => [
|
|
26
26
|
p,
|
|
@@ -29,9 +29,16 @@ function M({
|
|
|
29
29
|
)
|
|
30
30
|
};
|
|
31
31
|
a(n([o]));
|
|
32
|
-
}, []), /* @__PURE__ */
|
|
33
|
-
/* @__PURE__ */
|
|
34
|
-
|
|
32
|
+
}, []), /* @__PURE__ */ s("div", { className: "flex flex-col gap-2 p-3", children: m.map((e, o) => /* @__PURE__ */ f("div", { className: "flex flex-col gap-1", children: [
|
|
33
|
+
/* @__PURE__ */ s(
|
|
34
|
+
"label",
|
|
35
|
+
{
|
|
36
|
+
className: "font-medium text-sm",
|
|
37
|
+
htmlFor: `options.${o}.content`,
|
|
38
|
+
children: e.name
|
|
39
|
+
}
|
|
40
|
+
),
|
|
41
|
+
/* @__PURE__ */ s(
|
|
35
42
|
"input",
|
|
36
43
|
{
|
|
37
44
|
className: "focus:outline-none",
|
|
@@ -41,6 +48,6 @@ function M({
|
|
|
41
48
|
] }, e.name)) });
|
|
42
49
|
}
|
|
43
50
|
export {
|
|
44
|
-
|
|
51
|
+
F as SelectVariableEditor
|
|
45
52
|
};
|
|
46
53
|
//# sourceMappingURL=SelectVariableEditor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectVariableEditor.js","sources":["../../../../../src/components/inputs/variables/editors/SelectVariableEditor.tsx"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"SelectVariableEditor.js","sources":["../../../../../src/components/inputs/variables/editors/SelectVariableEditor.tsx"],"sourcesContent":["import { useEffect, useMemo } from 'react';\nimport { useFieldArray, useForm } from 'react-hook-form';\nimport type { SelectElement } from '@/types';\n\nimport { parseICUMessage, serializeICUMessage } from '@/utils/icu-tranform';\n\nexport interface SelectVariableEditorProps {\n element: SelectElement;\n onUpdate: (value: string) => void;\n}\n\nexport function SelectVariableEditor({\n element,\n onUpdate,\n}: SelectVariableEditorProps) {\n const options = useMemo<{ name: string; content: string }[]>(\n () =>\n Object.entries(element.options).map(([name, option]) => ({\n name,\n content: serializeICUMessage(option.value),\n })),\n [element],\n );\n\n const { control, register, getValues } = useForm<{\n options: { name: string; content: string }[];\n }>({\n defaultValues: { options },\n });\n const { fields } = useFieldArray({\n control,\n name: 'options',\n });\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: useEffectEvent\n useEffect(() => {\n return () => {\n const values = getValues();\n const updatedElement: SelectElement = {\n ...element,\n options: Object.fromEntries(\n values.options.map(({ name, content }) => [\n name,\n { value: parseICUMessage(content) },\n ]),\n ),\n };\n onUpdate(serializeICUMessage([updatedElement]));\n };\n }, []);\n\n return (\n <div className=\"flex flex-col gap-2 p-3\">\n {fields.map((field, index) => (\n <div className=\"flex flex-col gap-1\" key={field.name}>\n <label\n className=\"font-medium text-sm\"\n htmlFor={`options.${index}.content`}\n >\n {field.name}\n </label>\n {/* // TODO add support for variable mentions */}\n <input\n className=\"focus:outline-none\"\n {...register(`options.${index}.content`)}\n />\n </div>\n ))}\n </div>\n );\n}\n"],"names":["SelectVariableEditor","element","onUpdate","options","useMemo","name","option","serializeICUMessage","control","register","getValues","useForm","fields","useFieldArray","useEffect","values","updatedElement","content","parseICUMessage","jsx","field","index","jsxs"],"mappings":";;;;AAWO,SAASA,EAAqB;AAAA,EACnC,SAAAC;AAAA,EACA,UAAAC;AACF,GAA8B;AAC5B,QAAMC,IAAUC;AAAA,IACd,MACE,OAAO,QAAQH,EAAQ,OAAO,EAAE,IAAI,CAAC,CAACI,GAAMC,CAAM,OAAO;AAAA,MACvD,MAAAD;AAAA,MACA,SAASE,EAAoBD,EAAO,KAAK;AAAA,IAAA,EACzC;AAAA,IACJ,CAACL,CAAO;AAAA,EAAA,GAGJ,EAAE,SAAAO,GAAS,UAAAC,GAAU,WAAAC,EAAA,IAAcC,EAEtC;AAAA,IACD,eAAe,EAAE,SAAAR,EAAA;AAAA,EAAQ,CAC1B,GACK,EAAE,QAAAS,EAAA,IAAWC,EAAc;AAAA,IAC/B,SAAAL;AAAA,IACA,MAAM;AAAA,EAAA,CACP;AAGD,SAAAM,EAAU,MACD,MAAM;AACX,UAAMC,IAASL,EAAA,GACTM,IAAgC;AAAA,MACpC,GAAGf;AAAA,MACH,SAAS,OAAO;AAAA,QACdc,EAAO,QAAQ,IAAI,CAAC,EAAE,MAAAV,GAAM,SAAAY,QAAc;AAAA,UACxCZ;AAAA,UACA,EAAE,OAAOa,EAAgBD,CAAO,EAAA;AAAA,QAAE,CACnC;AAAA,MAAA;AAAA,IACH;AAEF,IAAAf,EAASK,EAAoB,CAACS,CAAc,CAAC,CAAC;AAAA,EAChD,GACC,CAAA,CAAE,GAGH,gBAAAG,EAAC,OAAA,EAAI,WAAU,2BACZ,UAAAP,EAAO,IAAI,CAACQ,GAAOC,MAClB,gBAAAC,EAAC,OAAA,EAAI,WAAU,uBACb,UAAA;AAAA,IAAA,gBAAAH;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,WAAU;AAAA,QACV,SAAS,WAAWE,CAAK;AAAA,QAExB,UAAAD,EAAM;AAAA,MAAA;AAAA,IAAA;AAAA,IAGT,gBAAAD;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,WAAU;AAAA,QACT,GAAGV,EAAS,WAAWY,CAAK,UAAU;AAAA,MAAA;AAAA,IAAA;AAAA,EACzC,EAAA,GAXwCD,EAAM,IAYhD,CACD,GACH;AAEJ;"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { TagElement } from '../../../../types
|
|
1
|
+
import { TagElement } from '../../../../types';
|
|
2
2
|
export interface TagVariableEditorProps {
|
|
3
3
|
element: TagElement;
|
|
4
4
|
onUpdate: (value: string) => void;
|
|
5
5
|
}
|
|
6
6
|
export declare function TagVariableEditor({ element, onUpdate, }: TagVariableEditorProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
//# sourceMappingURL=TagVariableEditor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TagVariableEditor.d.ts","sourceRoot":"","sources":["../../../../../src/components/inputs/variables/editors/TagVariableEditor.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAI1C,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,UAAU,CAAC;IACpB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACnC;AAED,wBAAgB,iBAAiB,CAAC,EAChC,OAAO,EACP,QAAQ,GACT,EAAE,sBAAsB,2CA+BxB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TagVariableEditor.js","sources":["../../../../../src/components/inputs/variables/editors/TagVariableEditor.tsx"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"TagVariableEditor.js","sources":["../../../../../src/components/inputs/variables/editors/TagVariableEditor.tsx"],"sourcesContent":["import { useEffect, useMemo } from 'react';\nimport { useForm } from 'react-hook-form';\nimport type { TagElement } from '@/types';\n\nimport { parseICUMessage, serializeICUMessage } from '@/utils/icu-tranform';\n\nexport interface TagVariableEditorProps {\n element: TagElement;\n onUpdate: (value: string) => void;\n}\n\nexport function TagVariableEditor({\n element,\n onUpdate,\n}: TagVariableEditorProps) {\n const content = useMemo<string>(\n () => serializeICUMessage(element.children),\n [element],\n );\n\n const { register, getValues } = useForm<{ content: string }>({\n defaultValues: { content },\n });\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: useEffectEvent\n useEffect(() => {\n return () => {\n const { content } = getValues();\n // TODO find better solution for this\n const updatedElement: TagElement = {\n ...element,\n children: parseICUMessage(content),\n };\n onUpdate(serializeICUMessage([updatedElement]));\n };\n }, []);\n\n // TODO add support for variable mentions\n return (\n <textarea\n className=\"p-3 focus:outline-none\"\n {...register('content')}\n rows={1}\n />\n );\n}\n"],"names":["TagVariableEditor","element","onUpdate","content","useMemo","serializeICUMessage","register","getValues","useForm","useEffect","updatedElement","parseICUMessage","jsx"],"mappings":";;;;AAWO,SAASA,EAAkB;AAAA,EAChC,SAAAC;AAAA,EACA,UAAAC;AACF,GAA2B;AACzB,QAAMC,IAAUC;AAAA,IACd,MAAMC,EAAoBJ,EAAQ,QAAQ;AAAA,IAC1C,CAACA,CAAO;AAAA,EAAA,GAGJ,EAAE,UAAAK,GAAU,WAAAC,EAAA,IAAcC,EAA6B;AAAA,IAC3D,eAAe,EAAE,SAAAL,EAAA;AAAA,EAAQ,CAC1B;AAGD,SAAAM,EAAU,MACD,MAAM;AACX,UAAM,EAAE,SAAAN,EAAAA,IAAYI,EAAA,GAEdG,IAA6B;AAAA,MACjC,GAAGT;AAAA,MACH,UAAUU,EAAgBR,CAAO;AAAA,IAAA;AAEnC,IAAAD,EAASG,EAAoB,CAACK,CAAc,CAAC,CAAC;AAAA,EAChD,GACC,CAAA,CAAE,GAIH,gBAAAE;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAU;AAAA,MACT,GAAGN,EAAS,SAAS;AAAA,MACtB,MAAM;AAAA,IAAA;AAAA,EAAA;AAGZ;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TimeElement } from '../../../../types
|
|
1
|
+
import { TimeElement } from '../../../../types';
|
|
2
2
|
export interface TimeElementEditorProps {
|
|
3
3
|
name: string;
|
|
4
4
|
element: TimeElement | undefined;
|
|
@@ -7,3 +7,4 @@ export interface TimeElementEditorProps {
|
|
|
7
7
|
}>;
|
|
8
8
|
}
|
|
9
9
|
export declare function TimeElementEditor({ name, element, ref, }: TimeElementEditorProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
//# sourceMappingURL=TimeVariableEditor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TimeVariableEditor.d.ts","sourceRoot":"","sources":["../../../../../src/components/inputs/variables/editors/TimeVariableEditor.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,WAAW,GAAG,SAAS,CAAC;IACjC,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC;QAAE,QAAQ,EAAE,MAAM,MAAM,CAAA;KAAE,CAAC,CAAC;CAC5C;AAED,wBAAgB,iBAAiB,CAAC,EAChC,IAAI,EACJ,OAAO,EACP,GAAG,GACJ,EAAE,sBAAsB,2CASxB"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import { TemplateVariable, VariableMentionNodeAttrs } from '../../../types.ts';
|
|
2
1
|
import { MentionOptions } from '@tiptap/extension-mention';
|
|
2
|
+
import { TemplateVariable, VariableMentionNodeAttrs } from '../../../types';
|
|
3
3
|
export declare function VariableMention(variables: TemplateVariable[]): import('@tiptap/core').Node<MentionOptions<VariableMentionNodeAttrs, VariableMentionNodeAttrs>, any>;
|
|
4
|
+
//# sourceMappingURL=extension.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extension.d.ts","sourceRoot":"","sources":["../../../../src/components/inputs/variables/extension.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAShE,OAAO,KAAK,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAS1E,wBAAgB,eAAe,CAAC,SAAS,EAAE,gBAAgB,EAAE,wGA6B5D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extension.js","sources":["../../../../src/components/inputs/variables/extension.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"extension.js","sources":["../../../../src/components/inputs/variables/extension.ts"],"sourcesContent":["import type { VirtualElement } from '@floating-ui/dom';\nimport { computePosition, flip, shift } from '@floating-ui/dom';\nimport type { MentionOptions } from '@tiptap/extension-mention';\nimport Mention from '@tiptap/extension-mention';\nimport type { Attribute, Editor } from '@tiptap/react';\nimport {\n posToDOMRect,\n ReactNodeViewRenderer,\n ReactRenderer,\n} from '@tiptap/react';\nimport type { SuggestionKeyDownProps } from '@tiptap/suggestion';\nimport type { TemplateVariable, VariableMentionNodeAttrs } from '@/types';\n\nimport { formatVariableLabel } from '@/utils/format';\nimport { isTagElement, isTemporalElement } from '@/utils/guards';\nimport { serializeICUMessage } from '@/utils/icu-tranform';\nimport { VariableChip } from './VariableChip';\nimport type { VariableSuggestionProps } from './VariableSuggestion';\nimport { VariableSuggestion } from './VariableSuggestion';\n\nexport function VariableMention(variables: TemplateVariable[]) {\n return Mention.extend<\n MentionOptions<VariableMentionNodeAttrs, VariableMentionNodeAttrs>\n >({\n name: 'variable',\n addNodeView: () => ReactNodeViewRenderer(VariableChip),\n addAttributes: () =>\n ({\n name: { default: null },\n icu: { default: null },\n label: { default: null },\n }) satisfies Record<keyof VariableMentionNodeAttrs, Attribute>,\n renderText: ({ node }) => node.attrs.icu,\n }).configure({\n HTMLAttributes: {\n class: 'variable',\n },\n suggestions: [\n createSuggestion('@', variables),\n createSuggestion(\n '{',\n variables.filter((variable) => !isTagElement(variable)),\n ),\n createSuggestion(\n '<',\n variables.filter((variable) => isTagElement(variable)),\n ),\n ],\n });\n}\n\nfunction createSuggestion(\n char: string,\n variables: TemplateVariable[],\n): MentionOptions<\n VariableMentionNodeAttrs,\n VariableMentionNodeAttrs\n>['suggestion'] {\n const items = variables.map((variable) => ({\n name: variable.value,\n label: formatVariableLabel(variable),\n icu: serializeICUMessage([variable]),\n }));\n\n function updatePosition(editor: Editor, element: HTMLElement): void {\n const virtualElement: VirtualElement = {\n getBoundingClientRect: () =>\n posToDOMRect(\n editor.view,\n editor.state.selection.from,\n editor.state.selection.to,\n ),\n };\n\n void computePosition(virtualElement, element, {\n placement: 'bottom-start',\n strategy: 'absolute',\n middleware: [shift(), flip()],\n }).then(({ x, y, strategy }) => {\n element.style.width = 'max-content';\n element.style.position = strategy;\n element.style.left = `${x}px`;\n element.style.top = `${y}px`;\n });\n }\n\n return {\n char,\n items: ({ query }) =>\n items.filter((item) =>\n item.name.toLowerCase().startsWith(query.toLowerCase()),\n ),\n render: () => {\n let component: ReactRenderer<\n { onKeyDown(props: SuggestionKeyDownProps): boolean },\n VariableSuggestionProps\n >;\n\n const scrollableElement = document.getElementById(\n 'messages-form-content',\n );\n\n return {\n onStart: (props) => {\n component = new ReactRenderer<\n { onKeyDown(props: SuggestionKeyDownProps): boolean },\n VariableSuggestionProps\n >(VariableSuggestion, {\n props,\n editor: props.editor,\n });\n\n if (!props.clientRect) return;\n\n scrollableElement!.style.overflow = 'hidden';\n\n const element = component.element;\n element.style.position = 'absolute';\n document.body.appendChild(element);\n\n updatePosition(props.editor, element);\n },\n\n onUpdate(props) {\n component.updateProps(props);\n\n if (!props.clientRect) return;\n\n updatePosition(props.editor, component.element);\n },\n\n onKeyDown(props) {\n if (props.event.key === 'Escape') {\n component.destroy();\n return true;\n }\n if (!component.ref) return false;\n\n return component.ref.onKeyDown(props);\n },\n\n onExit() {\n component.element.remove();\n component.destroy();\n scrollableElement!.style.overflow = '';\n },\n };\n },\n };\n}\n"],"names":["VariableMention","variables","Mention","ReactNodeViewRenderer","VariableChip","node","createSuggestion","variable","isTagElement","char","items","formatVariableLabel","serializeICUMessage","updatePosition","editor","element","computePosition","posToDOMRect","shift","flip","x","y","strategy","query","item","component","scrollableElement","props","ReactRenderer","VariableSuggestion"],"mappings":";;;;;;;;AAoBO,SAASA,EAAgBC,GAA+B;AAC7D,SAAOC,EAAQ,OAEb;AAAA,IACA,MAAM;AAAA,IACN,aAAa,MAAMC,EAAsBC,CAAY;AAAA,IACrD,eAAe,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AAC;AAAA,IAC1B,CAAC;AAAA,EACH;AAEA,SAAO;AAAA,IACL,MAAAZ;AAAA,IACA,OAAO,CAAC,EAAE,OAAAc,EAAA,MACRb,EAAM;AAAA,MAAO,CAACc,MACZA,EAAK,KAAK,cAAc,WAAWD,EAAM,YAAA,CAAa;AAAA,IAAA;AAAA,IAE1D,QAAQ,MAAM;AACZ,UAAIE;AAKJ,YAAMC,IAAoB,SAAS;AAAA,QACjC;AAAA,MAAA;AAGF,aAAO;AAAA,QACL,SAAS,CAACC,MAAU;AASlB,cARAF,IAAY,IAAIG,EAGdC,GAAoB;AAAA,YACpB,OAAAF;AAAA,YACA,QAAQA,EAAM;AAAA,UAAA,CACf,GAEG,CAACA,EAAM,WAAY;AAEvB,UAAAD,EAAmB,MAAM,WAAW;AAEpC,gBAAMX,IAAUU,EAAU;AAC1B,UAAAV,EAAQ,MAAM,WAAW,YACzB,SAAS,KAAK,YAAYA,CAAO,GAEjCF,EAAec,EAAM,QAAQZ,CAAO;AAAA,QACtC;AAAA,QAEA,SAASY,GAAO;AAGd,UAFAF,EAAU,YAAYE,CAAK,GAEtBA,EAAM,cAEXd,EAAec,EAAM,QAAQF,EAAU,OAAO;AAAA,QAChD;AAAA,QAEA,UAAUE,GAAO;AACf,iBAAIA,EAAM,MAAM,QAAQ,YACtBF,EAAU,QAAA,GACH,MAEJA,EAAU,MAERA,EAAU,IAAI,UAAUE,CAAK,IAFT;AAAA,QAG7B;AAAA,QAEA,SAAS;AACP,UAAAF,EAAU,QAAQ,OAAA,GAClBA,EAAU,QAAA,GACVC,EAAmB,MAAM,WAAW;AAAA,QACtC;AAAA,MAAA;AAAA,IAEJ;AAAA,EAAA;AAEJ;"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { NumberElement, PluralElement } from '../../../../types
|
|
1
|
+
import { NumberElement, PluralElement } from '../../../../types';
|
|
2
2
|
export interface NumericVariablePickerProps {
|
|
3
3
|
element: NumberElement | PluralElement;
|
|
4
4
|
onUpdate: (value: string) => void;
|
|
5
5
|
}
|
|
6
6
|
export declare function NumericVariablePicker({ element, onUpdate, }: NumericVariablePickerProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
//# sourceMappingURL=NumericVariablePicker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NumericVariablePicker.d.ts","sourceRoot":"","sources":["../../../../../src/components/inputs/variables/pickers/NumericVariablePicker.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAc5D,MAAM,WAAW,0BAA0B;IACzC,OAAO,EAAE,aAAa,GAAG,aAAa,CAAC;IACvC,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACnC;AAED,wBAAgB,qBAAqB,CAAC,EACpC,OAAO,EACP,QAAQ,GACT,EAAE,0BAA0B,2CA8C5B"}
|
|
@@ -22,15 +22,15 @@ function E({
|
|
|
22
22
|
/* @__PURE__ */ a(
|
|
23
23
|
l.Root,
|
|
24
24
|
{
|
|
25
|
-
type: "single",
|
|
26
25
|
className: "flex bg-elevation-100",
|
|
27
26
|
onValueChange: (r) => u(r),
|
|
27
|
+
type: "single",
|
|
28
28
|
value: o,
|
|
29
29
|
children: v.map((r) => /* @__PURE__ */ a(
|
|
30
30
|
l.Item,
|
|
31
31
|
{
|
|
32
|
+
className: "flex-1 border-none data-[state=off]:cursor-pointer data-[state=on]:bg-elevation-800 data-[state=on]:text-elevation-0 data-[state=off]:opacity-50 data-[state=off]:hover:opacity-100",
|
|
32
33
|
value: r,
|
|
33
|
-
className: "flex-1 border-none data-[state=off]:cursor-pointer data-[state=off]:opacity-50 data-[state=off]:hover:opacity-100 data-[state=on]:bg-elevation-800 data-[state=on]:text-elevation-0",
|
|
34
34
|
children: r
|
|
35
35
|
},
|
|
36
36
|
r
|
|
@@ -40,9 +40,9 @@ function E({
|
|
|
40
40
|
/* @__PURE__ */ a("div", { className: "p-3", children: o === "plural" && /* @__PURE__ */ a(
|
|
41
41
|
d,
|
|
42
42
|
{
|
|
43
|
-
variableName: e.value,
|
|
44
43
|
element: i(e) ? e : void 0,
|
|
45
|
-
ref: t
|
|
44
|
+
ref: t,
|
|
45
|
+
variableName: e.value
|
|
46
46
|
}
|
|
47
47
|
) })
|
|
48
48
|
] });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NumericVariablePicker.js","sources":["../../../../../src/components/inputs/variables/pickers/NumericVariablePicker.tsx"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"NumericVariablePicker.js","sources":["../../../../../src/components/inputs/variables/pickers/NumericVariablePicker.tsx"],"sourcesContent":["import { ToggleGroup } from 'radix-ui';\nimport { useEffect, useRef, useState } from 'react';\nimport type { NumberElement, PluralElement } from '@/types';\n\nimport { isNumberElement, isPluralElement } from '@/utils/guards';\n\nimport { PluralVariableEditor } from '../editors/PluralVariableEditor';\n\nconst NUMERIC_TYPES = [\n 'number',\n 'plural',\n // \"selectordinal\"\n] as const;\n\ntype NumericType = (typeof NUMERIC_TYPES)[number];\n\nexport interface NumericVariablePickerProps {\n element: NumberElement | PluralElement;\n onUpdate: (value: string) => void;\n}\n\nexport function NumericVariablePicker({\n element,\n onUpdate,\n}: NumericVariablePickerProps) {\n const [type, setType] = useState<NumericType | undefined>(() => {\n if (isNumberElement(element)) return 'number';\n if (isPluralElement(element)) return 'plural';\n return undefined;\n });\n const getValueRef = useRef<{ getValue: () => string }>(null);\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: useEffectEvent\n useEffect(() => {\n return () => {\n if (!getValueRef.current) return;\n onUpdate(getValueRef.current.getValue());\n };\n }, []);\n\n return (\n <div className=\"\">\n <ToggleGroup.Root\n className=\"flex bg-elevation-100\"\n onValueChange={(value) => setType(value as NumericType)}\n type=\"single\"\n value={type}\n >\n {NUMERIC_TYPES.map((type) => (\n <ToggleGroup.Item\n className=\"flex-1 border-none data-[state=off]:cursor-pointer data-[state=on]:bg-elevation-800 data-[state=on]:text-elevation-0 data-[state=off]:opacity-50 data-[state=off]:hover:opacity-100\"\n key={type}\n value={type}\n >\n {type}\n </ToggleGroup.Item>\n ))}\n </ToggleGroup.Root>\n\n <div className=\"p-3\">\n {type === 'plural' && (\n <PluralVariableEditor\n element={isPluralElement(element) ? element : undefined}\n ref={getValueRef}\n variableName={element.value}\n />\n )}\n </div>\n </div>\n );\n}\n"],"names":["NUMERIC_TYPES","NumericVariablePicker","element","onUpdate","type","setType","useState","isNumberElement","isPluralElement","getValueRef","useRef","useEffect","jsxs","jsx","ToggleGroup","value","PluralVariableEditor"],"mappings":";;;;;AAQA,MAAMA,IAAgB;AAAA,EACpB;AAAA,EACA;AAAA;AAEF;AASO,SAASC,EAAsB;AAAA,EACpC,SAAAC;AAAA,EACA,UAAAC;AACF,GAA+B;AAC7B,QAAM,CAACC,GAAMC,CAAO,IAAIC,EAAkC,MAAM;AAC9D,QAAIC,EAAgBL,CAAO,EAAG,QAAO;AACrC,QAAIM,EAAgBN,CAAO,EAAG,QAAO;AAAA,EAEvC,CAAC,GACKO,IAAcC,EAAmC,IAAI;AAG3D,SAAAC,EAAU,MACD,MAAM;AACX,IAAKF,EAAY,WACjBN,EAASM,EAAY,QAAQ,UAAU;AAAA,EACzC,GACC,CAAA,CAAE,GAGH,gBAAAG,EAAC,OAAA,EAAI,WAAU,IACb,UAAA;AAAA,IAAA,gBAAAC;AAAA,MAACC,EAAY;AAAA,MAAZ;AAAA,QACC,WAAU;AAAA,QACV,eAAe,CAACC,MAAUV,EAAQU,CAAoB;AAAA,QACtD,MAAK;AAAA,QACL,OAAOX;AAAA,QAEN,UAAAJ,EAAc,IAAI,CAACI,MAClB,gBAAAS;AAAA,UAACC,EAAY;AAAA,UAAZ;AAAA,YACC,WAAU;AAAA,YAEV,OAAOV;AAAAA,YAEN,UAAAA;AAAAA,UAAA;AAAA,UAHIA;AAAAA,QAAA,CAKR;AAAA,MAAA;AAAA,IAAA;AAAA,IAGH,gBAAAS,EAAC,OAAA,EAAI,WAAU,OACZ,gBAAS,YACR,gBAAAA;AAAA,MAACG;AAAA,MAAA;AAAA,QACC,SAASR,EAAgBN,CAAO,IAAIA,IAAU;AAAA,QAC9C,KAAKO;AAAA,QACL,cAAcP,EAAQ;AAAA,MAAA;AAAA,IAAA,EACxB,CAEJ;AAAA,EAAA,GACF;AAEJ;"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { DateElement, TimeElement } from '../../../../types
|
|
1
|
+
import { DateElement, TimeElement } from '../../../../types';
|
|
2
2
|
export interface TemporalElementEditorProps {
|
|
3
3
|
element: DateElement | TimeElement;
|
|
4
4
|
onUpdate: (value: string) => void;
|
|
5
5
|
}
|
|
6
6
|
export declare function TemporalElementEditor({ element, onUpdate, }: TemporalElementEditorProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
//# sourceMappingURL=TemporalElementEditor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TemporalElementEditor.d.ts","sourceRoot":"","sources":["../../../../../src/components/inputs/variables/pickers/TemporalElementEditor.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAWxD,MAAM,WAAW,0BAA0B;IACzC,OAAO,EAAE,WAAW,GAAG,WAAW,CAAC;IACnC,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACnC;AAED,wBAAgB,qBAAqB,CAAC,EACpC,OAAO,EACP,QAAQ,GACT,EAAE,0BAA0B,2CAqD5B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MessageSchema } from '../../types
|
|
1
|
+
import { MessageSchema } from '../../types';
|
|
2
2
|
interface MessageFieldProps {
|
|
3
3
|
schema: MessageSchema;
|
|
4
4
|
messageKey: string;
|
|
@@ -7,3 +7,4 @@ interface MessageFieldProps {
|
|
|
7
7
|
}
|
|
8
8
|
export declare function MessageField({ schema, messageKey, path, className, }: MessageFieldProps): React.ReactNode;
|
|
9
9
|
export {};
|
|
10
|
+
//# sourceMappingURL=MessageField.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MessageField.d.ts","sourceRoot":"","sources":["../../../src/components/layout/MessageField.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAO7C,UAAU,iBAAiB;IACzB,MAAM,EAAE,aAAa,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,YAAY,CAAC,EAC3B,MAAM,EACN,UAAU,EACV,IAAI,EACJ,SAAS,GACV,EAAE,iBAAiB,GAAG,KAAK,CAAC,SAAS,CA8CrC"}
|