@vielzeug/refine 1.3.1 → 1.4.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/dist/checkbox-group.cjs +7 -7
- package/dist/checkbox-group.cjs.map +1 -1
- package/dist/checkbox-group.js +35 -26
- package/dist/checkbox-group.js.map +1 -1
- package/dist/checkbox.cjs +3 -3
- package/dist/checkbox.cjs.map +1 -1
- package/dist/checkbox.js +24 -19
- package/dist/checkbox.js.map +1 -1
- package/dist/combobox.cjs +24 -24
- package/dist/combobox.cjs.map +1 -1
- package/dist/combobox.js +133 -129
- package/dist/combobox.js.map +1 -1
- package/dist/custom-elements.json +4227 -3725
- package/dist/headless/auto-resize.cjs +2 -0
- package/dist/headless/auto-resize.cjs.map +1 -0
- package/dist/headless/auto-resize.d.ts +29 -0
- package/dist/headless/auto-resize.d.ts.map +1 -0
- package/dist/headless/auto-resize.js +16 -0
- package/dist/headless/auto-resize.js.map +1 -0
- package/dist/headless/checkable.cjs +1 -1
- package/dist/headless/checkable.cjs.map +1 -1
- package/dist/headless/checkable.d.ts +25 -7
- package/dist/headless/checkable.d.ts.map +1 -1
- package/dist/headless/checkable.js +19 -14
- package/dist/headless/checkable.js.map +1 -1
- package/dist/headless/choice-field.cjs +1 -1
- package/dist/headless/choice-field.cjs.map +1 -1
- package/dist/headless/choice-field.d.ts +21 -0
- package/dist/headless/choice-field.d.ts.map +1 -1
- package/dist/headless/choice-field.js +27 -19
- package/dist/headless/choice-field.js.map +1 -1
- package/dist/headless/composer.cjs +2 -0
- package/dist/headless/composer.cjs.map +1 -0
- package/dist/headless/composer.d.ts +44 -0
- package/dist/headless/composer.d.ts.map +1 -0
- package/dist/headless/composer.js +21 -0
- package/dist/headless/composer.js.map +1 -0
- package/dist/headless/field-base.cjs +1 -1
- package/dist/headless/field-base.cjs.map +1 -1
- package/dist/headless/field-base.d.ts +97 -84
- package/dist/headless/field-base.d.ts.map +1 -1
- package/dist/headless/field-base.js +43 -32
- package/dist/headless/field-base.js.map +1 -1
- package/dist/headless/index.d.ts +3 -1
- package/dist/headless/index.d.ts.map +1 -1
- package/dist/headless/text-field.cjs +1 -1
- package/dist/headless/text-field.cjs.map +1 -1
- package/dist/headless/text-field.d.ts +40 -0
- package/dist/headless/text-field.d.ts.map +1 -1
- package/dist/headless/text-field.js +30 -25
- package/dist/headless/text-field.js.map +1 -1
- package/dist/headless.cjs +1 -1
- package/dist/headless.js +27 -25
- package/dist/index.cjs +1 -1
- package/dist/index.js +61 -60
- package/dist/input.cjs +9 -9
- package/dist/input.cjs.map +1 -1
- package/dist/input.js +49 -44
- package/dist/input.js.map +1 -1
- package/dist/inputs/checkbox/checkbox.d.ts +3 -0
- package/dist/inputs/checkbox/checkbox.d.ts.map +1 -1
- package/dist/inputs/combobox/combobox.d.ts +1 -0
- package/dist/inputs/combobox/combobox.d.ts.map +1 -1
- package/dist/inputs/combobox/combobox.types.d.ts +2 -0
- package/dist/inputs/combobox/combobox.types.d.ts.map +1 -1
- package/dist/inputs/index.d.ts +2 -0
- package/dist/inputs/index.d.ts.map +1 -1
- package/dist/inputs/input/input.d.ts.map +1 -1
- package/dist/inputs/message-composer/message-composer.css.cjs +2 -0
- package/dist/inputs/message-composer/message-composer.css.cjs.map +1 -0
- package/dist/inputs/message-composer/message-composer.css.js +6 -0
- package/dist/inputs/message-composer/message-composer.css.js.map +1 -0
- package/dist/inputs/message-composer/message-composer.d.ts +139 -0
- package/dist/inputs/message-composer/message-composer.d.ts.map +1 -0
- package/dist/inputs/shared/field-binding.cjs +1 -1
- package/dist/inputs/shared/field-binding.cjs.map +1 -1
- package/dist/inputs/shared/field-binding.d.ts +15 -0
- package/dist/inputs/shared/field-binding.d.ts.map +1 -1
- package/dist/inputs/shared/field-binding.js +4 -3
- package/dist/inputs/shared/field-binding.js.map +1 -1
- package/dist/inputs/shared/form-context.cjs.map +1 -1
- package/dist/inputs/shared/form-context.d.ts +6 -0
- package/dist/inputs/shared/form-context.d.ts.map +1 -1
- package/dist/inputs/shared/form-context.js.map +1 -1
- package/dist/inputs/textarea/textarea.d.ts.map +1 -1
- package/dist/message-composer.cjs +52 -0
- package/dist/message-composer.cjs.map +1 -0
- package/dist/message-composer.js +168 -0
- package/dist/message-composer.js.map +1 -0
- package/dist/ore/dist/base-element.cjs +1 -1
- package/dist/ore/dist/base-element.cjs.map +1 -1
- package/dist/ore/dist/base-element.js +13 -3
- package/dist/ore/dist/base-element.js.map +1 -1
- package/dist/ore/dist/forms/field.cjs +1 -1
- package/dist/ore/dist/forms/field.cjs.map +1 -1
- package/dist/ore/dist/forms/field.js +29 -22
- package/dist/ore/dist/forms/field.js.map +1 -1
- package/dist/ore/dist/runtime.cjs +1 -1
- package/dist/ore/dist/runtime.cjs.map +1 -1
- package/dist/ore/dist/runtime.js +3 -1
- package/dist/ore/dist/runtime.js.map +1 -1
- package/dist/radio-group.cjs +9 -9
- package/dist/radio-group.cjs.map +1 -1
- package/dist/radio-group.js +44 -38
- package/dist/radio-group.js.map +1 -1
- package/dist/radio.cjs +3 -3
- package/dist/radio.cjs.map +1 -1
- package/dist/radio.js +23 -24
- package/dist/radio.js.map +1 -1
- package/dist/refine.cjs +228 -178
- package/dist/refine.cjs.map +1 -1
- package/dist/refine.iife.js +228 -178
- package/dist/refine.iife.js.map +1 -1
- package/dist/refine.js +251 -201
- package/dist/refine.js.map +1 -1
- package/dist/select.cjs +31 -31
- package/dist/select.cjs.map +1 -1
- package/dist/select.js +125 -122
- package/dist/select.js.map +1 -1
- package/dist/shared/size-presets.cjs +1 -1
- package/dist/shared/size-presets.cjs.map +1 -1
- package/dist/shared/size-presets.d.ts +23 -0
- package/dist/shared/size-presets.d.ts.map +1 -1
- package/dist/shared/size-presets.js +17 -1
- package/dist/shared/size-presets.js.map +1 -1
- package/dist/switch.cjs +3 -3
- package/dist/switch.cjs.map +1 -1
- package/dist/switch.js +17 -18
- package/dist/switch.js.map +1 -1
- package/dist/textarea.cjs +15 -15
- package/dist/textarea.cjs.map +1 -1
- package/dist/textarea.js +64 -60
- package/dist/textarea.js.map +1 -1
- package/package.json +11 -3
|
@@ -15,7 +15,22 @@ export type CheckableBindingHandle = {
|
|
|
15
15
|
helperText: Readable<string>;
|
|
16
16
|
indeterminate?: Signal<boolean>;
|
|
17
17
|
labelId: string;
|
|
18
|
+
/** Reflects `aria-required` — there's no native form control here to carry a real `required` attribute. */
|
|
19
|
+
required?: Readable<boolean | undefined>;
|
|
18
20
|
};
|
|
21
|
+
/**
|
|
22
|
+
* `prop.string()` already reflects `error`'s raw value as an attribute, but that leaves the
|
|
23
|
+
* attribute present-but-empty (`error=""`) once set instead of removing it — this normalizes
|
|
24
|
+
* an empty error back to "no attribute at all". Shared by every text-field component
|
|
25
|
+
* (`ore-input`, `ore-textarea`, `ore-message-composer`) since `bind()`'s own `error` writer
|
|
26
|
+
* needs a derived getter, not the raw prop, to get that behavior.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```ts
|
|
30
|
+
* bind({ attr: { error: errorAttr(errorText), size: fCtxProps.size, variant: fCtxProps.variant } });
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare const errorAttr: (errorText: Readable<string>) => (() => string | undefined);
|
|
19
34
|
/**
|
|
20
35
|
* Applies the standard host bindings shared by all checkable components
|
|
21
36
|
* (checkbox, switch, radio).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field-binding.d.ts","sourceRoot":"","sources":["../../../src/inputs/shared/field-binding.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAIzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD;;;;GAIG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;IACzB,QAAQ,EAAE,QAAQ,CAAC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M,GAAG,SAAS,CAEhF,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,qBAAqB,GAChC,UAAU,QAAQ,CAAC,aAAa,GAAG,SAAS,CAAC,EAC7C,QAAQ,sBAAsB,EAC9B,MAAM,UAAU,GAAG,OAAO,GAAG,QAAQ,KACpC,IA0CF,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { bind as e } from "@vielzeug/ore";
|
|
2
2
|
//#region src/inputs/shared/field-binding.ts
|
|
3
|
-
var t = (t, n, r) => {
|
|
4
|
-
let { assistiveId: i, checked: a, disabled: o, errorText: s, handleClick: c, handleKeydown: l, helperText: u, indeterminate: d, labelId: f } = n;
|
|
3
|
+
var t = (e) => () => e.value || void 0, n = (t, n, r) => {
|
|
4
|
+
let { assistiveId: i, checked: a, disabled: o, errorText: s, handleClick: c, handleKeydown: l, helperText: u, indeterminate: d, labelId: f, required: p } = n;
|
|
5
5
|
e({
|
|
6
6
|
attr: {
|
|
7
7
|
...d !== void 0 && { indeterminate: d },
|
|
@@ -10,6 +10,7 @@ var t = (t, n, r) => {
|
|
|
10
10
|
ariaDisabled: () => o.value ? "true" : null,
|
|
11
11
|
ariaInvalid: () => s.value ? "true" : null,
|
|
12
12
|
ariaLabelledby: f,
|
|
13
|
+
ariaRequired: () => p?.value ? "true" : null,
|
|
13
14
|
checked: a,
|
|
14
15
|
role: r,
|
|
15
16
|
size: t,
|
|
@@ -27,6 +28,6 @@ var t = (t, n, r) => {
|
|
|
27
28
|
});
|
|
28
29
|
};
|
|
29
30
|
//#endregion
|
|
30
|
-
export {
|
|
31
|
+
export { n as applyCheckableBinding, t as errorAttr };
|
|
31
32
|
|
|
32
33
|
//# sourceMappingURL=field-binding.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field-binding.js","names":[],"sources":["../../../src/inputs/shared/field-binding.ts"],"sourcesContent":["import type { Readable, Signal } from '@vielzeug/ripple';\n\nimport { bind } from '@vielzeug/ore';\n\nimport type { ComponentSize } from '../../types';\n\n/**\n * Minimal shape of the handle returned by `createCheckable` that\n * `applyCheckableBinding` needs. Matches both checkbox (with `indeterminate`)\n * and switch (without).\n */\nexport type CheckableBindingHandle = {\n assistiveId: string;\n checked: Signal<boolean>;\n disabled: Readable<boolean>;\n errorText: Readable<string>;\n handleClick: (event: MouseEvent) => boolean;\n handleKeydown: (event: KeyboardEvent) => boolean;\n helperText: Readable<string>;\n indeterminate?: Signal<boolean>;\n labelId: string;\n};\n\n/**\n * Applies the standard host bindings shared by all checkable components\n * (checkbox, switch, radio).\n *\n * Wires `role`, all ARIA attributes, `checked`, `size`, `tabindex`, the\n * `is-checked`/`is-disabled` classes, and the `click`/`keydown` event handlers.\n *\n * Pass `handle.indeterminate` for components that need it (checkbox);\n * omit it for switch/radio.\n */\nexport const applyCheckableBinding = (\n fCtxSize: Readable<ComponentSize | undefined>,\n handle: CheckableBindingHandle,\n role: 'checkbox' | 'radio' | 'switch',\n): void => {\n const {
|
|
1
|
+
{"version":3,"file":"field-binding.js","names":[],"sources":["../../../src/inputs/shared/field-binding.ts"],"sourcesContent":["import type { Readable, Signal } from '@vielzeug/ripple';\n\nimport { bind } from '@vielzeug/ore';\n\nimport type { ComponentSize } from '../../types';\n\n/**\n * Minimal shape of the handle returned by `createCheckable` that\n * `applyCheckableBinding` needs. Matches both checkbox (with `indeterminate`)\n * and switch (without).\n */\nexport type CheckableBindingHandle = {\n assistiveId: string;\n checked: Signal<boolean>;\n disabled: Readable<boolean>;\n errorText: Readable<string>;\n handleClick: (event: MouseEvent) => boolean;\n handleKeydown: (event: KeyboardEvent) => boolean;\n helperText: Readable<string>;\n indeterminate?: Signal<boolean>;\n labelId: string;\n /** Reflects `aria-required` — there's no native form control here to carry a real `required` attribute. */\n required?: Readable<boolean | undefined>;\n};\n\n/**\n * `prop.string()` already reflects `error`'s raw value as an attribute, but that leaves the\n * attribute present-but-empty (`error=\"\"`) once set instead of removing it — this normalizes\n * an empty error back to \"no attribute at all\". Shared by every text-field component\n * (`ore-input`, `ore-textarea`, `ore-message-composer`) since `bind()`'s own `error` writer\n * needs a derived getter, not the raw prop, to get that behavior.\n *\n * @example\n * ```ts\n * bind({ attr: { error: errorAttr(errorText), size: fCtxProps.size, variant: fCtxProps.variant } });\n * ```\n */\nexport const errorAttr = (errorText: Readable<string>): (() => string | undefined) => {\n return () => errorText.value || undefined;\n};\n\n/**\n * Applies the standard host bindings shared by all checkable components\n * (checkbox, switch, radio).\n *\n * Wires `role`, all ARIA attributes, `checked`, `size`, `tabindex`, the\n * `is-checked`/`is-disabled` classes, and the `click`/`keydown` event handlers.\n *\n * Pass `handle.indeterminate` for components that need it (checkbox);\n * omit it for switch/radio.\n */\nexport const applyCheckableBinding = (\n fCtxSize: Readable<ComponentSize | undefined>,\n handle: CheckableBindingHandle,\n role: 'checkbox' | 'radio' | 'switch',\n): void => {\n const {\n assistiveId,\n checked,\n disabled,\n errorText,\n handleClick,\n handleKeydown,\n helperText,\n indeterminate,\n labelId,\n required,\n } = handle;\n\n bind({\n attr: {\n ...(indeterminate !== undefined && { indeterminate }),\n ariaChecked: () => {\n if (role === 'checkbox' && indeterminate?.value) return 'mixed';\n\n return checked.value ? 'true' : 'false';\n },\n ariaDescribedby: () => (errorText.value || helperText.value ? assistiveId : null),\n ariaDisabled: () => (disabled.value ? 'true' : null),\n ariaInvalid: () => (errorText.value ? 'true' : null),\n ariaLabelledby: labelId,\n ariaRequired: () => (required?.value ? 'true' : null),\n checked,\n role,\n size: fCtxSize,\n tabindex: () => (disabled.value ? undefined : 0),\n },\n class: () => ({\n 'is-checked': checked.value,\n 'is-disabled': disabled.value,\n ...(indeterminate !== undefined && { 'is-indeterminate': indeterminate.value }),\n }),\n on: {\n click: handleClick,\n keydown: handleKeydown,\n },\n });\n};\n"],"mappings":";;AAqCA,IAAa,KAAa,YACX,EAAU,SAAS,KAAA,GAarB,KACX,GACA,GACA,MACS;CACT,IAAM,EACJ,gBACA,YACA,aACA,cACA,gBACA,kBACA,eACA,kBACA,YACA,gBACE;CAEJ,EAAK;EACH,MAAM;GACJ,GAAI,MAAkB,KAAA,KAAa,EAAE,iBAAc;GACnD,mBACM,MAAS,cAAc,GAAe,QAAc,UAEjD,EAAQ,QAAQ,SAAS;GAElC,uBAAwB,EAAU,SAAS,EAAW,QAAQ,IAAc;GAC5E,oBAAqB,EAAS,QAAQ,SAAS;GAC/C,mBAAoB,EAAU,QAAQ,SAAS;GAC/C,gBAAgB;GAChB,oBAAqB,GAAU,QAAQ,SAAS;GAChD;GACA;GACA,MAAM;GACN,gBAAiB,EAAS,QAAQ,KAAA,IAAY;EAChD;EACA,cAAc;GACZ,cAAc,EAAQ;GACtB,eAAe,EAAS;GACxB,GAAI,MAAkB,KAAA,KAAa,EAAE,oBAAoB,EAAc,MAAM;EAC/E;EACA,IAAI;GACF,OAAO;GACP,SAAS;EACX;CACF,CAAC;AACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form-context.cjs","names":[],"sources":["../../../src/inputs/shared/form-context.ts"],"sourcesContent":["import { bind, createContext } from '@vielzeug/ore';\nimport { computed, type Readable } from '@vielzeug/ripple';\n\nimport type { ValidationTrigger } from '../../headless';\nimport type { ComponentSize, VisualVariant } from '../../types';\n\nexport type FormContext = {\n /** Whether all child fields are disabled */\n disabled: Readable<boolean>;\n /** Default size propagated to all child form fields */\n size: Readable<ComponentSize | undefined>;\n /**\n * When to validate child form controls:\n * - `'submit'` (default): only on form submit\n * - `'blur'`: validate each field when it loses focus\n * - `'change'`: validate on every value change\n * - `'input'`: validate on every input event\n */\n validateOn: Readable<ValidationTrigger>;\n /** Default variant propagated to all child form fields */\n variant: Readable<VisualVariant | undefined>;\n};\n\nexport const FORM_CTX = createContext<FormContext>('FormContext');\n\n// ── Prop resolver ─────────────────────────────────────────────────────────────\n\ntype FormContextResolvedProps = {\n disabled: Readable<boolean>;\n size: Readable<ComponentSize | undefined>;\n variant: Readable<VisualVariant | undefined>;\n};\n\n/**\n * Pure resolver: merges local prop signals with an optional `FormContext`.\n * Returns computed `disabled`, `size`, and `variant` signals without any\n * side-effects — suitable for unit testing and composition.\n */\nexport const mergeFormContext = (\n props: {\n disabled?: Readable<boolean | undefined> | Readable<boolean>;\n size?: Readable<string | undefined> | Readable<string>;\n variant?: Readable<string | undefined> | Readable<string>;\n },\n formCtx?: FormContext,\n): FormContextResolvedProps => ({\n disabled: computed(() => Boolean(props.disabled?.value) || Boolean(formCtx?.disabled?.value)),\n size: computed(\n (): ComponentSize | undefined => (props.size?.value ?? formCtx?.size?.value) as ComponentSize | undefined,\n ),\n variant: computed(\n (): VisualVariant | undefined => (props.variant?.value ?? formCtx?.variant?.value) as VisualVariant | undefined,\n ),\n});\n\n/**\n * Resolves form context props AND automatically reflects the computed `disabled`\n * state as a `disabled` attribute on the host element.\n *\n * The `use` prefix signals that calling this function performs a side-effect\n * (`bind()` on the current component's host) in addition to returning the\n * resolved props — a real composable, since `bind` resolves the active\n * component through implicit context rather than being passed in.\n *\n * Accepts `FormContext | undefined` directly — pass `inject(FORM_CTX)`.\n */\nexport const useFormContext = (\n props: Parameters<typeof mergeFormContext>[0],\n formCtx?: FormContext,\n): FormContextResolvedProps => {\n const resolved = mergeFormContext(props, formCtx);\n\n bind({\n attr: {\n disabled: () => (resolved.disabled.value ? '' : undefined),\n },\n });\n\n return resolved;\n};\n"],"mappings":"6DAuBA,IAAa,GAAA,EAAA,EAAA,cAAA,CAAsC,aAAa,EAenD,GACX,EAKA,KAC8B,CAC9B,UAAA,EAAA,EAAA,SAAA,KAAyB,EAAQ,EAAM,UAAU,OAAU,EAAQ,GAAS,UAAU,KAAM,EAC5F,MAAA,EAAA,EAAA,SAAA,KACoC,EAAM,MAAM,OAAS,GAAS,MAAM,KACxE,EACA,SAAA,EAAA,EAAA,SAAA,KACoC,EAAM,SAAS,OAAS,GAAS,SAAS,KAC9E,CACF,
|
|
1
|
+
{"version":3,"file":"form-context.cjs","names":[],"sources":["../../../src/inputs/shared/form-context.ts"],"sourcesContent":["import { bind, createContext } from '@vielzeug/ore';\nimport { computed, type Readable } from '@vielzeug/ripple';\n\nimport type { ValidationTrigger } from '../../headless';\nimport type { ComponentSize, VisualVariant } from '../../types';\n\nexport type FormContext = {\n /** Whether all child fields are disabled */\n disabled: Readable<boolean>;\n /** Default size propagated to all child form fields */\n size: Readable<ComponentSize | undefined>;\n /**\n * When to validate child form controls:\n * - `'submit'` (default): only on form submit\n * - `'blur'`: validate each field when it loses focus\n * - `'change'`: validate on every value change\n * - `'input'`: validate on every input event\n */\n validateOn: Readable<ValidationTrigger>;\n /** Default variant propagated to all child form fields */\n variant: Readable<VisualVariant | undefined>;\n};\n\nexport const FORM_CTX = createContext<FormContext>('FormContext');\n\n// ── Prop resolver ─────────────────────────────────────────────────────────────\n\ntype FormContextResolvedProps = {\n disabled: Readable<boolean>;\n size: Readable<ComponentSize | undefined>;\n variant: Readable<VisualVariant | undefined>;\n};\n\n/**\n * Pure resolver: merges local prop signals with an optional `FormContext`.\n * Returns computed `disabled`, `size`, and `variant` signals without any\n * side-effects — suitable for unit testing and composition.\n */\nexport const mergeFormContext = (\n props: {\n disabled?: Readable<boolean | undefined> | Readable<boolean>;\n size?: Readable<string | undefined> | Readable<string>;\n variant?: Readable<string | undefined> | Readable<string>;\n },\n formCtx?: FormContext,\n): FormContextResolvedProps => ({\n disabled: computed(() => Boolean(props.disabled?.value) || Boolean(formCtx?.disabled?.value)),\n size: computed(\n (): ComponentSize | undefined => (props.size?.value ?? formCtx?.size?.value) as ComponentSize | undefined,\n ),\n variant: computed(\n (): VisualVariant | undefined => (props.variant?.value ?? formCtx?.variant?.value) as VisualVariant | undefined,\n ),\n});\n\n/**\n * Resolves form context props AND automatically reflects the computed `disabled`\n * state as a `disabled` attribute on the host element.\n *\n * The `use` prefix signals that calling this function performs a side-effect\n * (`bind()` on the current component's host) in addition to returning the\n * resolved props — a real composable, since `bind` resolves the active\n * component through implicit context rather than being passed in.\n *\n * Accepts `FormContext | undefined` directly — pass `inject(FORM_CTX)`.\n *\n * `props` here is a field component's *own* full props object (from `setup(props)`), not a\n * narrowed struct — this reads `props.disabled`/`props.size`/`props.variant` off it directly,\n * by name. That's easy to miss when auditing a component: `props.variant` can look unused\n * (never appears as `props.variant` anywhere else in the file) purely because its only reader\n * is this call — grepping for `useFormContext(props` is the tell.\n */\nexport const useFormContext = (\n props: Parameters<typeof mergeFormContext>[0],\n formCtx?: FormContext,\n): FormContextResolvedProps => {\n const resolved = mergeFormContext(props, formCtx);\n\n bind({\n attr: {\n disabled: () => (resolved.disabled.value ? '' : undefined),\n },\n });\n\n return resolved;\n};\n"],"mappings":"6DAuBA,IAAa,GAAA,EAAA,EAAA,cAAA,CAAsC,aAAa,EAenD,GACX,EAKA,KAC8B,CAC9B,UAAA,EAAA,EAAA,SAAA,KAAyB,EAAQ,EAAM,UAAU,OAAU,EAAQ,GAAS,UAAU,KAAM,EAC5F,MAAA,EAAA,EAAA,SAAA,KACoC,EAAM,MAAM,OAAS,GAAS,MAAM,KACxE,EACA,SAAA,EAAA,EAAA,SAAA,KACoC,EAAM,SAAS,OAAS,GAAS,SAAS,KAC9E,CACF,GAmBa,GACX,EACA,IAC6B,CAC7B,IAAM,EAAW,EAAiB,EAAO,CAAO,EAQhD,OANA,EAAA,EAAA,KAAA,CAAK,CACH,KAAM,CACJ,aAAiB,EAAS,SAAS,MAAQ,GAAK,IAAA,EAClD,CACF,CAAC,EAEM,CACT"}
|
|
@@ -43,6 +43,12 @@ export declare const mergeFormContext: (props: {
|
|
|
43
43
|
* component through implicit context rather than being passed in.
|
|
44
44
|
*
|
|
45
45
|
* Accepts `FormContext | undefined` directly — pass `inject(FORM_CTX)`.
|
|
46
|
+
*
|
|
47
|
+
* `props` here is a field component's *own* full props object (from `setup(props)`), not a
|
|
48
|
+
* narrowed struct — this reads `props.disabled`/`props.size`/`props.variant` off it directly,
|
|
49
|
+
* by name. That's easy to miss when auditing a component: `props.variant` can look unused
|
|
50
|
+
* (never appears as `props.variant` anywhere else in the file) purely because its only reader
|
|
51
|
+
* is this call — grepping for `useFormContext(props` is the tell.
|
|
46
52
|
*/
|
|
47
53
|
export declare const useFormContext: (props: Parameters<typeof mergeFormContext>[0], formCtx?: FormContext) => FormContextResolvedProps;
|
|
48
54
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form-context.d.ts","sourceRoot":"","sources":["../../../src/inputs/shared/form-context.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,KAAK,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEhE,MAAM,MAAM,WAAW,GAAG;IACxB,4CAA4C;IAC5C,QAAQ,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC5B,uDAAuD;IACvD,IAAI,EAAE,QAAQ,CAAC,aAAa,GAAG,SAAS,CAAC,CAAC;IAC1C;;;;;;OAMG;IACH,UAAU,EAAE,QAAQ,CAAC,iBAAiB,CAAC,CAAC;IACxC,0DAA0D;IAC1D,OAAO,EAAE,QAAQ,CAAC,aAAa,GAAG,SAAS,CAAC,CAAC;CAC9C,CAAC;AAEF,eAAO,MAAM,QAAQ,mDAA4C,CAAC;AAIlE,KAAK,wBAAwB,GAAG;IAC9B,QAAQ,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC5B,IAAI,EAAE,QAAQ,CAAC,aAAa,GAAG,SAAS,CAAC,CAAC;IAC1C,OAAO,EAAE,QAAQ,CAAC,aAAa,GAAG,SAAS,CAAC,CAAC;CAC9C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,GAC3B,OAAO;IACL,QAAQ,CAAC,EAAE,QAAQ,CAAC,OAAO,GAAG,SAAS,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC7D,IAAI,CAA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O,CAAC,CAAC;IAC7D,IAAI,CAAC,EAAE,QAAQ,CAAC,MAAM,GAAG,SAAS,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC;IACvD,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,GAAG,SAAS,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC;CAC3D,EACD,UAAU,WAAW,KACpB,wBAQD,CAAC;AAEH;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,cAAc,GACzB,OAAO,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC,CAAC,CAAC,EAC7C,UAAU,WAAW,KACpB,wBAUF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form-context.js","names":[],"sources":["../../../src/inputs/shared/form-context.ts"],"sourcesContent":["import { bind, createContext } from '@vielzeug/ore';\nimport { computed, type Readable } from '@vielzeug/ripple';\n\nimport type { ValidationTrigger } from '../../headless';\nimport type { ComponentSize, VisualVariant } from '../../types';\n\nexport type FormContext = {\n /** Whether all child fields are disabled */\n disabled: Readable<boolean>;\n /** Default size propagated to all child form fields */\n size: Readable<ComponentSize | undefined>;\n /**\n * When to validate child form controls:\n * - `'submit'` (default): only on form submit\n * - `'blur'`: validate each field when it loses focus\n * - `'change'`: validate on every value change\n * - `'input'`: validate on every input event\n */\n validateOn: Readable<ValidationTrigger>;\n /** Default variant propagated to all child form fields */\n variant: Readable<VisualVariant | undefined>;\n};\n\nexport const FORM_CTX = createContext<FormContext>('FormContext');\n\n// ── Prop resolver ─────────────────────────────────────────────────────────────\n\ntype FormContextResolvedProps = {\n disabled: Readable<boolean>;\n size: Readable<ComponentSize | undefined>;\n variant: Readable<VisualVariant | undefined>;\n};\n\n/**\n * Pure resolver: merges local prop signals with an optional `FormContext`.\n * Returns computed `disabled`, `size`, and `variant` signals without any\n * side-effects — suitable for unit testing and composition.\n */\nexport const mergeFormContext = (\n props: {\n disabled?: Readable<boolean | undefined> | Readable<boolean>;\n size?: Readable<string | undefined> | Readable<string>;\n variant?: Readable<string | undefined> | Readable<string>;\n },\n formCtx?: FormContext,\n): FormContextResolvedProps => ({\n disabled: computed(() => Boolean(props.disabled?.value) || Boolean(formCtx?.disabled?.value)),\n size: computed(\n (): ComponentSize | undefined => (props.size?.value ?? formCtx?.size?.value) as ComponentSize | undefined,\n ),\n variant: computed(\n (): VisualVariant | undefined => (props.variant?.value ?? formCtx?.variant?.value) as VisualVariant | undefined,\n ),\n});\n\n/**\n * Resolves form context props AND automatically reflects the computed `disabled`\n * state as a `disabled` attribute on the host element.\n *\n * The `use` prefix signals that calling this function performs a side-effect\n * (`bind()` on the current component's host) in addition to returning the\n * resolved props — a real composable, since `bind` resolves the active\n * component through implicit context rather than being passed in.\n *\n * Accepts `FormContext | undefined` directly — pass `inject(FORM_CTX)`.\n */\nexport const useFormContext = (\n props: Parameters<typeof mergeFormContext>[0],\n formCtx?: FormContext,\n): FormContextResolvedProps => {\n const resolved = mergeFormContext(props, formCtx);\n\n bind({\n attr: {\n disabled: () => (resolved.disabled.value ? '' : undefined),\n },\n });\n\n return resolved;\n};\n"],"mappings":";;;AAuBA,IAAa,IAAW,EAA2B,aAAa,GAenD,KACX,GAKA,OAC8B;CAC9B,UAAU,QAAe,EAAQ,EAAM,UAAU,SAAU,EAAQ,GAAS,UAAU,KAAM;CAC5F,MAAM,QAC8B,EAAM,MAAM,SAAS,GAAS,MAAM,KACxE;CACA,SAAS,QAC2B,EAAM,SAAS,SAAS,GAAS,SAAS,KAC9E;AACF,
|
|
1
|
+
{"version":3,"file":"form-context.js","names":[],"sources":["../../../src/inputs/shared/form-context.ts"],"sourcesContent":["import { bind, createContext } from '@vielzeug/ore';\nimport { computed, type Readable } from '@vielzeug/ripple';\n\nimport type { ValidationTrigger } from '../../headless';\nimport type { ComponentSize, VisualVariant } from '../../types';\n\nexport type FormContext = {\n /** Whether all child fields are disabled */\n disabled: Readable<boolean>;\n /** Default size propagated to all child form fields */\n size: Readable<ComponentSize | undefined>;\n /**\n * When to validate child form controls:\n * - `'submit'` (default): only on form submit\n * - `'blur'`: validate each field when it loses focus\n * - `'change'`: validate on every value change\n * - `'input'`: validate on every input event\n */\n validateOn: Readable<ValidationTrigger>;\n /** Default variant propagated to all child form fields */\n variant: Readable<VisualVariant | undefined>;\n};\n\nexport const FORM_CTX = createContext<FormContext>('FormContext');\n\n// ── Prop resolver ─────────────────────────────────────────────────────────────\n\ntype FormContextResolvedProps = {\n disabled: Readable<boolean>;\n size: Readable<ComponentSize | undefined>;\n variant: Readable<VisualVariant | undefined>;\n};\n\n/**\n * Pure resolver: merges local prop signals with an optional `FormContext`.\n * Returns computed `disabled`, `size`, and `variant` signals without any\n * side-effects — suitable for unit testing and composition.\n */\nexport const mergeFormContext = (\n props: {\n disabled?: Readable<boolean | undefined> | Readable<boolean>;\n size?: Readable<string | undefined> | Readable<string>;\n variant?: Readable<string | undefined> | Readable<string>;\n },\n formCtx?: FormContext,\n): FormContextResolvedProps => ({\n disabled: computed(() => Boolean(props.disabled?.value) || Boolean(formCtx?.disabled?.value)),\n size: computed(\n (): ComponentSize | undefined => (props.size?.value ?? formCtx?.size?.value) as ComponentSize | undefined,\n ),\n variant: computed(\n (): VisualVariant | undefined => (props.variant?.value ?? formCtx?.variant?.value) as VisualVariant | undefined,\n ),\n});\n\n/**\n * Resolves form context props AND automatically reflects the computed `disabled`\n * state as a `disabled` attribute on the host element.\n *\n * The `use` prefix signals that calling this function performs a side-effect\n * (`bind()` on the current component's host) in addition to returning the\n * resolved props — a real composable, since `bind` resolves the active\n * component through implicit context rather than being passed in.\n *\n * Accepts `FormContext | undefined` directly — pass `inject(FORM_CTX)`.\n *\n * `props` here is a field component's *own* full props object (from `setup(props)`), not a\n * narrowed struct — this reads `props.disabled`/`props.size`/`props.variant` off it directly,\n * by name. That's easy to miss when auditing a component: `props.variant` can look unused\n * (never appears as `props.variant` anywhere else in the file) purely because its only reader\n * is this call — grepping for `useFormContext(props` is the tell.\n */\nexport const useFormContext = (\n props: Parameters<typeof mergeFormContext>[0],\n formCtx?: FormContext,\n): FormContextResolvedProps => {\n const resolved = mergeFormContext(props, formCtx);\n\n bind({\n attr: {\n disabled: () => (resolved.disabled.value ? '' : undefined),\n },\n });\n\n return resolved;\n};\n"],"mappings":";;;AAuBA,IAAa,IAAW,EAA2B,aAAa,GAenD,KACX,GAKA,OAC8B;CAC9B,UAAU,QAAe,EAAQ,EAAM,UAAU,SAAU,EAAQ,GAAS,UAAU,KAAM;CAC5F,MAAM,QAC8B,EAAM,MAAM,SAAS,GAAS,MAAM,KACxE;CACA,SAAS,QAC2B,EAAM,SAAS,SAAS,GAAS,SAAS,KAC9E;AACF,IAmBa,KACX,GACA,MAC6B;CAC7B,IAAM,IAAW,EAAiB,GAAO,CAAO;CAQhD,OANA,EAAK,EACH,MAAM,EACJ,gBAAiB,EAAS,SAAS,QAAQ,KAAK,KAAA,EAClD,EACF,CAAC,GAEM;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"textarea.d.ts","sourceRoot":"","sources":["../../../src/inputs/textarea/textarea.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"textarea.d.ts","sourceRoot":"","sources":["../../../src/inputs/textarea/textarea.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AASjD,oCAAoC;AAEpC,MAAM,MAAM,iBAAiB,GAAG;IAC9B,MAAM,EAAE;QAAE,aAAa,EAAE,KAAK,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAChD,KAAK,EAAE;QAAE,aAAa,EAAE,KAAK,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;CAChD,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,cAAc,CAAC,OAAO,CAAC,aAAa,EAAE,OAAO,GAAG,MAAM,CAAC,CAAC,GAAG;IACxF,mCAAmC;IACnC,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,wDAAwD;IACxD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,qCAAqC;IACrC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;;;OAKG;IACH,GAAG,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,mBAAmB,GAAG,IAAI,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC;IACxD,gCAAgC;IAChC,MAAM,CAAC,EAAE,MAAM,GAAG,YAAY,GAAG,MAAM,GAAG,UAAU,CAAC;IACrD,kCAAkC;IAClC,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,eAAO,MAAM,YAAY,EAAG,cAAuB,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./ore/dist/directives/live.cjs");require("./ore/dist/directives.cjs");const t=require("./styles/mixins/accessibility.css.cjs"),n=require("./styles/mixins/shape.css.cjs"),r=require("./styles/mixins/states.css.cjs"),i=require("./styles/mixins/theme.css.cjs"),a=require("./shared/prop-bundles.cjs"),o=require("./shared/size-presets.cjs"),s=require("./headless/ore.cjs"),c=require("./headless/auto-resize.cjs"),l=require("./headless/field-base.cjs"),u=require("./headless/text-field.cjs"),d=require("./headless/composer.cjs"),f=require("./ore/dist/forms/field.cjs");require("./ore/dist/forms.cjs");const p=require("./inputs/shared/field-binding.cjs"),m=require("./inputs/shared/form-context.cjs"),h=require("./inputs/message-composer/message-composer.css.cjs");let g=require("@vielzeug/ore"),_=require("@vielzeug/ripple");var v=`Send message`,y=`arrow-up`,b=`ore-message-composer`;(0,g.define)(b,{formAssociated:!0,props:{...a.themableBundle,...a.sizableBundle,...a.disablableBundle,...a.loadableBundle,"clear-on-send":g.prop.bool(!0),error:g.prop.string(),fullwidth:g.prop.bool(!1),helper:g.prop.string(),label:g.prop.string(),maxlength:g.prop.json(void 0),name:g.prop.string(),placeholder:g.prop.string(),readonly:g.prop.bool(!1),ref:g.prop.json(void 0),required:g.prop.bool(!1),rows:g.prop.json(void 0),"send-icon":g.prop.string(),"send-label":g.prop.string(),"send-shortcut":g.prop.oneOf([`enter`,`mod+enter`],`enter`),value:g.prop.string(),variant:g.prop.string()},setup(t){let n=(0,g.useEmit)(),r=(0,g.useSlots)(),i=(0,g.inject)(m.FORM_CTX),a=m.useFormContext(t,i),o=a.disabled,h=s.lifecycleSignal(g.onCleanup),b=(0,g.ref)(),x=c.createAutoResize(),S=u.createTextField({disabled:o,error:t.error,helper:t.helper,maxLength:t.maxlength,onInput:(e,t)=>n(`input`,{originalEvent:e,value:t}),prefix:`composer`,readonly:t.readonly,required:t.required,signal:h,validateOn:i?.validateOn,value:t.value});S.attachFormField(f.useField({disabled:S.disabled,onReset:()=>{S.reset(),x.recompute()},toFormValue:e=>e,validationMessage:S.validationMessage,validity:S.validity,value:S.value}));function C(e){n(`send`,{originalEvent:e,value:S.value.value.trim()})&&t[`clear-on-send`].value!==!1&&(S.clear(),x.recompute(),b.value?.focus())}let w=d.createComposerControl({disabled:o,loading:(0,_.computed)(()=>!!t.loading.value),onSend:C,sendShortcut:t[`send-shortcut`],value:S.value});return(0,g.onElement)(b,e=>{let n=S.wire(e),r=x.wire(e),i=e=>w.handleKeydown(e);e.addEventListener(`keydown`,i),t.ref.value?.(e);let a=(0,_.watch)(t.ref,t=>{t?.(e)});return()=>{e.removeEventListener(`keydown`,i),n(),r(),a.dispose(),t.ref.value?.(null)}}),(0,g.bind)({attr:{error:p.errorAttr(S.errorText),size:a.size,variant:a.variant}}),g.html`
|
|
2
|
+
<div class="composer" part="composer">
|
|
3
|
+
<textarea
|
|
4
|
+
class="field"
|
|
5
|
+
part="field"
|
|
6
|
+
ref="${b}"
|
|
7
|
+
:rows="${()=>t.rows.value??1}"
|
|
8
|
+
:name="${()=>t.name.value??``}"
|
|
9
|
+
:placeholder="${()=>t.placeholder.value??`Message…`}"
|
|
10
|
+
:maxlength="${()=>t.maxlength.value}"
|
|
11
|
+
?disabled="${o}"
|
|
12
|
+
?readonly="${()=>!!t.readonly.value}"
|
|
13
|
+
?required="${()=>!!t.required.value}"
|
|
14
|
+
:value="${e.live(S.value)}"
|
|
15
|
+
:aria-label="${()=>t.label.value||`Message`}"
|
|
16
|
+
:aria-keyshortcuts="${w.keyShortcutsHint}"
|
|
17
|
+
:aria-describedby="${S.ariaDescribedBy}"
|
|
18
|
+
:aria-errormessage="${S.ariaErrorMessage}"
|
|
19
|
+
:aria-invalid="${S.ariaInvalid}"></textarea>
|
|
20
|
+
<span class="${()=>l.counterClassName(S.counter?.value)}" aria-live="polite" ?hidden="${()=>!S.counter}">${()=>S.counter?.value.counterText.replace(` / `,`/`)??``}</span>
|
|
21
|
+
<div id="${S.assistiveId}" class="helper-text" aria-live="polite" part="helper" ?hidden="${()=>!!S.errorText.value||!S.helperText.value}">
|
|
22
|
+
${()=>S.helperText.value}
|
|
23
|
+
</div>
|
|
24
|
+
<div id="${S.errorId}" class="helper-text" role="alert" part="error" ?hidden="${()=>!S.errorText.value}">
|
|
25
|
+
${()=>S.errorText.value}
|
|
26
|
+
</div>
|
|
27
|
+
<div class="toolbar" part="toolbar">
|
|
28
|
+
<div class="toolbar-start" part="toolbar-start">
|
|
29
|
+
<slot name="prefix"></slot>
|
|
30
|
+
</div>
|
|
31
|
+
<div class="toolbar-end" part="toolbar-end">
|
|
32
|
+
<slot name="suffix"></slot>
|
|
33
|
+
<slot name="send"></slot>
|
|
34
|
+
${()=>r.has(`send`).value?``:g.html`<ore-button
|
|
35
|
+
class="send-btn"
|
|
36
|
+
part="send-button"
|
|
37
|
+
type="button"
|
|
38
|
+
icon-only
|
|
39
|
+
variant="solid"
|
|
40
|
+
:color="${()=>t.color.value||`primary`}"
|
|
41
|
+
:size="${a.size}"
|
|
42
|
+
:label="${()=>t[`send-label`].value||v}"
|
|
43
|
+
?loading="${()=>!!t.loading.value}"
|
|
44
|
+
?disabled="${()=>!w.canSend.value}"
|
|
45
|
+
@click="${e=>w.send(e)}">
|
|
46
|
+
<ore-icon name="${()=>t[`send-icon`].value||y}" size="16"></ore-icon>
|
|
47
|
+
</ore-button>`}
|
|
48
|
+
</div>
|
|
49
|
+
</div>
|
|
50
|
+
</div>
|
|
51
|
+
`},shadow:{delegatesFocus:!0},styles:[i.colorThemeMixin,t.coarsePointerMixin,t.reducedMotionMixin,r.disabledLoadingMixin,i.forcedColorsMixin,i.forcedColorsFocusMixin(`.field`),n.sizeVariantMixin(o.MESSAGE_COMPOSER_SIZE_PRESET),h.default]}),exports.MESSAGE_COMPOSER_TAG=b;
|
|
52
|
+
//# sourceMappingURL=message-composer.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message-composer.cjs","names":[],"sources":["../src/inputs/message-composer/message-composer.ts"],"sourcesContent":["import { define, html, inject, prop, ref, bind, onCleanup, onElement, useEmit, useSlots } from '@vielzeug/ore';\nimport { live } from '@vielzeug/ore/directives';\nimport { useField } from '@vielzeug/ore/forms';\nimport { computed, watch } from '@vielzeug/ripple';\n\nimport type { ComponentSize, ThemeColor, VisualVariant } from '../../types';\n\nimport {\n counterClassName,\n createAutoResize,\n createComposerControl,\n createTextField,\n lifecycleSignal,\n type SendShortcut,\n} from '../../headless';\nimport {\n disablableBundle,\n loadableBundle,\n MESSAGE_COMPOSER_SIZE_PRESET,\n sizableBundle,\n themableBundle,\n} from '../../shared';\nimport {\n colorThemeMixin,\n coarsePointerMixin,\n disabledLoadingMixin,\n forcedColorsFocusMixin,\n forcedColorsMixin,\n reducedMotionMixin,\n sizeVariantMixin,\n} from '../../styles';\nimport { errorAttr } from '../shared/field-binding';\nimport { FORM_CTX, useFormContext } from '../shared/form-context';\nimport '../../content/icon/icon';\nimport '../button/button';\nimport componentStyles from './message-composer.css?inline';\n\nexport type { SendShortcut } from '../../headless';\n\nconst DEFAULT_SEND_LABEL = 'Send message';\nconst SEND_ICON = 'arrow-up';\n\n/** Events emitted by the message composer */\nexport type OreMessageComposerEvents = {\n /** Fired on every keystroke with the current value. */\n input: { originalEvent: Event; value: string };\n /**\n * Fired for a send attempt (the resolved `send-shortcut` or the send button) while the\n * composer isn't blank/disabled/loading. Cancelable — call `preventDefault()` to keep the\n * current text in the field instead of the default clear + refocus.\n */\n send: { originalEvent: KeyboardEvent | MouseEvent; value: string };\n};\n\n/** Message composer properties */\nexport type OreMessageComposerProps = {\n /** Clear the value and refocus after a non-cancelled `send` (default `true`) */\n 'clear-on-send'?: boolean;\n /** Theme color (card focus ring + default send button color) */\n color?: ThemeColor;\n /** Disable the whole composer (field, slots, and send action) */\n disabled?: boolean;\n /** Error message shown below the field */\n error?: string;\n /** Stretch the composer to the full width of its container */\n fullwidth?: boolean;\n /** Helper text shown below the field */\n helper?: string;\n /** Accessible name for the field — never rendered visually, only as `aria-label` */\n label?: string;\n /** Blocks further sends (e.g. a send is already in flight) without disabling editing */\n loading?: boolean;\n /** Maximum character count; shows a counter */\n maxlength?: number;\n /** Form field name */\n name?: string;\n /** Placeholder text */\n placeholder?: string;\n /** Make the field read-only */\n readonly?: boolean;\n /**\n * JS-only callback fired with the inner `<textarea>` element when it mounts, and with\n * `null` when it unmounts. Set as a JS property: `composer.ref = (el) => { ... }`.\n */\n ref?: ((el: HTMLTextAreaElement | null) => void) | null;\n /** Require a non-blank value for `<ore-form>` validation */\n required?: boolean;\n /** Number of visible rows before auto-resize grows the field */\n rows?: number;\n /** Lucide icon name for the default send button (default `'arrow-up'`) */\n 'send-icon'?: string;\n /** Accessible label for the send button (default `'Send message'`) */\n 'send-label'?: string;\n /** Keyboard shortcut that sends: 'enter' (Shift+Enter for a newline) or 'mod+enter' (Enter always inserts a newline; Ctrl/Cmd+Enter sends) */\n 'send-shortcut'?: SendShortcut;\n /** Component size */\n size?: ComponentSize;\n /** Current text value */\n value?: string;\n /** Visual variant of the card — same variant set as `ore-textarea`, applied to the card. */\n variant?: Exclude<VisualVariant, 'frost' | 'text'>;\n};\n\n/**\n * A message/comment composer — a card with an auto-resizing field on top and a toolbar row\n * below it, built directly on the same headless primitives as `ore-textarea` (`createTextField`,\n * `createAutoResize`) rather than composing `ore-textarea` itself. Nesting a fully-styled sibling\n * component and suppressing most of its chrome (as an earlier version of this component did) is\n * a leaky composition — this owns its single `<textarea>` outright, so there's exactly one\n * implementation of the field's appearance to reason about, not two fighting each other.\n *\n * Handles the send gesture (Enter to send, Shift+Enter for a newline, or a Ctrl/Cmd+Enter\n * alternative), IME-safe composition, and clear-and-refocus after sending.\n *\n * @element ore-message-composer\n *\n * @attr {string} value - Current text value\n * @attr {string} placeholder - Placeholder text\n * @attr {string} label - Accessible name for the field (not rendered visually)\n * @attr {string} name - Form field name\n * @attr {string} helper - Helper text shown below the field\n * @attr {string} error - Error message shown below the field\n * @attr {boolean} disabled - Disable the whole composer\n * @attr {boolean} readonly - Read-only mode\n * @attr {boolean} required - Require a non-blank value for `<ore-form>` validation\n * @attr {boolean} loading - Blocks further sends without disabling editing\n * @attr {number} maxlength - Max character count; shows a counter\n * @attr {number} rows - Visible rows before auto-resize grows the field (default 1)\n * @attr {string} color - Theme color: 'primary' | 'secondary' | 'info' | 'success' | 'warning' | 'error'\n * @attr {string} variant - Visual variant of the card: 'solid' | 'flat' | 'bordered' | 'outline' | 'ghost'\n * @attr {string} size - 'sm' | 'md' | 'lg'\n * @attr {boolean} fullwidth - Stretch to the full width of the container\n * @attr {string} send-icon - Lucide icon name for the default send button (default 'arrow-up')\n * @attr {string} send-label - Accessible label for the send button (default 'Send message')\n * @attr {string} send-shortcut - 'enter' (default) | 'mod+enter'\n * @attr {boolean} clear-on-send - Clear the value and refocus after a non-cancelled send (default true)\n *\n * @fires input - Fired on every keystroke. detail: { value, originalEvent }\n * @fires send - Fired on a send attempt. Cancelable. detail: { value, originalEvent }\n *\n * @slot prefix - Content at the start of the toolbar row (e.g. an attach menu)\n * @slot suffix - Content at the end of the toolbar row, before the send button (e.g. a model picker)\n * @slot send - Replaces the default send button entirely — the only supported way to customize it\n *\n * @cssprop --message-composer-bg - Card background color\n * @cssprop --message-composer-border-color - Card border color\n * @cssprop --message-composer-radius - Card border radius\n * @cssprop --message-composer-padding - Card inner padding\n * @cssprop --message-composer-gap - Gap between the field/toolbar rows and between toolbar items\n * @cssprop --message-composer-placeholder-color - Field placeholder text color\n * @cssprop --message-composer-min-height - Minimum field height (default one line)\n * @cssprop --message-composer-hover-bg - Card background on hover (flat/ghost variants)\n * @cssprop --message-composer-hover-border-color - Card border on hover (flat/bordered variants)\n * @cssprop --message-composer-focus-bg - Card background when focused (flat variant)\n * @cssprop --message-composer-focus-border-color - Card border when focused (flat variant)\n *\n * @part composer - Root card container\n * @part field - The native `<textarea>` element\n * @part helper - Helper text element\n * @part error - Error text element (`role=\"alert\"`)\n * @part toolbar - Toolbar row below the field\n * @part toolbar-start - Toolbar group holding the `prefix` slot\n * @part toolbar-end - Toolbar group holding the `suffix` slot and the send button\n * @part send-button - The default send button (absent when the `send` slot is used)\n *\n * @example\n * ```html\n * <ore-message-composer placeholder=\"Message…\" send-shortcut=\"mod+enter\"></ore-message-composer>\n * ```\n */\nexport const MESSAGE_COMPOSER_TAG = 'ore-message-composer' as const;\ndefine<OreMessageComposerProps>(MESSAGE_COMPOSER_TAG, {\n formAssociated: true,\n props: {\n ...themableBundle,\n ...sizableBundle,\n ...disablableBundle,\n ...loadableBundle,\n 'clear-on-send': prop.bool(true),\n error: prop.string(),\n fullwidth: prop.bool(false),\n helper: prop.string(),\n label: prop.string(),\n maxlength: prop.json(undefined as number | undefined),\n name: prop.string(),\n placeholder: prop.string(),\n readonly: prop.bool(false),\n ref: prop.json(undefined as ((el: HTMLTextAreaElement | null) => void) | null | undefined),\n required: prop.bool(false),\n rows: prop.json(undefined as number | undefined),\n 'send-icon': prop.string(),\n 'send-label': prop.string(),\n 'send-shortcut': prop.oneOf(['enter', 'mod+enter'] as const, 'enter'),\n value: prop.string(),\n variant: prop.string<Exclude<VisualVariant, 'frost' | 'text'>>(),\n },\n setup(props) {\n const emit = useEmit<OreMessageComposerEvents>();\n const slots = useSlots<'prefix' | 'send' | 'suffix'>();\n\n const formCtx = inject(FORM_CTX);\n const fCtxProps = useFormContext(props, formCtx);\n const isDisabled = fCtxProps.disabled;\n\n const abortSignal = lifecycleSignal(onCleanup);\n const textareaRef = ref<HTMLTextAreaElement>();\n const autoResize = createAutoResize();\n\n const tf = createTextField({\n disabled: isDisabled,\n error: props.error,\n helper: props.helper,\n maxLength: props.maxlength,\n onInput: (event, value) => emit('input', { originalEvent: event, value }),\n prefix: 'composer',\n readonly: props.readonly,\n required: props.required,\n signal: abortSignal,\n validateOn: formCtx?.validateOn,\n value: props.value,\n });\n\n // Directly form-associated now that the field is owned here rather than borrowed from a\n // nested `ore-textarea` (which previously registered with the ancestor `<form>` on this\n // component's behalf).\n tf.attachFormField(\n useField<string>({\n disabled: tf.disabled,\n onReset: () => {\n tf.reset();\n autoResize.recompute();\n },\n toFormValue: (v) => v,\n validationMessage: tf.validationMessage,\n validity: tf.validity,\n value: tf.value,\n }),\n );\n\n function attemptSend(event: KeyboardEvent | MouseEvent): void {\n const notPrevented = emit('send', { originalEvent: event, value: tf.value.value.trim() });\n\n // `preventDefault()` on `send` means \"keep the current text — skip the default clear\n // + refocus\" (see the event's own doc comment): both halves of that default are gated on\n // the same condition, not just the clear.\n if (notPrevented && props['clear-on-send'].value !== false) {\n tf.clear();\n autoResize.recompute();\n textareaRef.value?.focus();\n }\n }\n\n const composer = createComposerControl({\n disabled: isDisabled,\n loading: computed(() => Boolean(props.loading.value)),\n onSend: attemptSend,\n sendShortcut: props['send-shortcut'],\n value: tf.value,\n });\n\n onElement(textareaRef, (textareaEl) => {\n const unwireField = tf.wire(textareaEl);\n const unwireAutoResize = autoResize.wire(textareaEl);\n const handleKeydown = (e: KeyboardEvent) => composer.handleKeydown(e);\n\n textareaEl.addEventListener('keydown', handleKeydown);\n\n // Immediate fire for when the prop is already set on mount.\n props.ref.value?.(textareaEl);\n\n // Reactive watcher so that if props.ref is set *after* the inner <textarea> mounts\n // (e.g. a parent sets it via a ref callback after render), the new callback still\n // receives the live element.\n const refSub = watch(props.ref, (cb) => {\n cb?.(textareaEl);\n });\n\n return () => {\n textareaEl.removeEventListener('keydown', handleKeydown);\n unwireField();\n unwireAutoResize();\n refSub.dispose();\n props.ref.value?.(null);\n };\n });\n\n bind({\n attr: {\n error: errorAttr(tf.errorText),\n size: fCtxProps.size,\n variant: fCtxProps.variant,\n },\n });\n\n const counterClass = () => counterClassName(tf.counter?.value);\n const counterHidden = () => !tf.counter;\n const counterText = () => tf.counter?.value.counterText.replace(' / ', '/') ?? '';\n const helperHidden = () => !!tf.errorText.value || !tf.helperText.value;\n const errorHidden = () => !tf.errorText.value;\n\n return html`\n <div class=\"composer\" part=\"composer\">\n <textarea\n class=\"field\"\n part=\"field\"\n ref=\"${textareaRef}\"\n :rows=\"${() => props.rows.value ?? 1}\"\n :name=\"${() => props.name.value ?? ''}\"\n :placeholder=\"${() => props.placeholder.value ?? 'Message…'}\"\n :maxlength=\"${() => props.maxlength.value}\"\n ?disabled=\"${isDisabled}\"\n ?readonly=\"${() => Boolean(props.readonly.value)}\"\n ?required=\"${() => Boolean(props.required.value)}\"\n :value=\"${live(tf.value)}\"\n :aria-label=\"${() => props.label.value || 'Message'}\"\n :aria-keyshortcuts=\"${composer.keyShortcutsHint}\"\n :aria-describedby=\"${tf.ariaDescribedBy}\"\n :aria-errormessage=\"${tf.ariaErrorMessage}\"\n :aria-invalid=\"${tf.ariaInvalid}\"></textarea>\n <span class=\"${counterClass}\" aria-live=\"polite\" ?hidden=\"${counterHidden}\">${counterText}</span>\n <div id=\"${tf.assistiveId}\" class=\"helper-text\" aria-live=\"polite\" part=\"helper\" ?hidden=\"${helperHidden}\">\n ${() => tf.helperText.value}\n </div>\n <div id=\"${tf.errorId}\" class=\"helper-text\" role=\"alert\" part=\"error\" ?hidden=\"${errorHidden}\">\n ${() => tf.errorText.value}\n </div>\n <div class=\"toolbar\" part=\"toolbar\">\n <div class=\"toolbar-start\" part=\"toolbar-start\">\n <slot name=\"prefix\"></slot>\n </div>\n <div class=\"toolbar-end\" part=\"toolbar-end\">\n <slot name=\"suffix\"></slot>\n <slot name=\"send\"></slot>\n ${() =>\n slots.has('send').value\n ? ''\n : html`<ore-button\n class=\"send-btn\"\n part=\"send-button\"\n type=\"button\"\n icon-only\n variant=\"solid\"\n :color=\"${() => props.color.value || 'primary'}\"\n :size=\"${fCtxProps.size}\"\n :label=\"${() => props['send-label'].value || DEFAULT_SEND_LABEL}\"\n ?loading=\"${() => Boolean(props.loading.value)}\"\n ?disabled=\"${() => !composer.canSend.value}\"\n @click=\"${(e: MouseEvent) => composer.send(e)}\">\n <ore-icon name=\"${() => props['send-icon'].value || SEND_ICON}\" size=\"16\"></ore-icon>\n </ore-button>`}\n </div>\n </div>\n </div>\n `;\n },\n shadow: { delegatesFocus: true },\n styles: [\n colorThemeMixin,\n coarsePointerMixin,\n reducedMotionMixin,\n disabledLoadingMixin,\n forcedColorsMixin,\n forcedColorsFocusMixin('.field'),\n sizeVariantMixin(MESSAGE_COMPOSER_SIZE_PRESET),\n componentStyles,\n ],\n});\n"],"mappings":"s4BAuCA,IAAM,EAAqB,eACrB,EAAY,WAkIL,EAAuB,oCACJ,EAAsB,CACpD,eAAgB,GAChB,MAAO,CACL,GAAG,EAAA,eACH,GAAG,EAAA,cACH,GAAG,EAAA,iBACH,GAAG,EAAA,eACH,gBAAiB,EAAA,KAAK,KAAK,EAAI,EAC/B,MAAO,EAAA,KAAK,OAAO,EACnB,UAAW,EAAA,KAAK,KAAK,EAAK,EAC1B,OAAQ,EAAA,KAAK,OAAO,EACpB,MAAO,EAAA,K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AAM,OAAS,UAAU;gCAC9B,EAAS,iBAAiB;+BAC3B,EAAG,gBAAgB;gCAClB,EAAG,iBAAiB;2BACzB,EAAG,YAAY;2BAxBX,EAAA,iBAAiB,EAAG,SAAS,KAAK,EAyB7B,oCAxBJ,CAAC,EAAG,QAwB8C,QAvBpD,EAAG,SAAS,MAAM,YAAY,QAAQ,MAAO,GAAG,GAAK,GAuBe;mBAC/E,EAAG,YAAY,sEAvBH,CAAC,CAAC,EAAG,UAAU,OAAS,CAAC,EAAG,WAAW,MAuB2C;gBAC/F,EAAG,WAAW,MAAM;;mBAEnB,EAAG,QAAQ,+DAzBA,CAAC,EAAG,UAAU,MAyByD;gBACnF,EAAG,UAAU,MAAM;;;;;;;;;kBAUvB,EAAM,IAAI,MAAM,CAAC,CAAC,MACd,GACA,EAAA,IAAI;;;;;;kCAMc,EAAM,MAAM,OAAS,UAAU;6BACtC,EAAU,KAAK;kCACR,EAAM,aAAa,CAAC,OAAS,EAAmB;oCAC9C,EAAQ,EAAM,QAAQ,MAAO;qCAC5B,CAAC,EAAS,QAAQ,MAAM;8BAChC,GAAkB,EAAS,KAAK,CAAC,EAAE;0CACtB,EAAM,YAAY,CAAC,OAAS,EAAU;iCACjD;;;;KAK/B,EACA,OAAQ,CAAE,eAAgB,EAAK,EAC/B,OAAQ,CACN,EAAA,gBACA,EAAA,mBACA,EAAA,mBACA,EAAA,qBACA,EAAA,kBACA,EAAA,uBAAuB,QAAQ,EAC/B,EAAA,iBAAiB,EAAA,4BAA4B,EAC7C,EAAA,OACF,CACF,CAAC"}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { live as e } from "./ore/dist/directives/live.js";
|
|
2
|
+
import "./ore/dist/directives.js";
|
|
3
|
+
import { coarsePointerMixin as t, reducedMotionMixin as n } from "./styles/mixins/accessibility.css.js";
|
|
4
|
+
import { sizeVariantMixin as r } from "./styles/mixins/shape.css.js";
|
|
5
|
+
import { disabledLoadingMixin as i } from "./styles/mixins/states.css.js";
|
|
6
|
+
import { colorThemeMixin as a, forcedColorsFocusMixin as o, forcedColorsMixin as s } from "./styles/mixins/theme.css.js";
|
|
7
|
+
import { disablableBundle as c, loadableBundle as l, sizableBundle as u, themableBundle as d } from "./shared/prop-bundles.js";
|
|
8
|
+
import { MESSAGE_COMPOSER_SIZE_PRESET as f } from "./shared/size-presets.js";
|
|
9
|
+
import { lifecycleSignal as p } from "./headless/ore.js";
|
|
10
|
+
import { createAutoResize as m } from "./headless/auto-resize.js";
|
|
11
|
+
import { counterClassName as h } from "./headless/field-base.js";
|
|
12
|
+
import { createTextField as g } from "./headless/text-field.js";
|
|
13
|
+
import { createComposerControl as _ } from "./headless/composer.js";
|
|
14
|
+
import { useField as v } from "./ore/dist/forms/field.js";
|
|
15
|
+
import "./ore/dist/forms.js";
|
|
16
|
+
import { errorAttr as y } from "./inputs/shared/field-binding.js";
|
|
17
|
+
import { FORM_CTX as b, useFormContext as x } from "./inputs/shared/form-context.js";
|
|
18
|
+
import S from "./inputs/message-composer/message-composer.css.js";
|
|
19
|
+
import { bind as C, define as w, html as T, inject as E, onCleanup as D, onElement as O, prop as k, ref as A, useEmit as j, useSlots as M } from "@vielzeug/ore";
|
|
20
|
+
import { computed as N, watch as P } from "@vielzeug/ripple";
|
|
21
|
+
//#region src/inputs/message-composer/message-composer.ts
|
|
22
|
+
var F = "Send message", I = "arrow-up", L = "ore-message-composer";
|
|
23
|
+
w(L, {
|
|
24
|
+
formAssociated: !0,
|
|
25
|
+
props: {
|
|
26
|
+
...d,
|
|
27
|
+
...u,
|
|
28
|
+
...c,
|
|
29
|
+
...l,
|
|
30
|
+
"clear-on-send": k.bool(!0),
|
|
31
|
+
error: k.string(),
|
|
32
|
+
fullwidth: k.bool(!1),
|
|
33
|
+
helper: k.string(),
|
|
34
|
+
label: k.string(),
|
|
35
|
+
maxlength: k.json(void 0),
|
|
36
|
+
name: k.string(),
|
|
37
|
+
placeholder: k.string(),
|
|
38
|
+
readonly: k.bool(!1),
|
|
39
|
+
ref: k.json(void 0),
|
|
40
|
+
required: k.bool(!1),
|
|
41
|
+
rows: k.json(void 0),
|
|
42
|
+
"send-icon": k.string(),
|
|
43
|
+
"send-label": k.string(),
|
|
44
|
+
"send-shortcut": k.oneOf(["enter", "mod+enter"], "enter"),
|
|
45
|
+
value: k.string(),
|
|
46
|
+
variant: k.string()
|
|
47
|
+
},
|
|
48
|
+
setup(t) {
|
|
49
|
+
let n = j(), r = M(), i = E(b), a = x(t, i), o = a.disabled, s = p(D), c = A(), l = m(), u = g({
|
|
50
|
+
disabled: o,
|
|
51
|
+
error: t.error,
|
|
52
|
+
helper: t.helper,
|
|
53
|
+
maxLength: t.maxlength,
|
|
54
|
+
onInput: (e, t) => n("input", {
|
|
55
|
+
originalEvent: e,
|
|
56
|
+
value: t
|
|
57
|
+
}),
|
|
58
|
+
prefix: "composer",
|
|
59
|
+
readonly: t.readonly,
|
|
60
|
+
required: t.required,
|
|
61
|
+
signal: s,
|
|
62
|
+
validateOn: i?.validateOn,
|
|
63
|
+
value: t.value
|
|
64
|
+
});
|
|
65
|
+
u.attachFormField(v({
|
|
66
|
+
disabled: u.disabled,
|
|
67
|
+
onReset: () => {
|
|
68
|
+
u.reset(), l.recompute();
|
|
69
|
+
},
|
|
70
|
+
toFormValue: (e) => e,
|
|
71
|
+
validationMessage: u.validationMessage,
|
|
72
|
+
validity: u.validity,
|
|
73
|
+
value: u.value
|
|
74
|
+
}));
|
|
75
|
+
function d(e) {
|
|
76
|
+
n("send", {
|
|
77
|
+
originalEvent: e,
|
|
78
|
+
value: u.value.value.trim()
|
|
79
|
+
}) && t["clear-on-send"].value !== !1 && (u.clear(), l.recompute(), c.value?.focus());
|
|
80
|
+
}
|
|
81
|
+
let f = _({
|
|
82
|
+
disabled: o,
|
|
83
|
+
loading: N(() => !!t.loading.value),
|
|
84
|
+
onSend: d,
|
|
85
|
+
sendShortcut: t["send-shortcut"],
|
|
86
|
+
value: u.value
|
|
87
|
+
});
|
|
88
|
+
return O(c, (e) => {
|
|
89
|
+
let n = u.wire(e), r = l.wire(e), i = (e) => f.handleKeydown(e);
|
|
90
|
+
e.addEventListener("keydown", i), t.ref.value?.(e);
|
|
91
|
+
let a = P(t.ref, (t) => {
|
|
92
|
+
t?.(e);
|
|
93
|
+
});
|
|
94
|
+
return () => {
|
|
95
|
+
e.removeEventListener("keydown", i), n(), r(), a.dispose(), t.ref.value?.(null);
|
|
96
|
+
};
|
|
97
|
+
}), C({ attr: {
|
|
98
|
+
error: y(u.errorText),
|
|
99
|
+
size: a.size,
|
|
100
|
+
variant: a.variant
|
|
101
|
+
} }), T`
|
|
102
|
+
<div class="composer" part="composer">
|
|
103
|
+
<textarea
|
|
104
|
+
class="field"
|
|
105
|
+
part="field"
|
|
106
|
+
ref="${c}"
|
|
107
|
+
:rows="${() => t.rows.value ?? 1}"
|
|
108
|
+
:name="${() => t.name.value ?? ""}"
|
|
109
|
+
:placeholder="${() => t.placeholder.value ?? "Message…"}"
|
|
110
|
+
:maxlength="${() => t.maxlength.value}"
|
|
111
|
+
?disabled="${o}"
|
|
112
|
+
?readonly="${() => !!t.readonly.value}"
|
|
113
|
+
?required="${() => !!t.required.value}"
|
|
114
|
+
:value="${e(u.value)}"
|
|
115
|
+
:aria-label="${() => t.label.value || "Message"}"
|
|
116
|
+
:aria-keyshortcuts="${f.keyShortcutsHint}"
|
|
117
|
+
:aria-describedby="${u.ariaDescribedBy}"
|
|
118
|
+
:aria-errormessage="${u.ariaErrorMessage}"
|
|
119
|
+
:aria-invalid="${u.ariaInvalid}"></textarea>
|
|
120
|
+
<span class="${() => h(u.counter?.value)}" aria-live="polite" ?hidden="${() => !u.counter}">${() => u.counter?.value.counterText.replace(" / ", "/") ?? ""}</span>
|
|
121
|
+
<div id="${u.assistiveId}" class="helper-text" aria-live="polite" part="helper" ?hidden="${() => !!u.errorText.value || !u.helperText.value}">
|
|
122
|
+
${() => u.helperText.value}
|
|
123
|
+
</div>
|
|
124
|
+
<div id="${u.errorId}" class="helper-text" role="alert" part="error" ?hidden="${() => !u.errorText.value}">
|
|
125
|
+
${() => u.errorText.value}
|
|
126
|
+
</div>
|
|
127
|
+
<div class="toolbar" part="toolbar">
|
|
128
|
+
<div class="toolbar-start" part="toolbar-start">
|
|
129
|
+
<slot name="prefix"></slot>
|
|
130
|
+
</div>
|
|
131
|
+
<div class="toolbar-end" part="toolbar-end">
|
|
132
|
+
<slot name="suffix"></slot>
|
|
133
|
+
<slot name="send"></slot>
|
|
134
|
+
${() => r.has("send").value ? "" : T`<ore-button
|
|
135
|
+
class="send-btn"
|
|
136
|
+
part="send-button"
|
|
137
|
+
type="button"
|
|
138
|
+
icon-only
|
|
139
|
+
variant="solid"
|
|
140
|
+
:color="${() => t.color.value || "primary"}"
|
|
141
|
+
:size="${a.size}"
|
|
142
|
+
:label="${() => t["send-label"].value || F}"
|
|
143
|
+
?loading="${() => !!t.loading.value}"
|
|
144
|
+
?disabled="${() => !f.canSend.value}"
|
|
145
|
+
@click="${(e) => f.send(e)}">
|
|
146
|
+
<ore-icon name="${() => t["send-icon"].value || I}" size="16"></ore-icon>
|
|
147
|
+
</ore-button>`}
|
|
148
|
+
</div>
|
|
149
|
+
</div>
|
|
150
|
+
</div>
|
|
151
|
+
`;
|
|
152
|
+
},
|
|
153
|
+
shadow: { delegatesFocus: !0 },
|
|
154
|
+
styles: [
|
|
155
|
+
a,
|
|
156
|
+
t,
|
|
157
|
+
n,
|
|
158
|
+
i,
|
|
159
|
+
s,
|
|
160
|
+
o(".field"),
|
|
161
|
+
r(f),
|
|
162
|
+
S
|
|
163
|
+
]
|
|
164
|
+
});
|
|
165
|
+
//#endregion
|
|
166
|
+
export { L as MESSAGE_COMPOSER_TAG };
|
|
167
|
+
|
|
168
|
+
//# sourceMappingURL=message-composer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message-composer.js","names":[],"sources":["../src/inputs/message-composer/message-composer.ts"],"sourcesContent":["import { define, html, inject, prop, ref, bind, onCleanup, onElement, useEmit, useSlots } from '@vielzeug/ore';\nimport { live } from '@vielzeug/ore/directives';\nimport { useField } from '@vielzeug/ore/forms';\nimport { computed, watch } from '@vielzeug/ripple';\n\nimport type { ComponentSize, ThemeColor, VisualVariant } from '../../types';\n\nimport {\n counterClassName,\n createAutoResize,\n createComposerControl,\n createTextField,\n lifecycleSignal,\n type SendShortcut,\n} from '../../headless';\nimport {\n disablableBundle,\n loadableBundle,\n MESSAGE_COMPOSER_SIZE_PRESET,\n sizableBundle,\n themableBundle,\n} from '../../shared';\nimport {\n colorThemeMixin,\n coarsePointerMixin,\n disabledLoadingMixin,\n forcedColorsFocusMixin,\n forcedColorsMixin,\n reducedMotionMixin,\n sizeVariantMixin,\n} from '../../styles';\nimport { errorAttr } from '../shared/field-binding';\nimport { FORM_CTX, useFormContext } from '../shared/form-context';\nimport '../../content/icon/icon';\nimport '../button/button';\nimport componentStyles from './message-composer.css?inline';\n\nexport type { SendShortcut } from '../../headless';\n\nconst DEFAULT_SEND_LABEL = 'Send message';\nconst SEND_ICON = 'arrow-up';\n\n/** Events emitted by the message composer */\nexport type OreMessageComposerEvents = {\n /** Fired on every keystroke with the current value. */\n input: { originalEvent: Event; value: string };\n /**\n * Fired for a send attempt (the resolved `send-shortcut` or the send button) while the\n * composer isn't blank/disabled/loading. Cancelable — call `preventDefault()` to keep the\n * current text in the field instead of the default clear + refocus.\n */\n send: { originalEvent: KeyboardEvent | MouseEvent; value: string };\n};\n\n/** Message composer properties */\nexport type OreMessageComposerProps = {\n /** Clear the value and refocus after a non-cancelled `send` (default `true`) */\n 'clear-on-send'?: boolean;\n /** Theme color (card focus ring + default send button color) */\n color?: ThemeColor;\n /** Disable the whole composer (field, slots, and send action) */\n disabled?: boolean;\n /** Error message shown below the field */\n error?: string;\n /** Stretch the composer to the full width of its container */\n fullwidth?: boolean;\n /** Helper text shown below the field */\n helper?: string;\n /** Accessible name for the field — never rendered visually, only as `aria-label` */\n label?: string;\n /** Blocks further sends (e.g. a send is already in flight) without disabling editing */\n loading?: boolean;\n /** Maximum character count; shows a counter */\n maxlength?: number;\n /** Form field name */\n name?: string;\n /** Placeholder text */\n placeholder?: string;\n /** Make the field read-only */\n readonly?: boolean;\n /**\n * JS-only callback fired with the inner `<textarea>` element when it mounts, and with\n * `null` when it unmounts. Set as a JS property: `composer.ref = (el) => { ... }`.\n */\n ref?: ((el: HTMLTextAreaElement | null) => void) | null;\n /** Require a non-blank value for `<ore-form>` validation */\n required?: boolean;\n /** Number of visible rows before auto-resize grows the field */\n rows?: number;\n /** Lucide icon name for the default send button (default `'arrow-up'`) */\n 'send-icon'?: string;\n /** Accessible label for the send button (default `'Send message'`) */\n 'send-label'?: string;\n /** Keyboard shortcut that sends: 'enter' (Shift+Enter for a newline) or 'mod+enter' (Enter always inserts a newline; Ctrl/Cmd+Enter sends) */\n 'send-shortcut'?: SendShortcut;\n /** Component size */\n size?: ComponentSize;\n /** Current text value */\n value?: string;\n /** Visual variant of the card — same variant set as `ore-textarea`, applied to the card. */\n variant?: Exclude<VisualVariant, 'frost' | 'text'>;\n};\n\n/**\n * A message/comment composer — a card with an auto-resizing field on top and a toolbar row\n * below it, built directly on the same headless primitives as `ore-textarea` (`createTextField`,\n * `createAutoResize`) rather than composing `ore-textarea` itself. Nesting a fully-styled sibling\n * component and suppressing most of its chrome (as an earlier version of this component did) is\n * a leaky composition — this owns its single `<textarea>` outright, so there's exactly one\n * implementation of the field's appearance to reason about, not two fighting each other.\n *\n * Handles the send gesture (Enter to send, Shift+Enter for a newline, or a Ctrl/Cmd+Enter\n * alternative), IME-safe composition, and clear-and-refocus after sending.\n *\n * @element ore-message-composer\n *\n * @attr {string} value - Current text value\n * @attr {string} placeholder - Placeholder text\n * @attr {string} label - Accessible name for the field (not rendered visually)\n * @attr {string} name - Form field name\n * @attr {string} helper - Helper text shown below the field\n * @attr {string} error - Error message shown below the field\n * @attr {boolean} disabled - Disable the whole composer\n * @attr {boolean} readonly - Read-only mode\n * @attr {boolean} required - Require a non-blank value for `<ore-form>` validation\n * @attr {boolean} loading - Blocks further sends without disabling editing\n * @attr {number} maxlength - Max character count; shows a counter\n * @attr {number} rows - Visible rows before auto-resize grows the field (default 1)\n * @attr {string} color - Theme color: 'primary' | 'secondary' | 'info' | 'success' | 'warning' | 'error'\n * @attr {string} variant - Visual variant of the card: 'solid' | 'flat' | 'bordered' | 'outline' | 'ghost'\n * @attr {string} size - 'sm' | 'md' | 'lg'\n * @attr {boolean} fullwidth - Stretch to the full width of the container\n * @attr {string} send-icon - Lucide icon name for the default send button (default 'arrow-up')\n * @attr {string} send-label - Accessible label for the send button (default 'Send message')\n * @attr {string} send-shortcut - 'enter' (default) | 'mod+enter'\n * @attr {boolean} clear-on-send - Clear the value and refocus after a non-cancelled send (default true)\n *\n * @fires input - Fired on every keystroke. detail: { value, originalEvent }\n * @fires send - Fired on a send attempt. Cancelable. detail: { value, originalEvent }\n *\n * @slot prefix - Content at the start of the toolbar row (e.g. an attach menu)\n * @slot suffix - Content at the end of the toolbar row, before the send button (e.g. a model picker)\n * @slot send - Replaces the default send button entirely — the only supported way to customize it\n *\n * @cssprop --message-composer-bg - Card background color\n * @cssprop --message-composer-border-color - Card border color\n * @cssprop --message-composer-radius - Card border radius\n * @cssprop --message-composer-padding - Card inner padding\n * @cssprop --message-composer-gap - Gap between the field/toolbar rows and between toolbar items\n * @cssprop --message-composer-placeholder-color - Field placeholder text color\n * @cssprop --message-composer-min-height - Minimum field height (default one line)\n * @cssprop --message-composer-hover-bg - Card background on hover (flat/ghost variants)\n * @cssprop --message-composer-hover-border-color - Card border on hover (flat/bordered variants)\n * @cssprop --message-composer-focus-bg - Card background when focused (flat variant)\n * @cssprop --message-composer-focus-border-color - Card border when focused (flat variant)\n *\n * @part composer - Root card container\n * @part field - The native `<textarea>` element\n * @part helper - Helper text element\n * @part error - Error text element (`role=\"alert\"`)\n * @part toolbar - Toolbar row below the field\n * @part toolbar-start - Toolbar group holding the `prefix` slot\n * @part toolbar-end - Toolbar group holding the `suffix` slot and the send button\n * @part send-button - The default send button (absent when the `send` slot is used)\n *\n * @example\n * ```html\n * <ore-message-composer placeholder=\"Message…\" send-shortcut=\"mod+enter\"></ore-message-composer>\n * ```\n */\nexport const MESSAGE_COMPOSER_TAG = 'ore-message-composer' as const;\ndefine<OreMessageComposerProps>(MESSAGE_COMPOSER_TAG, {\n formAssociated: true,\n props: {\n ...themableBundle,\n ...sizableBundle,\n ...disablableBundle,\n ...loadableBundle,\n 'clear-on-send': prop.bool(true),\n error: prop.string(),\n fullwidth: prop.bool(false),\n helper: prop.string(),\n label: prop.string(),\n maxlength: prop.json(undefined as number | undefined),\n name: prop.string(),\n placeholder: prop.string(),\n readonly: prop.bool(false),\n ref: prop.json(undefined as ((el: HTMLTextAreaElement | null) => void) | null | undefined),\n required: prop.bool(false),\n rows: prop.json(undefined as number | undefined),\n 'send-icon': prop.string(),\n 'send-label': prop.string(),\n 'send-shortcut': prop.oneOf(['enter', 'mod+enter'] as const, 'enter'),\n value: prop.string(),\n variant: prop.string<Exclude<VisualVariant, 'frost' | 'text'>>(),\n },\n setup(props) {\n const emit = useEmit<OreMessageComposerEvents>();\n const slots = useSlots<'prefix' | 'send' | 'suffix'>();\n\n const formCtx = inject(FORM_CTX);\n const fCtxProps = useFormContext(props, formCtx);\n const isDisabled = fCtxProps.disabled;\n\n const abortSignal = lifecycleSignal(onCleanup);\n const textareaRef = ref<HTMLTextAreaElement>();\n const autoResize = createAutoResize();\n\n const tf = createTextField({\n disabled: isDisabled,\n error: props.error,\n helper: props.helper,\n maxLength: props.maxlength,\n onInput: (event, value) => emit('input', { originalEvent: event, value }),\n prefix: 'composer',\n readonly: props.readonly,\n required: props.required,\n signal: abortSignal,\n validateOn: formCtx?.validateOn,\n value: props.value,\n });\n\n // Directly form-associated now that the field is owned here rather than borrowed from a\n // nested `ore-textarea` (which previously registered with the ancestor `<form>` on this\n // component's behalf).\n tf.attachFormField(\n useField<string>({\n disabled: tf.disabled,\n onReset: () => {\n tf.reset();\n autoResize.recompute();\n },\n toFormValue: (v) => v,\n validationMessage: tf.validationMessage,\n validity: tf.validity,\n value: tf.value,\n }),\n );\n\n function attemptSend(event: KeyboardEvent | MouseEvent): void {\n const notPrevented = emit('send', { originalEvent: event, value: tf.value.value.trim() });\n\n // `preventDefault()` on `send` means \"keep the current text — skip the default clear\n // + refocus\" (see the event's own doc comment): both halves of that default are gated on\n // the same condition, not just the clear.\n if (notPrevented && props['clear-on-send'].value !== false) {\n tf.clear();\n autoResize.recompute();\n textareaRef.value?.focus();\n }\n }\n\n const composer = createComposerControl({\n disabled: isDisabled,\n loading: computed(() => Boolean(props.loading.value)),\n onSend: attemptSend,\n sendShortcut: props['send-shortcut'],\n value: tf.value,\n });\n\n onElement(textareaRef, (textareaEl) => {\n const unwireField = tf.wire(textareaEl);\n const unwireAutoResize = autoResize.wire(textareaEl);\n const handleKeydown = (e: KeyboardEvent) => composer.handleKeydown(e);\n\n textareaEl.addEventListener('keydown', handleKeydown);\n\n // Immediate fire for when the prop is already set on mount.\n props.ref.value?.(textareaEl);\n\n // Reactive watcher so that if props.ref is set *after* the inner <textarea> mounts\n // (e.g. a parent sets it via a ref callback after render), the new callback still\n // receives the live element.\n const refSub = watch(props.ref, (cb) => {\n cb?.(textareaEl);\n });\n\n return () => {\n textareaEl.removeEventListener('keydown', handleKeydown);\n unwireField();\n unwireAutoResize();\n refSub.dispose();\n props.ref.value?.(null);\n };\n });\n\n bind({\n attr: {\n error: errorAttr(tf.errorText),\n size: fCtxProps.size,\n variant: fCtxProps.variant,\n },\n });\n\n const counterClass = () => counterClassName(tf.counter?.value);\n const counterHidden = () => !tf.counter;\n const counterText = () => tf.counter?.value.counterText.replace(' / ', '/') ?? '';\n const helperHidden = () => !!tf.errorText.value || !tf.helperText.value;\n const errorHidden = () => !tf.errorText.value;\n\n return html`\n <div class=\"composer\" part=\"composer\">\n <textarea\n class=\"field\"\n part=\"field\"\n ref=\"${textareaRef}\"\n :rows=\"${() => props.rows.value ?? 1}\"\n :name=\"${() => props.name.value ?? ''}\"\n :placeholder=\"${() => props.placeholder.value ?? 'Message…'}\"\n :maxlength=\"${() => props.maxlength.value}\"\n ?disabled=\"${isDisabled}\"\n ?readonly=\"${() => Boolean(props.readonly.value)}\"\n ?required=\"${() => Boolean(props.required.value)}\"\n :value=\"${live(tf.value)}\"\n :aria-label=\"${() => props.label.value || 'Message'}\"\n :aria-keyshortcuts=\"${composer.keyShortcutsHint}\"\n :aria-describedby=\"${tf.ariaDescribedBy}\"\n :aria-errormessage=\"${tf.ariaErrorMessage}\"\n :aria-invalid=\"${tf.ariaInvalid}\"></textarea>\n <span class=\"${counterClass}\" aria-live=\"polite\" ?hidden=\"${counterHidden}\">${counterText}</span>\n <div id=\"${tf.assistiveId}\" class=\"helper-text\" aria-live=\"polite\" part=\"helper\" ?hidden=\"${helperHidden}\">\n ${() => tf.helperText.value}\n </div>\n <div id=\"${tf.errorId}\" class=\"helper-text\" role=\"alert\" part=\"error\" ?hidden=\"${errorHidden}\">\n ${() => tf.errorText.value}\n </div>\n <div class=\"toolbar\" part=\"toolbar\">\n <div class=\"toolbar-start\" part=\"toolbar-start\">\n <slot name=\"prefix\"></slot>\n </div>\n <div class=\"toolbar-end\" part=\"toolbar-end\">\n <slot name=\"suffix\"></slot>\n <slot name=\"send\"></slot>\n ${() =>\n slots.has('send').value\n ? ''\n : html`<ore-button\n class=\"send-btn\"\n part=\"send-button\"\n type=\"button\"\n icon-only\n variant=\"solid\"\n :color=\"${() => props.color.value || 'primary'}\"\n :size=\"${fCtxProps.size}\"\n :label=\"${() => props['send-label'].value || DEFAULT_SEND_LABEL}\"\n ?loading=\"${() => Boolean(props.loading.value)}\"\n ?disabled=\"${() => !composer.canSend.value}\"\n @click=\"${(e: MouseEvent) => composer.send(e)}\">\n <ore-icon name=\"${() => props['send-icon'].value || SEND_ICON}\" size=\"16\"></ore-icon>\n </ore-button>`}\n </div>\n </div>\n </div>\n `;\n },\n shadow: { delegatesFocus: true },\n styles: [\n colorThemeMixin,\n coarsePointerMixin,\n reducedMotionMixin,\n disabledLoadingMixin,\n forcedColorsMixin,\n forcedColorsFocusMixin('.field'),\n sizeVariantMixin(MESSAGE_COMPOSER_SIZE_PRESET),\n componentStyles,\n ],\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAuCA,IAAM,IAAqB,gBACrB,IAAY,YAkIL,IAAuB;AACpC,EAAgC,GAAsB;CACpD,gBAAgB;CAChB,OAAO;EACL,GAAG;EACH,GAAG;EACH,GAAG;EACH,GAAG;EACH,iBAAiB,EAAK,KAAK,EAAI;EAC/B,OAAO,EAAK,OAAO;EACnB,WAAW,EAAK,KAAK,EAAK;EAC1B,QAAQ,EAAK,OAAO;EACpB,OAAO,EAAK,OAAO;EACnB,WAAW,EAAK,KAAK,KAAA,CAA+B;EACpD,MAAM,EAAK,OAAO;EAClB,aAAa,EAAK,OAAO;EACzB,UAAU,EAAK,KAAK,EAAK;EACzB,KAAK,EAAK,KAAK,KAAA,CAA0E;EACzF,UAAU,EAAK,KAAK,EAAK;EACzB,MAAM,EAAK,KAAK,KAAA,CAA+B;EAC/C,aAAa,EAAK,OAAO;EACzB,cAAc,EAAK,OAAO;EAC1B,iBAAiB,EAAK,MAAM,CAAC,SAAS,WAAW,GAAY,OAAO;EACpE,OAAO,EAAK,OAAO;EACnB,SAAS,EAAK,OAAiD;CACjE;CACA,MAAM,GAAO;EACX,IAAM,IAAO,EAAkC,GACzC,IAAQ,EAAuC,GAE/C,IAAU,EAAO,CAAQ,GACzB,IAAY,EAAe,GAAO,CAAO,GACzC,IAAa,EAAU,UAEvB,IAAc,EAAgB,CAAS,GACvC,IAAc,EAAyB,GACvC,IAAa,EAAiB,GAE9B,IAAK,EAAgB;GACzB,UAAU;GACV,OAAO,EAAM;GACb,QAAQ,EAAM;GACd,WAAW,EAAM;GACjB,UAAU,GAAO,MAAU,EAAK,SAAS;IAAE,eAAe;IAAO;GAAM,CAAC;GACxE,QAAQ;GACR,UAAU,EAAM;GAChB,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AAG;gCAChB,EAAM,YAAY,SAAS,WAAW;8BACxC,EAAM,UAAU,MAAM;uBAC7B,EAAW;6BACL,EAAQ,EAAM,SAAS,MAAO;6BAC9B,EAAQ,EAAM,SAAS,MAAO;oBACvC,EAAK,EAAG,KAAK,EAAE;+BACJ,EAAM,MAAM,SAAS,UAAU;gCAC9B,EAAS,iBAAiB;+BAC3B,EAAG,gBAAgB;gCAClB,EAAG,iBAAiB;2BACzB,EAAG,YAAY;6BAxBX,EAAiB,EAAG,SAAS,KAAK,EAyB7B,sCAxBJ,CAAC,EAAG,QAwB8C,UAvBpD,EAAG,SAAS,MAAM,YAAY,QAAQ,OAAO,GAAG,KAAK,GAuBe;mBAC/E,EAAG,YAAY,wEAvBH,CAAC,CAAC,EAAG,UAAU,SAAS,CAAC,EAAG,WAAW,MAuB2C;kBAC/F,EAAG,WAAW,MAAM;;mBAEnB,EAAG,QAAQ,iEAzBA,CAAC,EAAG,UAAU,MAyByD;kBACnF,EAAG,UAAU,MAAM;;;;;;;;;oBAUvB,EAAM,IAAI,MAAM,CAAC,CAAC,QACd,KACA,CAAI;;;;;;oCAMc,EAAM,MAAM,SAAS,UAAU;6BACtC,EAAU,KAAK;oCACR,EAAM,aAAa,CAAC,SAAS,EAAmB;sCAC9C,EAAQ,EAAM,QAAQ,MAAO;uCAC5B,CAAC,EAAS,QAAQ,MAAM;+BAChC,MAAkB,EAAS,KAAK,CAAC,EAAE;4CACtB,EAAM,YAAY,CAAC,SAAS,EAAU;iCACjD;;;;;CAK/B;CACA,QAAQ,EAAE,gBAAgB,GAAK;CAC/B,QAAQ;EACN;EACA;EACA;EACA;EACA;EACA,EAAuB,QAAQ;EAC/B,EAAiB,CAA4B;EAC7C;CACF;AACF,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("./_dev.cjs"),t=require("./errors.cjs");require("./types/bindings.cjs");const n=require("./runtime.cjs"),r=require("./utils/css.cjs"),i=require("./props.cjs"),a=require("./types.cjs");let o=require("@vielzeug/ripple");var s=()=>({generation:0,mountCallbacks:[],phase:a.ComponentPhase.UNINITIALIZED,scope:(0,o.scope)(),templateResult:null}),c=class extends HTMLElement{static _definition;static _normalizedPropDefs;static formAssociated=!1;static observedAttributes=[];_component;constructor(){super();let e=this.constructor._definition;e?.shadow!==!1&&this.attachShadow({mode:`open`,...e?.shadow}),this._component=s()}connectedCallback(){(0,o.untrack)(()=>{this._component.phase===a.ComponentPhase.UNINITIALIZED&&this._runSetup(),this._init()}),this.dispatchEvent(new CustomEvent(a.LIFECYCLE_EVENTS.CONNECT,{bubbles:!1,composed:!1}))}attributeChangedCallback(e,t,n){if(t===n)return;let r=i.getPropMeta(this,e);if(!r)return;let a=r.parse(n);Object.is((0,o.untrack)(()=>r.signal.value),a)||(r.signal.value=a)}disconnectedCallback(){this._component.generation++,this._component.phase=a.ComponentPhase.UNMOUNTED,this.dispatchEvent(new CustomEvent(a.LIFECYCLE_EVENTS.DISCONNECT,{bubbles:!1,composed:!1})),this._component.scope.dispose(),this._component.mountCallbacks=[],this._component.phase=a.ComponentPhase.UNINITIALIZED,this._component.scope=(0,o.scope)(),this._component.templateResult=null}_handleSetupError(e,n=`setup`){let r=e instanceof Error?e:Error(String(e)),i=new t.OreLifecycleError(`<${this.localName}> failed during ${this._component.phase} (${n})`,{cause:r,component:this.localName,phase:n}),a=this.constructor._definition;if(a?.onError)try{return a.onError(i,this)}catch{}t.reportRuntimeError(i,this)}_runSetup(){this._component.phase=a.ComponentPhase.SETUP_RUNNING;let e=this.constructor._definition,t=this.constructor._normalizedPropDefs,r={element:this,mountCallbacks:[]};try{let o;if(this._component.scope.run(()=>{o=n.runWithContext(r,()=>{let n=t?i.createProps(this,t):{};return e.setup(n)})}),this._component.mountCallbacks.push(...r.mountCallbacks),o!=null&&typeof o.then==`function`){let t=this._component.mountCallbacks.splice(0);this._component.phase=a.ComponentPhase.LOADING,e.loading&&(this._component.templateResult=e.loading()),this._runSetupAsync(o,t,this._component.generation)}else this._component.templateResult=o??null,this._component.phase=a.ComponentPhase.SETUP_DONE}catch(e){let t=this._handleSetupError(e);if(t)this._component.templateResult=t,this._component.phase=a.ComponentPhase.SETUP_DONE;else throw this._component.phase=a.ComponentPhase.UNINITIALIZED,e}}_isStale(e){return this._component.generation!==e||!this.isConnected}async _runSetupAsync(t,n,r){try{let i=await t;if(this._isStale(r)){e.warn(`<${this.localName}> async setup result discarded — element disconnected before setup resolved.`);return}this._component.templateResult=i??null,this._component.phase=a.ComponentPhase.SETUP_DONE,this._component.mountCallbacks.push(...n),i&&this._applyResult(i),this._scheduleMountCallbacks()}catch(t){if(this._isStale(r)){e.warn(`<${this.localName}> async setup error discarded — element disconnected before setup resolved.`);return}let n=this._handleSetupError(t,`async-setup`);n?(this._component.templateResult=n,this._component.phase=a.ComponentPhase.SETUP_DONE,this._applyResult(n)):this._component.phase=a.ComponentPhase.UNINITIALIZED}}_applyResult(e){e&&((this.shadowRoot??this).replaceChildren(e.fragment),this._component.scope.run(()=>{e.apply(n.onCleanup)}))}_init(){this._applyStyles(),this._mountTemplate(),this._component.phase===a.ComponentPhase.SETUP_DONE&&this._scheduleMountCallbacks()}_applyStyles(){let e=this.constructor._definition;this.shadowRoot&&e?.styles?.length&&(this.shadowRoot.adoptedStyleSheets=e.styles.map(r.loadStylesheet))}_mountTemplate(){let e=this._component.templateResult;e&&this._applyResult(e)}_scheduleMountCallbacks(){if(this._component.mountCallbacks.length===0)return;let e=this._component.generation;queueMicrotask(()=>{if(this._isStale(e))return;let t=this._component.mountCallbacks.splice(0);for(let e of t)try{let t={element:this,mountCallbacks:[]};this._component.scope.run(()=>{n.runWithContext(t,()=>{let t=e();typeof t==`function`&&n.onCleanup(t)})}),t.mountCallbacks.length>0&&this._component.mountCallbacks.push(...t.mountCallbacks)}catch(e){this._handleSetupError(e,`mounted`)}this._component.mountCallbacks.length>0&&this._scheduleMountCallbacks()})}};exports.BaseElement=c;
|
|
1
|
+
const e=require("./_dev.cjs"),t=require("./errors.cjs");require("./types/bindings.cjs");const n=require("./runtime.cjs"),r=require("./utils/css.cjs"),i=require("./props.cjs"),a=require("./types.cjs");let o=require("@vielzeug/ripple");var s=()=>({formResetCallbacks:[],generation:0,mountCallbacks:[],phase:a.ComponentPhase.UNINITIALIZED,scope:(0,o.scope)(),templateResult:null}),c=class extends HTMLElement{static _definition;static _normalizedPropDefs;static formAssociated=!1;static observedAttributes=[];_component;constructor(){super();let e=this.constructor._definition;e?.shadow!==!1&&this.attachShadow({mode:`open`,...e?.shadow}),this._component=s()}connectedCallback(){(0,o.untrack)(()=>{this._component.phase===a.ComponentPhase.UNINITIALIZED&&this._runSetup(),this._init()}),this.dispatchEvent(new CustomEvent(a.LIFECYCLE_EVENTS.CONNECT,{bubbles:!1,composed:!1}))}attributeChangedCallback(e,t,n){if(t===n)return;let r=i.getPropMeta(this,e);if(!r)return;let a=r.parse(n);Object.is((0,o.untrack)(()=>r.signal.value),a)||(r.signal.value=a)}disconnectedCallback(){this._component.generation++,this._component.phase=a.ComponentPhase.UNMOUNTED,this.dispatchEvent(new CustomEvent(a.LIFECYCLE_EVENTS.DISCONNECT,{bubbles:!1,composed:!1})),this._component.scope.dispose(),this._component.formResetCallbacks=[],this._component.mountCallbacks=[],this._component.phase=a.ComponentPhase.UNINITIALIZED,this._component.scope=(0,o.scope)(),this._component.templateResult=null}formResetCallback(){for(let e of this._component.formResetCallbacks)try{e()}catch(e){this._handleSetupError(e,`form-reset`)}}_handleSetupError(e,n=`setup`){let r=e instanceof Error?e:Error(String(e)),i=new t.OreLifecycleError(`<${this.localName}> failed during ${this._component.phase} (${n})`,{cause:r,component:this.localName,phase:n}),a=this.constructor._definition;if(a?.onError)try{return a.onError(i,this)}catch{}t.reportRuntimeError(i,this)}_runSetup(){this._component.phase=a.ComponentPhase.SETUP_RUNNING;let e=this.constructor._definition,t=this.constructor._normalizedPropDefs,r={element:this,formResetCallbacks:[],mountCallbacks:[]};try{let o;if(this._component.scope.run(()=>{o=n.runWithContext(r,()=>{let n=t?i.createProps(this,t):{};return e.setup(n)})}),this._component.mountCallbacks.push(...r.mountCallbacks),this._component.formResetCallbacks.push(...r.formResetCallbacks),o!=null&&typeof o.then==`function`){let t=this._component.mountCallbacks.splice(0);this._component.phase=a.ComponentPhase.LOADING,e.loading&&(this._component.templateResult=e.loading()),this._runSetupAsync(o,t,this._component.generation)}else this._component.templateResult=o??null,this._component.phase=a.ComponentPhase.SETUP_DONE}catch(e){let t=this._handleSetupError(e);if(t)this._component.templateResult=t,this._component.phase=a.ComponentPhase.SETUP_DONE;else throw this._component.phase=a.ComponentPhase.UNINITIALIZED,e}}_isStale(e){return this._component.generation!==e||!this.isConnected}async _runSetupAsync(t,n,r){try{let i=await t;if(this._isStale(r)){e.warn(`<${this.localName}> async setup result discarded — element disconnected before setup resolved.`);return}this._component.templateResult=i??null,this._component.phase=a.ComponentPhase.SETUP_DONE,this._component.mountCallbacks.push(...n),i&&this._applyResult(i),this._scheduleMountCallbacks()}catch(t){if(this._isStale(r)){e.warn(`<${this.localName}> async setup error discarded — element disconnected before setup resolved.`);return}let n=this._handleSetupError(t,`async-setup`);n?(this._component.templateResult=n,this._component.phase=a.ComponentPhase.SETUP_DONE,this._applyResult(n)):this._component.phase=a.ComponentPhase.UNINITIALIZED}}_applyResult(e){e&&((this.shadowRoot??this).replaceChildren(e.fragment),this._component.scope.run(()=>{e.apply(n.onCleanup)}))}_init(){this._applyStyles(),this._mountTemplate(),this._component.phase===a.ComponentPhase.SETUP_DONE&&this._scheduleMountCallbacks()}_applyStyles(){let e=this.constructor._definition;this.shadowRoot&&e?.styles?.length&&(this.shadowRoot.adoptedStyleSheets=e.styles.map(r.loadStylesheet))}_mountTemplate(){let e=this._component.templateResult;e&&this._applyResult(e)}_scheduleMountCallbacks(){if(this._component.mountCallbacks.length===0)return;let e=this._component.generation;queueMicrotask(()=>{if(this._isStale(e))return;let t=this._component.mountCallbacks.splice(0);for(let e of t)try{let t={element:this,formResetCallbacks:[],mountCallbacks:[]};this._component.scope.run(()=>{n.runWithContext(t,()=>{let t=e();typeof t==`function`&&n.onCleanup(t)})}),t.mountCallbacks.length>0&&this._component.mountCallbacks.push(...t.mountCallbacks),t.formResetCallbacks.length>0&&this._component.formResetCallbacks.push(...t.formResetCallbacks)}catch(e){this._handleSetupError(e,`mounted`)}this._component.mountCallbacks.length>0&&this._scheduleMountCallbacks()})}};exports.BaseElement=c;
|
|
2
2
|
//# sourceMappingURL=base-element.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-element.cjs","names":["s","c","o","i","a","t","e","r","l"],"sources":["../../../../ore/dist/base-element.js"],"sourcesContent":["import{warn as e}from\"./_dev.js\";import{OreLifecycleError as t,reportRuntimeError as n}from\"./errors.js\";import\"./types/bindings.js\";import{onCleanup as r,runWithContext as i}from\"./runtime.js\";import{createProps as a,getPropMeta as o}from\"./props.js\";import{ComponentPhase as s,LIFECYCLE_EVENTS as c}from\"./types.js\";import{loadStylesheet as l}from\"./utils/css.js\";import{scope as u,untrack as d}from\"@vielzeug/ripple\";var f=()=>({generation:0,mountCallbacks:[],phase:s.UNINITIALIZED,scope:u(),templateResult:null}),p=class extends HTMLElement{static _definition;static _normalizedPropDefs;static formAssociated=!1;static observedAttributes=[];_component;constructor(){super();let e=this.constructor._definition;e?.shadow!==!1&&this.attachShadow({mode:`open`,...e?.shadow}),this._component=f()}connectedCallback(){d(()=>{this._component.phase===s.UNINITIALIZED&&this._runSetup(),this._init()}),this.dispatchEvent(new CustomEvent(c.CONNECT,{bubbles:!1,composed:!1}))}attributeChangedCallback(e,t,n){if(t===n)return;let r=o(this,e);if(!r)return;let i=r.parse(n);Object.is(d(()=>r.signal.value),i)||(r.signal.value=i)}disconnectedCallback(){this._component.generation++,this._component.phase=s.UNMOUNTED,this.dispatchEvent(new CustomEvent(c.DISCONNECT,{bubbles:!1,composed:!1})),this._component.scope.dispose(),this._component.mountCallbacks=[],this._component.phase=s.UNINITIALIZED,this._component.scope=u(),this._component.templateResult=null}_handleSetupError(e,r=`setup`){let i=e instanceof Error?e:Error(String(e)),a=new t(`<${this.localName}> failed during ${this._component.phase} (${r})`,{cause:i,component:this.localName,phase:r}),o=this.constructor._definition;if(o?.onError)try{return o.onError(a,this)}catch{}n(a,this)}_runSetup(){this._component.phase=s.SETUP_RUNNING;let e=this.constructor._definition,t=this.constructor._normalizedPropDefs,n={element:this,mountCallbacks:[]};try{let r;if(this._component.scope.run(()=>{r=i(n,()=>{let n=t?a(this,t):{};return e.setup(n)})}),this._component.mountCallbacks.push(...n.mountCallbacks),r!=null&&typeof r.then==`function`){let t=this._component.mountCallbacks.splice(0);this._component.phase=s.LOADING,e.loading&&(this._component.templateResult=e.loading()),this._runSetupAsync(r,t,this._component.generation)}else this._component.templateResult=r??null,this._component.phase=s.SETUP_DONE}catch(e){let t=this._handleSetupError(e);if(t)this._component.templateResult=t,this._component.phase=s.SETUP_DONE;else throw this._component.phase=s.UNINITIALIZED,e}}_isStale(e){return this._component.generation!==e||!this.isConnected}async _runSetupAsync(t,n,r){try{let i=await t;if(this._isStale(r)){e(`<${this.localName}> async setup result discarded — element disconnected before setup resolved.`);return}this._component.templateResult=i??null,this._component.phase=s.SETUP_DONE,this._component.mountCallbacks.push(...n),i&&this._applyResult(i),this._scheduleMountCallbacks()}catch(t){if(this._isStale(r)){e(`<${this.localName}> async setup error discarded — element disconnected before setup resolved.`);return}let n=this._handleSetupError(t,`async-setup`);n?(this._component.templateResult=n,this._component.phase=s.SETUP_DONE,this._applyResult(n)):this._component.phase=s.UNINITIALIZED}}_applyResult(e){e&&((this.shadowRoot??this).replaceChildren(e.fragment),this._component.scope.run(()=>{e.apply(r)}))}_init(){this._applyStyles(),this._mountTemplate(),this._component.phase===s.SETUP_DONE&&this._scheduleMountCallbacks()}_applyStyles(){let e=this.constructor._definition;this.shadowRoot&&e?.styles?.length&&(this.shadowRoot.adoptedStyleSheets=e.styles.map(l))}_mountTemplate(){let e=this._component.templateResult;e&&this._applyResult(e)}_scheduleMountCallbacks(){if(this._component.mountCallbacks.length===0)return;let e=this._component.generation;queueMicrotask(()=>{if(this._isStale(e))return;let t=this._component.mountCallbacks.splice(0);for(let e of t)try{let t={element:this,mountCallbacks:[]};this._component.scope.run(()=>{i(t,()=>{let t=e();typeof t==`function`&&r(t)})}),t.mountCallbacks.length>0&&this._component.mountCallbacks.push(...t.mountCallbacks)}catch(e){this._handleSetupError(e,`mounted`)}this._component.mountCallbacks.length>0&&this._scheduleMountCallbacks()})}};export{p as BaseElement};\n//# sourceMappingURL=base-element.js.map"],"mappings":"0OAAoa,IAAI,OAAO,CAAC,WAAW,EAAE,eAAe,CAAC,EAAE,MAAMA,EAAAA,eAAE,cAAc,OAAA,EAAA,EAAA,MAAA,CAAQ,EAAE,eAAe,IAAI,GAAG,EAAE,cAAc,WAAW,CAAC,OAAO,YAAY,OAAO,oBAAoB,OAAO,eAAe,CAAC,EAAE,OAAO,mBAAmB,CAAC,EAAE,WAAW,aAAa,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,YAAY,YAAY,GAAG,SAAS,CAAC,GAAG,KAAK,aAAa,CAAC,KAAK,OAAO,GAAG,GAAG,MAAM,CAAC,EAAE,KAAK,WAAW,EAAE,CAAC,CAAC,mBAAmB,EAAC,EAAA,EAAA,QAAA,KAAM,CAAC,KAAK,WAAW,QAAQA,EAAAA,eAAE,eAAe,KAAK,UAAU,EAAE,KAAK,MAAM,CAAC,CAAC,EAAE,KAAK,cAAc,IAAI,YAAYC,EAAAA,iBAAE,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,yBAAyB,EAAE,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,IAAI,EAAEC,EAAAA,YAAE,KAAK,CAAC,EAAE,GAAG,CAAC,EAAE,OAAO,IAAI,EAAE,EAAE,MAAM,CAAC,EAAE,OAAO,IAAA,EAAA,EAAA,QAAA,KAAS,EAAE,OAAO,KAAK,EAAE,CAAC,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B,EAAE,QAAQ,EAAE,KAAK,WAAW,MAAM,QAAQ,CAAC,EAAE,MAAMO,EAAAA,SAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,KAAK,aAAa,EAAE,KAAK,eAAe,EAAE,KAAK,WAAW,QAAQP,EAAAA,eAAE,YAAY,KAAK,wBAAwB,CAAC,CAAC,cAAc,CAAC,IAAI,EAAE,KAAK,YAAY,YAAY,KAAK,YAAY,GAAG,QAAQ,SAAS,KAAK,WAAW,mBAAmB,EAAE,OAAO,IAAIQ,EAAAA,cAAC,EAAE,CAAC,gBAAgB,CAAC,IAAI,EAAE,KAAK,WAAW,eAAe,GAAG,KAAK,aAAa,CAAC,CAAC,CAAC,yBAAyB,CAAC,GAAG,KAAK,WAAW,eAAe,SAAS,EAAE,OAAO,IAAI,EAAE,KAAK,WAAW,WAAW,mBAAmB,CAAC,GAAG,KAAK,SAAS,CAAC,EAAE,OAAO,IAAI,EAAE,KAAK,WAAW,eAAe,OAAO,CAAC,EAAE,IAAI,IAAI,KAAK,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC,QAAQ,KAAK,eAAe,CAAC,CAAC,EAAE,KAAK,WAAW,MAAM,QAAQ,CAAC,EAAA,eAAE,MAAM,CAAC,IAAI,EAAE,EAAE,EAAE,OAAO,GAAG,YAAYD,EAAAA,UAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,eAAe,OAAO,GAAG,KAAK,WAAW,eAAe,KAAK,GAAG,EAAE,cAAc,CAAC,OAAO,EAAE,CAAC,KAAK,kBAAkB,EAAE,SAAS,CAAC,CAAC,KAAK,WAAW,eAAe,OAAO,GAAG,KAAK,wBAAwB,CAAC,CAAC,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"base-element.cjs","names":["s","c","o","i","a","t","e","r","l"],"sources":["../../../../ore/dist/base-element.js"],"sourcesContent":["import{warn as e}from\"./_dev.js\";import{OreLifecycleError as t,reportRuntimeError as n}from\"./errors.js\";import\"./types/bindings.js\";import{onCleanup as r,runWithContext as i}from\"./runtime.js\";import{createProps as a,getPropMeta as o}from\"./props.js\";import{ComponentPhase as s,LIFECYCLE_EVENTS as c}from\"./types.js\";import{loadStylesheet as l}from\"./utils/css.js\";import{scope as u,untrack as d}from\"@vielzeug/ripple\";var f=()=>({formResetCallbacks:[],generation:0,mountCallbacks:[],phase:s.UNINITIALIZED,scope:u(),templateResult:null}),p=class extends HTMLElement{static _definition;static _normalizedPropDefs;static formAssociated=!1;static observedAttributes=[];_component;constructor(){super();let e=this.constructor._definition;e?.shadow!==!1&&this.attachShadow({mode:`open`,...e?.shadow}),this._component=f()}connectedCallback(){d(()=>{this._component.phase===s.UNINITIALIZED&&this._runSetup(),this._init()}),this.dispatchEvent(new CustomEvent(c.CONNECT,{bubbles:!1,composed:!1}))}attributeChangedCallback(e,t,n){if(t===n)return;let r=o(this,e);if(!r)return;let i=r.parse(n);Object.is(d(()=>r.signal.value),i)||(r.signal.value=i)}disconnectedCallback(){this._component.generation++,this._component.phase=s.UNMOUNTED,this.dispatchEvent(new CustomEvent(c.DISCONNECT,{bubbles:!1,composed:!1})),this._component.scope.dispose(),this._component.formResetCallbacks=[],this._component.mountCallbacks=[],this._component.phase=s.UNINITIALIZED,this._component.scope=u(),this._component.templateResult=null}formResetCallback(){for(let e of this._component.formResetCallbacks)try{e()}catch(e){this._handleSetupError(e,`form-reset`)}}_handleSetupError(e,r=`setup`){let i=e instanceof Error?e:Error(String(e)),a=new t(`<${this.localName}> failed during ${this._component.phase} (${r})`,{cause:i,component:this.localName,phase:r}),o=this.constructor._definition;if(o?.onError)try{return o.onError(a,this)}catch{}n(a,this)}_runSetup(){this._component.phase=s.SETUP_RUNNING;let e=this.constructor._definition,t=this.constructor._normalizedPropDefs,n={element:this,formResetCallbacks:[],mountCallbacks:[]};try{let r;if(this._component.scope.run(()=>{r=i(n,()=>{let n=t?a(this,t):{};return e.setup(n)})}),this._component.mountCallbacks.push(...n.mountCallbacks),this._component.formResetCallbacks.push(...n.formResetCallbacks),r!=null&&typeof r.then==`function`){let t=this._component.mountCallbacks.splice(0);this._component.phase=s.LOADING,e.loading&&(this._component.templateResult=e.loading()),this._runSetupAsync(r,t,this._component.generation)}else this._component.templateResult=r??null,this._component.phase=s.SETUP_DONE}catch(e){let t=this._handleSetupError(e);if(t)this._component.templateResult=t,this._component.phase=s.SETUP_DONE;else throw this._component.phase=s.UNINITIALIZED,e}}_isStale(e){return this._component.generation!==e||!this.isConnected}async _runSetupAsync(t,n,r){try{let i=await t;if(this._isStale(r)){e(`<${this.localName}> async setup result discarded — element disconnected before setup resolved.`);return}this._component.templateResult=i??null,this._component.phase=s.SETUP_DONE,this._component.mountCallbacks.push(...n),i&&this._applyResult(i),this._scheduleMountCallbacks()}catch(t){if(this._isStale(r)){e(`<${this.localName}> async setup error discarded — element disconnected before setup resolved.`);return}let n=this._handleSetupError(t,`async-setup`);n?(this._component.templateResult=n,this._component.phase=s.SETUP_DONE,this._applyResult(n)):this._component.phase=s.UNINITIALIZED}}_applyResult(e){e&&((this.shadowRoot??this).replaceChildren(e.fragment),this._component.scope.run(()=>{e.apply(r)}))}_init(){this._applyStyles(),this._mountTemplate(),this._component.phase===s.SETUP_DONE&&this._scheduleMountCallbacks()}_applyStyles(){let e=this.constructor._definition;this.shadowRoot&&e?.styles?.length&&(this.shadowRoot.adoptedStyleSheets=e.styles.map(l))}_mountTemplate(){let e=this._component.templateResult;e&&this._applyResult(e)}_scheduleMountCallbacks(){if(this._component.mountCallbacks.length===0)return;let e=this._component.generation;queueMicrotask(()=>{if(this._isStale(e))return;let t=this._component.mountCallbacks.splice(0);for(let e of t)try{let t={element:this,formResetCallbacks:[],mountCallbacks:[]};this._component.scope.run(()=>{i(t,()=>{let t=e();typeof t==`function`&&r(t)})}),t.mountCallbacks.length>0&&this._component.mountCallbacks.push(...t.mountCallbacks),t.formResetCallbacks.length>0&&this._component.formResetCallbacks.push(...t.formResetCallbacks)}catch(e){this._handleSetupError(e,`mounted`)}this._component.m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
|
|
8
8
|
import { scope as u, untrack as d } from "@vielzeug/ripple";
|
|
9
9
|
//#region ../ore/dist/base-element.js
|
|
10
10
|
var f = () => ({
|
|
11
|
+
formResetCallbacks: [],
|
|
11
12
|
generation: 0,
|
|
12
13
|
mountCallbacks: [],
|
|
13
14
|
phase: c.UNINITIALIZED,
|
|
@@ -46,7 +47,14 @@ var f = () => ({
|
|
|
46
47
|
this._component.generation++, this._component.phase = c.UNMOUNTED, this.dispatchEvent(new CustomEvent(l.DISCONNECT, {
|
|
47
48
|
bubbles: !1,
|
|
48
49
|
composed: !1
|
|
49
|
-
})), this._component.scope.dispose(), this._component.mountCallbacks = [], this._component.phase = c.UNINITIALIZED, this._component.scope = u(), this._component.templateResult = null;
|
|
50
|
+
})), this._component.scope.dispose(), this._component.formResetCallbacks = [], this._component.mountCallbacks = [], this._component.phase = c.UNINITIALIZED, this._component.scope = u(), this._component.templateResult = null;
|
|
51
|
+
}
|
|
52
|
+
formResetCallback() {
|
|
53
|
+
for (let e of this._component.formResetCallbacks) try {
|
|
54
|
+
e();
|
|
55
|
+
} catch (e) {
|
|
56
|
+
this._handleSetupError(e, "form-reset");
|
|
57
|
+
}
|
|
50
58
|
}
|
|
51
59
|
_handleSetupError(e, r = "setup") {
|
|
52
60
|
let i = e instanceof Error ? e : Error(String(e)), a = new t(`<${this.localName}> failed during ${this._component.phase} (${r})`, {
|
|
@@ -63,6 +71,7 @@ var f = () => ({
|
|
|
63
71
|
this._component.phase = c.SETUP_RUNNING;
|
|
64
72
|
let e = this.constructor._definition, t = this.constructor._normalizedPropDefs, n = {
|
|
65
73
|
element: this,
|
|
74
|
+
formResetCallbacks: [],
|
|
66
75
|
mountCallbacks: []
|
|
67
76
|
};
|
|
68
77
|
try {
|
|
@@ -72,7 +81,7 @@ var f = () => ({
|
|
|
72
81
|
let n = t ? o(this, t) : {};
|
|
73
82
|
return e.setup(n);
|
|
74
83
|
});
|
|
75
|
-
}), this._component.mountCallbacks.push(...n.mountCallbacks), r != null && typeof r.then == "function") {
|
|
84
|
+
}), this._component.mountCallbacks.push(...n.mountCallbacks), this._component.formResetCallbacks.push(...n.formResetCallbacks), r != null && typeof r.then == "function") {
|
|
76
85
|
let t = this._component.mountCallbacks.splice(0);
|
|
77
86
|
this._component.phase = c.LOADING, e.loading && (this._component.templateResult = e.loading()), this._runSetupAsync(r, t, this._component.generation);
|
|
78
87
|
} else this._component.templateResult = r ?? null, this._component.phase = c.SETUP_DONE;
|
|
@@ -127,6 +136,7 @@ var f = () => ({
|
|
|
127
136
|
for (let e of t) try {
|
|
128
137
|
let t = {
|
|
129
138
|
element: this,
|
|
139
|
+
formResetCallbacks: [],
|
|
130
140
|
mountCallbacks: []
|
|
131
141
|
};
|
|
132
142
|
this._component.scope.run(() => {
|
|
@@ -134,7 +144,7 @@ var f = () => ({
|
|
|
134
144
|
let t = e();
|
|
135
145
|
typeof t == "function" && r(t);
|
|
136
146
|
});
|
|
137
|
-
}), t.mountCallbacks.length > 0 && this._component.mountCallbacks.push(...t.mountCallbacks);
|
|
147
|
+
}), t.mountCallbacks.length > 0 && this._component.mountCallbacks.push(...t.mountCallbacks), t.formResetCallbacks.length > 0 && this._component.formResetCallbacks.push(...t.formResetCallbacks);
|
|
138
148
|
} catch (e) {
|
|
139
149
|
this._handleSetupError(e, "mounted");
|
|
140
150
|
}
|