739 lines
27 KiB
JavaScript
739 lines
27 KiB
JavaScript
import { c as compute_rest_props, a as subscribe, j as hasContext, b as getContext, s as setContext, n as noop } from './lifecycle-px-3doLe.js';
|
|
import { c as create_ssr_component, s as spread, d as escape_attribute_value, f as escape_object, b as add_attribute, v as validate_component, a as each, e as escape } from './ssr-ipqebOFl.js';
|
|
import { c as cn } from './button-CeH7Xj2c.js';
|
|
import { m as makeElement, d as addMeltEventListener, o as omit, l as disabledAttr, b as executeCallbacks, s as styleToString, c as createElHelpers, k as kbd } from './index3-4H3SMWet.js';
|
|
import { c as createDispatcher, a as createBitAttrs, r as removeUndefined, g as getOptionUpdater, e as toWritableStores, o as overridable, n as nanoid } from './index-pRP-dlMc.js';
|
|
import { w as writable } from './index2-D4yenS_5.js';
|
|
import 'clsx';
|
|
|
|
const globals = typeof window !== "undefined" ? window : typeof globalThis !== "undefined" ? globalThis : (
|
|
// @ts-ignore Node typings have this
|
|
global
|
|
);
|
|
function createLabel() {
|
|
const root = makeElement("label", {
|
|
action: (node) => {
|
|
const mouseDown = addMeltEventListener(node, "mousedown", (e) => {
|
|
if (!e.defaultPrevented && e.detail > 1) {
|
|
e.preventDefault();
|
|
}
|
|
});
|
|
return {
|
|
destroy: mouseDown
|
|
};
|
|
}
|
|
});
|
|
return {
|
|
elements: {
|
|
root
|
|
}
|
|
};
|
|
}
|
|
const defaults = {
|
|
defaultChecked: false,
|
|
disabled: false,
|
|
required: false,
|
|
name: "",
|
|
value: ""
|
|
};
|
|
const { name } = createElHelpers("switch");
|
|
function createSwitch(props) {
|
|
const propsWithDefaults = { ...defaults, ...props };
|
|
const options = toWritableStores(omit(propsWithDefaults, "checked"));
|
|
const { disabled, required, name: nameStore, value } = options;
|
|
const checkedWritable = propsWithDefaults.checked ?? writable(propsWithDefaults.defaultChecked);
|
|
const checked = overridable(checkedWritable, propsWithDefaults?.onCheckedChange);
|
|
function toggleSwitch() {
|
|
if (disabled.get())
|
|
return;
|
|
checked.update((prev) => !prev);
|
|
}
|
|
const root = makeElement(name(), {
|
|
stores: [checked, disabled, required],
|
|
returned: ([$checked, $disabled, $required]) => {
|
|
return {
|
|
"data-disabled": disabledAttr($disabled),
|
|
disabled: disabledAttr($disabled),
|
|
"data-state": $checked ? "checked" : "unchecked",
|
|
type: "button",
|
|
role: "switch",
|
|
"aria-checked": $checked ? "true" : "false",
|
|
"aria-required": $required ? "true" : void 0
|
|
};
|
|
},
|
|
action(node) {
|
|
const unsub = executeCallbacks(addMeltEventListener(node, "click", () => {
|
|
toggleSwitch();
|
|
}), addMeltEventListener(node, "keydown", (e) => {
|
|
if (e.key !== kbd.ENTER && e.key !== kbd.SPACE)
|
|
return;
|
|
e.preventDefault();
|
|
toggleSwitch();
|
|
}));
|
|
return {
|
|
destroy: unsub
|
|
};
|
|
}
|
|
});
|
|
const input = makeElement(name("input"), {
|
|
stores: [checked, nameStore, required, disabled, value],
|
|
returned: ([$checked, $name, $required, $disabled, $value]) => {
|
|
return {
|
|
type: "checkbox",
|
|
"aria-hidden": true,
|
|
hidden: true,
|
|
tabindex: -1,
|
|
name: $name,
|
|
value: $value,
|
|
checked: $checked,
|
|
required: $required,
|
|
disabled: disabledAttr($disabled),
|
|
style: styleToString({
|
|
position: "absolute",
|
|
opacity: 0,
|
|
"pointer-events": "none",
|
|
margin: 0,
|
|
transform: "translateX(-100%)"
|
|
})
|
|
};
|
|
}
|
|
});
|
|
return {
|
|
elements: {
|
|
root,
|
|
input
|
|
},
|
|
states: {
|
|
checked
|
|
},
|
|
options
|
|
};
|
|
}
|
|
function getLabelData() {
|
|
const NAME = "label";
|
|
const PARTS = ["root"];
|
|
const getAttrs = createBitAttrs(NAME, PARTS);
|
|
return {
|
|
NAME,
|
|
getAttrs
|
|
};
|
|
}
|
|
const Label$1 = create_ssr_component(($$result, $$props, $$bindings, slots) => {
|
|
let builder;
|
|
let $$restProps = compute_rest_props($$props, ["asChild", "el"]);
|
|
let $root, $$unsubscribe_root;
|
|
let { asChild = false } = $$props;
|
|
let { el = void 0 } = $$props;
|
|
const { elements: { root } } = createLabel();
|
|
$$unsubscribe_root = subscribe(root, (value) => $root = value);
|
|
createDispatcher();
|
|
const { getAttrs } = getLabelData();
|
|
const attrs = getAttrs("root");
|
|
if ($$props.asChild === void 0 && $$bindings.asChild && asChild !== void 0)
|
|
$$bindings.asChild(asChild);
|
|
if ($$props.el === void 0 && $$bindings.el && el !== void 0)
|
|
$$bindings.el(el);
|
|
builder = $root;
|
|
{
|
|
Object.assign(builder, attrs);
|
|
}
|
|
$$unsubscribe_root();
|
|
return `${asChild ? `${slots.default ? slots.default({ builder }) : ``}` : `<label${spread([escape_object(builder), escape_object($$restProps)], {})}${add_attribute("this", el, 0)}>${slots.default ? slots.default({ builder }) : ``}</label>`}`;
|
|
});
|
|
function getSwitchData() {
|
|
const NAME = "switch";
|
|
const PARTS = ["root", "input", "thumb"];
|
|
return {
|
|
NAME,
|
|
PARTS
|
|
};
|
|
}
|
|
function setCtx(props) {
|
|
const { NAME, PARTS } = getSwitchData();
|
|
const getAttrs = createBitAttrs(NAME, PARTS);
|
|
const Switch2 = { ...createSwitch(removeUndefined(props)), getAttrs };
|
|
setContext(NAME, Switch2);
|
|
return {
|
|
...Switch2,
|
|
updateOption: getOptionUpdater(Switch2.options)
|
|
};
|
|
}
|
|
function getCtx() {
|
|
const { NAME } = getSwitchData();
|
|
return getContext(NAME);
|
|
}
|
|
const Switch_input = create_ssr_component(($$result, $$props, $$bindings, slots) => {
|
|
let inputValue;
|
|
let $$restProps = compute_rest_props($$props, ["el"]);
|
|
let $value, $$unsubscribe_value;
|
|
let $input, $$unsubscribe_input;
|
|
let $name, $$unsubscribe_name;
|
|
let $disabled, $$unsubscribe_disabled;
|
|
let $required, $$unsubscribe_required;
|
|
let { el = void 0 } = $$props;
|
|
const { elements: { input }, options: { value, name: name2, disabled, required } } = getCtx();
|
|
$$unsubscribe_input = subscribe(input, (value2) => $input = value2);
|
|
$$unsubscribe_value = subscribe(value, (value2) => $value = value2);
|
|
$$unsubscribe_name = subscribe(name2, (value2) => $name = value2);
|
|
$$unsubscribe_disabled = subscribe(disabled, (value2) => $disabled = value2);
|
|
$$unsubscribe_required = subscribe(required, (value2) => $required = value2);
|
|
if ($$props.el === void 0 && $$bindings.el && el !== void 0)
|
|
$$bindings.el(el);
|
|
inputValue = $value === void 0 || $value === "" ? "on" : $value;
|
|
$$unsubscribe_value();
|
|
$$unsubscribe_input();
|
|
$$unsubscribe_name();
|
|
$$unsubscribe_disabled();
|
|
$$unsubscribe_required();
|
|
return `<input${spread(
|
|
[
|
|
escape_object($input),
|
|
{ name: escape_attribute_value($name) },
|
|
{ disabled: $disabled || null },
|
|
{ required: $required || null },
|
|
{
|
|
value: escape_attribute_value(inputValue)
|
|
},
|
|
escape_object($$restProps)
|
|
],
|
|
{}
|
|
)}${add_attribute("this", el, 0)}>`;
|
|
});
|
|
const { Object: Object_1 } = globals;
|
|
const Switch$1 = create_ssr_component(($$result, $$props, $$bindings, slots) => {
|
|
let builder;
|
|
let attrs;
|
|
let $$restProps = compute_rest_props($$props, [
|
|
"checked",
|
|
"onCheckedChange",
|
|
"disabled",
|
|
"name",
|
|
"value",
|
|
"includeInput",
|
|
"required",
|
|
"asChild",
|
|
"inputAttrs",
|
|
"el"
|
|
]);
|
|
let $root, $$unsubscribe_root;
|
|
let { checked = void 0 } = $$props;
|
|
let { onCheckedChange = void 0 } = $$props;
|
|
let { disabled = void 0 } = $$props;
|
|
let { name: name2 = void 0 } = $$props;
|
|
let { value = void 0 } = $$props;
|
|
let { includeInput = true } = $$props;
|
|
let { required = void 0 } = $$props;
|
|
let { asChild = false } = $$props;
|
|
let { inputAttrs = void 0 } = $$props;
|
|
let { el = void 0 } = $$props;
|
|
const { elements: { root }, states: { checked: localChecked }, updateOption, getAttrs } = setCtx({
|
|
disabled,
|
|
name: name2,
|
|
value,
|
|
required,
|
|
defaultChecked: checked,
|
|
onCheckedChange: ({ next }) => {
|
|
if (checked !== next) {
|
|
onCheckedChange?.(next);
|
|
checked = next;
|
|
}
|
|
return next;
|
|
}
|
|
});
|
|
$$unsubscribe_root = subscribe(root, (value2) => $root = value2);
|
|
createDispatcher();
|
|
if ($$props.checked === void 0 && $$bindings.checked && checked !== void 0)
|
|
$$bindings.checked(checked);
|
|
if ($$props.onCheckedChange === void 0 && $$bindings.onCheckedChange && onCheckedChange !== void 0)
|
|
$$bindings.onCheckedChange(onCheckedChange);
|
|
if ($$props.disabled === void 0 && $$bindings.disabled && disabled !== void 0)
|
|
$$bindings.disabled(disabled);
|
|
if ($$props.name === void 0 && $$bindings.name && name2 !== void 0)
|
|
$$bindings.name(name2);
|
|
if ($$props.value === void 0 && $$bindings.value && value !== void 0)
|
|
$$bindings.value(value);
|
|
if ($$props.includeInput === void 0 && $$bindings.includeInput && includeInput !== void 0)
|
|
$$bindings.includeInput(includeInput);
|
|
if ($$props.required === void 0 && $$bindings.required && required !== void 0)
|
|
$$bindings.required(required);
|
|
if ($$props.asChild === void 0 && $$bindings.asChild && asChild !== void 0)
|
|
$$bindings.asChild(asChild);
|
|
if ($$props.inputAttrs === void 0 && $$bindings.inputAttrs && inputAttrs !== void 0)
|
|
$$bindings.inputAttrs(inputAttrs);
|
|
if ($$props.el === void 0 && $$bindings.el && el !== void 0)
|
|
$$bindings.el(el);
|
|
checked !== void 0 && localChecked.set(checked);
|
|
{
|
|
updateOption("disabled", disabled);
|
|
}
|
|
{
|
|
updateOption("name", name2);
|
|
}
|
|
{
|
|
updateOption("value", value);
|
|
}
|
|
{
|
|
updateOption("required", required);
|
|
}
|
|
builder = $root;
|
|
attrs = {
|
|
...getAttrs("root"),
|
|
"data-checked": checked ? "" : void 0
|
|
};
|
|
{
|
|
Object.assign(builder, attrs);
|
|
}
|
|
$$unsubscribe_root();
|
|
return `${asChild ? `${slots.default ? slots.default({ builder }) : ``}` : `<button${spread([escape_object(builder), { type: "button" }, escape_object($$restProps)], {})}${add_attribute("this", el, 0)}>${slots.default ? slots.default({ builder }) : ``}</button>`} ${includeInput ? `${validate_component(Switch_input, "SwitchInput").$$render($$result, Object_1.assign({}, inputAttrs), {}, {})}` : ``}`;
|
|
});
|
|
const Switch_thumb = create_ssr_component(($$result, $$props, $$bindings, slots) => {
|
|
let attrs;
|
|
let $$restProps = compute_rest_props($$props, ["asChild", "el"]);
|
|
let $checked, $$unsubscribe_checked;
|
|
let { asChild = false } = $$props;
|
|
let { el = void 0 } = $$props;
|
|
const { states: { checked }, getAttrs } = getCtx();
|
|
$$unsubscribe_checked = subscribe(checked, (value) => $checked = value);
|
|
if ($$props.asChild === void 0 && $$bindings.asChild && asChild !== void 0)
|
|
$$bindings.asChild(asChild);
|
|
if ($$props.el === void 0 && $$bindings.el && el !== void 0)
|
|
$$bindings.el(el);
|
|
attrs = {
|
|
...getAttrs("thumb"),
|
|
"data-state": $checked ? "checked" : "unchecked",
|
|
"data-checked": $checked ? "" : void 0
|
|
};
|
|
$$unsubscribe_checked();
|
|
return `${asChild ? `${slots.default ? slots.default({ attrs, checked: $checked }) : ``}` : `<span${spread([escape_object($$restProps), escape_object(attrs)], {})}${add_attribute("this", el, 0)}></span>`}`;
|
|
});
|
|
const Input = create_ssr_component(($$result, $$props, $$bindings, slots) => {
|
|
let $$restProps = compute_rest_props($$props, ["class", "value", "readonly"]);
|
|
let { class: className = void 0 } = $$props;
|
|
let { value = void 0 } = $$props;
|
|
let { readonly = void 0 } = $$props;
|
|
if ($$props.class === void 0 && $$bindings.class && className !== void 0)
|
|
$$bindings.class(className);
|
|
if ($$props.value === void 0 && $$bindings.value && value !== void 0)
|
|
$$bindings.value(value);
|
|
if ($$props.readonly === void 0 && $$bindings.readonly && readonly !== void 0)
|
|
$$bindings.readonly(readonly);
|
|
return `<input${spread(
|
|
[
|
|
{
|
|
class: escape_attribute_value(cn("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50", className))
|
|
},
|
|
{ readonly: readonly || null },
|
|
escape_object($$restProps)
|
|
],
|
|
{}
|
|
)}${add_attribute("value", value, 0)}>`;
|
|
});
|
|
const FORM_FIELD = Symbol("FORM_FIELD_CTX");
|
|
function setFormField(props) {
|
|
setContext(FORM_FIELD, props);
|
|
return props;
|
|
}
|
|
function getFormField() {
|
|
if (!hasContext(FORM_FIELD)) {
|
|
ctxError("Form.Field");
|
|
}
|
|
return getContext(FORM_FIELD);
|
|
}
|
|
const FORM_CONTROL = Symbol("FORM_CONTROL_CTX");
|
|
function setFormControl(props) {
|
|
setContext(FORM_CONTROL, props);
|
|
return props;
|
|
}
|
|
function getFormControl() {
|
|
if (!hasContext(FORM_CONTROL)) {
|
|
ctxError("<Control />");
|
|
}
|
|
return getContext(FORM_CONTROL);
|
|
}
|
|
function ctxError(ctx) {
|
|
throw new Error(`Unable to find \`${ctx}\` context. Did you forget to wrap the component in a \`${ctx}\`?`);
|
|
}
|
|
function getAriaDescribedBy({ fieldErrorsId = void 0, descriptionId = void 0, errors }) {
|
|
let describedBy = "";
|
|
if (descriptionId) {
|
|
describedBy += descriptionId + " ";
|
|
}
|
|
if (errors.length && fieldErrorsId) {
|
|
describedBy += fieldErrorsId;
|
|
}
|
|
return describedBy ? describedBy.trim() : void 0;
|
|
}
|
|
function getAriaRequired(constraints) {
|
|
if (!("required" in constraints))
|
|
return void 0;
|
|
return constraints.required ? "true" : void 0;
|
|
}
|
|
function getAriaInvalid(errors) {
|
|
return errors && errors.length ? "true" : void 0;
|
|
}
|
|
function getDataFsError(errors) {
|
|
return errors && errors.length ? "" : void 0;
|
|
}
|
|
function generateId() {
|
|
return nanoid(5);
|
|
}
|
|
function extractErrorArray(errors) {
|
|
if (Array.isArray(errors))
|
|
return errors;
|
|
if (typeof errors === "object" && "_errors" in errors) {
|
|
if (errors._errors !== void 0)
|
|
return errors._errors;
|
|
}
|
|
return [];
|
|
}
|
|
function getValueAtPath(path, obj) {
|
|
const keys = path.split(/[[\].]/).filter(Boolean);
|
|
let value = obj;
|
|
for (const key of keys) {
|
|
if (typeof value !== "object" || value === null) {
|
|
return void 0;
|
|
}
|
|
value = value[key];
|
|
}
|
|
return value;
|
|
}
|
|
const Field = create_ssr_component(($$result, $$props, $$bindings, slots) => {
|
|
let formErrors;
|
|
let formConstraints;
|
|
let formTainted;
|
|
let formData;
|
|
let $formTainted, $$unsubscribe_formTainted = noop, $$subscribe_formTainted = () => ($$unsubscribe_formTainted(), $$unsubscribe_formTainted = subscribe(formTainted, ($$value) => $formTainted = $$value), formTainted);
|
|
let $formConstraints, $$unsubscribe_formConstraints = noop, $$subscribe_formConstraints = () => ($$unsubscribe_formConstraints(), $$unsubscribe_formConstraints = subscribe(formConstraints, ($$value) => $formConstraints = $$value), formConstraints);
|
|
let $formErrors, $$unsubscribe_formErrors = noop, $$subscribe_formErrors = () => ($$unsubscribe_formErrors(), $$unsubscribe_formErrors = subscribe(formErrors, ($$value) => $formErrors = $$value), formErrors);
|
|
let $formData, $$unsubscribe_formData = noop, $$subscribe_formData = () => ($$unsubscribe_formData(), $$unsubscribe_formData = subscribe(formData, ($$value) => $formData = $$value), formData);
|
|
let $errors, $$unsubscribe_errors;
|
|
let $tainted, $$unsubscribe_tainted;
|
|
let { form } = $$props;
|
|
let { name: name2 } = $$props;
|
|
const field = {
|
|
name: writable(name2),
|
|
errors: writable([]),
|
|
constraints: writable({}),
|
|
tainted: writable(false),
|
|
fieldErrorsId: writable(),
|
|
descriptionId: writable(),
|
|
form
|
|
};
|
|
const { tainted, errors } = field;
|
|
$$unsubscribe_tainted = subscribe(tainted, (value) => $tainted = value);
|
|
$$unsubscribe_errors = subscribe(errors, (value) => $errors = value);
|
|
setFormField(field);
|
|
if ($$props.form === void 0 && $$bindings.form && form !== void 0)
|
|
$$bindings.form(form);
|
|
if ($$props.name === void 0 && $$bindings.name && name2 !== void 0)
|
|
$$bindings.name(name2);
|
|
$$subscribe_formErrors({ errors: formErrors, constraints: formConstraints, tainted: formTainted, form: formData } = form, $$subscribe_formConstraints(), $$subscribe_formTainted(), $$subscribe_formData());
|
|
{
|
|
field.name.set(name2);
|
|
}
|
|
{
|
|
field.errors.set(extractErrorArray(getValueAtPath(name2, $formErrors)));
|
|
}
|
|
{
|
|
field.constraints.set(getValueAtPath(name2, $formConstraints) ?? {});
|
|
}
|
|
{
|
|
field.tainted.set($formTainted ? getValueAtPath(name2, $formTainted) === true : false);
|
|
}
|
|
$$unsubscribe_formTainted();
|
|
$$unsubscribe_formConstraints();
|
|
$$unsubscribe_formErrors();
|
|
$$unsubscribe_formData();
|
|
$$unsubscribe_errors();
|
|
$$unsubscribe_tainted();
|
|
return ` ${slots.default ? slots.default({
|
|
value: $formData[name2],
|
|
errors: $errors,
|
|
tainted: $tainted,
|
|
constraints: $formConstraints[name2]
|
|
}) : ``}`;
|
|
});
|
|
const Control$1 = create_ssr_component(($$result, $$props, $$bindings, slots) => {
|
|
let errorAttr;
|
|
let attrs;
|
|
let labelAttrs;
|
|
let $idStore, $$unsubscribe_idStore;
|
|
let $constraints, $$unsubscribe_constraints;
|
|
let $errors, $$unsubscribe_errors;
|
|
let $descriptionId, $$unsubscribe_descriptionId;
|
|
let $fieldErrorsId, $$unsubscribe_fieldErrorsId;
|
|
let $name, $$unsubscribe_name;
|
|
let { id = generateId() } = $$props;
|
|
const { name: name2, fieldErrorsId, descriptionId, errors, constraints } = getFormField();
|
|
$$unsubscribe_name = subscribe(name2, (value) => $name = value);
|
|
$$unsubscribe_fieldErrorsId = subscribe(fieldErrorsId, (value) => $fieldErrorsId = value);
|
|
$$unsubscribe_descriptionId = subscribe(descriptionId, (value) => $descriptionId = value);
|
|
$$unsubscribe_errors = subscribe(errors, (value) => $errors = value);
|
|
$$unsubscribe_constraints = subscribe(constraints, (value) => $constraints = value);
|
|
const controlContext = {
|
|
id: writable(id),
|
|
attrs: writable(),
|
|
labelAttrs: writable()
|
|
};
|
|
const { id: idStore } = controlContext;
|
|
$$unsubscribe_idStore = subscribe(idStore, (value) => $idStore = value);
|
|
setFormControl(controlContext);
|
|
if ($$props.id === void 0 && $$bindings.id && id !== void 0)
|
|
$$bindings.id(id);
|
|
{
|
|
controlContext.id.set(id);
|
|
}
|
|
errorAttr = getDataFsError($errors);
|
|
attrs = {
|
|
name: $name,
|
|
id: $idStore,
|
|
"data-fs-error": errorAttr,
|
|
"aria-describedby": getAriaDescribedBy({
|
|
fieldErrorsId: $fieldErrorsId,
|
|
descriptionId: $descriptionId,
|
|
errors: $errors
|
|
}),
|
|
"aria-invalid": getAriaInvalid($errors),
|
|
"aria-required": getAriaRequired($constraints),
|
|
"data-fs-control": ""
|
|
};
|
|
labelAttrs = {
|
|
for: $idStore,
|
|
"data-fs-label": "",
|
|
"data-fs-error": errorAttr
|
|
};
|
|
{
|
|
controlContext.attrs.set(attrs);
|
|
}
|
|
{
|
|
controlContext.labelAttrs.set(labelAttrs);
|
|
}
|
|
$$unsubscribe_idStore();
|
|
$$unsubscribe_constraints();
|
|
$$unsubscribe_errors();
|
|
$$unsubscribe_descriptionId();
|
|
$$unsubscribe_fieldErrorsId();
|
|
$$unsubscribe_name();
|
|
return ` ${slots.default ? slots.default({ attrs }) : ``}`;
|
|
});
|
|
const Field_errors = create_ssr_component(($$result, $$props, $$bindings, slots) => {
|
|
let errorAttr;
|
|
let fieldErrorsAttrs;
|
|
let errorAttrs;
|
|
let $$restProps = compute_rest_props($$props, ["id", "asChild", "el"]);
|
|
let $fieldErrorsId, $$unsubscribe_fieldErrorsId;
|
|
let $errors, $$unsubscribe_errors;
|
|
const { fieldErrorsId, errors } = getFormField();
|
|
$$unsubscribe_fieldErrorsId = subscribe(fieldErrorsId, (value) => $fieldErrorsId = value);
|
|
$$unsubscribe_errors = subscribe(errors, (value) => $errors = value);
|
|
let { id = generateId() } = $$props;
|
|
let { asChild = false } = $$props;
|
|
let { el = void 0 } = $$props;
|
|
if ($$props.id === void 0 && $$bindings.id && id !== void 0)
|
|
$$bindings.id(id);
|
|
if ($$props.asChild === void 0 && $$bindings.asChild && asChild !== void 0)
|
|
$$bindings.asChild(asChild);
|
|
if ($$props.el === void 0 && $$bindings.el && el !== void 0)
|
|
$$bindings.el(el);
|
|
errorAttr = getDataFsError($errors);
|
|
{
|
|
fieldErrorsId.set(id);
|
|
}
|
|
fieldErrorsAttrs = {
|
|
id: $fieldErrorsId,
|
|
"data-fs-error": errorAttr,
|
|
"data-fs-field-errors": "",
|
|
"aria-live": "assertive",
|
|
...$$restProps
|
|
};
|
|
errorAttrs = {
|
|
"data-fs-field-error": "",
|
|
"data-fs-error": errorAttr
|
|
};
|
|
$$unsubscribe_fieldErrorsId();
|
|
$$unsubscribe_errors();
|
|
return ` ${asChild ? `${slots.default ? slots.default({
|
|
errors: $errors,
|
|
fieldErrorsAttrs,
|
|
errorAttrs
|
|
}) : ``}` : `<div${spread([escape_object(fieldErrorsAttrs)], {})}${add_attribute("this", el, 0)}>${slots.default ? slots.default({
|
|
errors: $errors,
|
|
fieldErrorsAttrs,
|
|
errorAttrs
|
|
}) : ` ${each($errors, (error) => {
|
|
return `<div${spread([escape_object(errorAttrs)], {})}>${escape(error)}</div>`;
|
|
})} `}</div>`}`;
|
|
});
|
|
const Label = create_ssr_component(($$result, $$props, $$bindings, slots) => {
|
|
let $$restProps = compute_rest_props($$props, ["class"]);
|
|
let { class: className = void 0 } = $$props;
|
|
if ($$props.class === void 0 && $$bindings.class && className !== void 0)
|
|
$$bindings.class(className);
|
|
return `${validate_component(Label$1, "LabelPrimitive.Root").$$render(
|
|
$$result,
|
|
Object.assign(
|
|
{},
|
|
{
|
|
class: cn("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70", className)
|
|
},
|
|
$$restProps
|
|
),
|
|
{},
|
|
{
|
|
default: () => {
|
|
return `${slots.default ? slots.default({}) : ``}`;
|
|
}
|
|
}
|
|
)}`;
|
|
});
|
|
const Form_label = create_ssr_component(($$result, $$props, $$bindings, slots) => {
|
|
let $$restProps = compute_rest_props($$props, ["class"]);
|
|
let $labelAttrs, $$unsubscribe_labelAttrs;
|
|
let { class: className = void 0 } = $$props;
|
|
const { labelAttrs } = getFormControl();
|
|
$$unsubscribe_labelAttrs = subscribe(labelAttrs, (value) => $labelAttrs = value);
|
|
if ($$props.class === void 0 && $$bindings.class && className !== void 0)
|
|
$$bindings.class(className);
|
|
$$unsubscribe_labelAttrs();
|
|
return `${validate_component(Label, "Label").$$render(
|
|
$$result,
|
|
Object.assign(
|
|
{},
|
|
$labelAttrs,
|
|
{
|
|
class: cn("data-[fs-error]:text-destructive", className)
|
|
},
|
|
$$restProps
|
|
),
|
|
{},
|
|
{
|
|
default: () => {
|
|
return `${slots.default ? slots.default({ labelAttrs }) : ``}`;
|
|
}
|
|
}
|
|
)}`;
|
|
});
|
|
const Form_field_errors = create_ssr_component(($$result, $$props, $$bindings, slots) => {
|
|
let $$restProps = compute_rest_props($$props, ["class", "errorClasses"]);
|
|
let { class: className = void 0 } = $$props;
|
|
let { errorClasses = void 0 } = $$props;
|
|
if ($$props.class === void 0 && $$bindings.class && className !== void 0)
|
|
$$bindings.class(className);
|
|
if ($$props.errorClasses === void 0 && $$bindings.errorClasses && errorClasses !== void 0)
|
|
$$bindings.errorClasses(errorClasses);
|
|
return `${validate_component(Field_errors, "FormPrimitive.FieldErrors").$$render(
|
|
$$result,
|
|
Object.assign(
|
|
{},
|
|
{
|
|
class: cn("text-sm font-medium text-destructive", className)
|
|
},
|
|
$$restProps
|
|
),
|
|
{},
|
|
{
|
|
default: ({ errors, fieldErrorsAttrs, errorAttrs }) => {
|
|
return `${slots.default ? slots.default({ errors, fieldErrorsAttrs, errorAttrs }) : ` ${each(errors, (error) => {
|
|
return `<div${spread(
|
|
[
|
|
escape_object(errorAttrs),
|
|
{
|
|
class: escape_attribute_value(cn(errorClasses))
|
|
}
|
|
],
|
|
{}
|
|
)}>${escape(error)}</div>`;
|
|
})} `}`;
|
|
}
|
|
}
|
|
)}`;
|
|
});
|
|
const Form_field = create_ssr_component(($$result, $$props, $$bindings, slots) => {
|
|
let { form } = $$props;
|
|
let { name: name2 } = $$props;
|
|
let { class: className = void 0 } = $$props;
|
|
if ($$props.form === void 0 && $$bindings.form && form !== void 0)
|
|
$$bindings.form(form);
|
|
if ($$props.name === void 0 && $$bindings.name && name2 !== void 0)
|
|
$$bindings.name(name2);
|
|
if ($$props.class === void 0 && $$bindings.class && className !== void 0)
|
|
$$bindings.class(className);
|
|
return `${validate_component(Field, "FormPrimitive.Field").$$render($$result, { form, name: name2 }, {}, {
|
|
default: ({ constraints, errors, tainted, value }) => {
|
|
return `<div${add_attribute("class", cn("space-y-2", className), 0)}>${slots.default ? slots.default({ constraints, errors, tainted, value }) : ``}</div>`;
|
|
}
|
|
})}`;
|
|
});
|
|
const Control = Control$1;
|
|
const Switch = create_ssr_component(($$result, $$props, $$bindings, slots) => {
|
|
let $$restProps = compute_rest_props($$props, ["class", "checked"]);
|
|
let { class: className = void 0 } = $$props;
|
|
let { checked = void 0 } = $$props;
|
|
if ($$props.class === void 0 && $$bindings.class && className !== void 0)
|
|
$$bindings.class(className);
|
|
if ($$props.checked === void 0 && $$bindings.checked && checked !== void 0)
|
|
$$bindings.checked(checked);
|
|
let $$settled;
|
|
let $$rendered;
|
|
let previous_head = $$result.head;
|
|
do {
|
|
$$settled = true;
|
|
$$result.head = previous_head;
|
|
$$rendered = `${validate_component(Switch$1, "SwitchPrimitive.Root").$$render(
|
|
$$result,
|
|
Object.assign(
|
|
{},
|
|
{
|
|
class: cn("peer inline-flex h-[24px] w-[44px] shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input", className)
|
|
},
|
|
$$restProps,
|
|
{ checked }
|
|
),
|
|
{
|
|
checked: ($$value) => {
|
|
checked = $$value;
|
|
$$settled = false;
|
|
}
|
|
},
|
|
{
|
|
default: () => {
|
|
return `${validate_component(Switch_thumb, "SwitchPrimitive.Thumb").$$render(
|
|
$$result,
|
|
{
|
|
class: cn("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")
|
|
},
|
|
{},
|
|
{}
|
|
)}`;
|
|
}
|
|
}
|
|
)}`;
|
|
} while (!$$settled);
|
|
return $$rendered;
|
|
});
|
|
const Textarea = create_ssr_component(($$result, $$props, $$bindings, slots) => {
|
|
let $$restProps = compute_rest_props($$props, ["class", "value", "readonly"]);
|
|
let { class: className = void 0 } = $$props;
|
|
let { value = void 0 } = $$props;
|
|
let { readonly = void 0 } = $$props;
|
|
if ($$props.class === void 0 && $$bindings.class && className !== void 0)
|
|
$$bindings.class(className);
|
|
if ($$props.value === void 0 && $$bindings.value && value !== void 0)
|
|
$$bindings.value(value);
|
|
if ($$props.readonly === void 0 && $$bindings.readonly && readonly !== void 0)
|
|
$$bindings.readonly(readonly);
|
|
return `<textarea${spread(
|
|
[
|
|
{
|
|
class: escape_attribute_value(cn("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50", className))
|
|
},
|
|
{ readonly: readonly || null },
|
|
escape_object($$restProps)
|
|
],
|
|
{}
|
|
)}>${escape(value || "")}</textarea>`;
|
|
});
|
|
|
|
export { Control as C, Form_field as F, Input as I, Label as L, Switch as S, Textarea as T, Form_label as a, Form_field_errors as b, createLabel as c, getDataFsError as d, generateId as e, getFormField as g };
|
|
//# sourceMappingURL=textarea-DXN-n3En.js.map
|