prom-pal-ui 1.4.2 → 1.4.4

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.
@@ -620,7 +620,7 @@ function createSlotClone$1(ownerName) {
620
620
  children = use(children._payload);
621
621
  }
622
622
  if (React__namespace.isValidElement(children)) {
623
- const childrenRef = getElementRef$1(children);
623
+ const childrenRef = getElementRef$2(children);
624
624
  const props2 = mergeProps$1(slotProps, children.props);
625
625
  if (children.type !== React__namespace.Fragment) {
626
626
  props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
@@ -660,7 +660,7 @@ function mergeProps$1(slotProps, childProps) {
660
660
  }
661
661
  return { ...slotProps, ...overrideProps };
662
662
  }
663
- function getElementRef$1(element) {
663
+ function getElementRef$2(element) {
664
664
  let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get;
665
665
  let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
666
666
  if (mayWarn) {
@@ -4121,7 +4121,7 @@ function createSlotClone(ownerName) {
4121
4121
  const SlotClone = React__namespace.forwardRef((props, forwardedRef) => {
4122
4122
  const { children, ...slotProps } = props;
4123
4123
  if (React__namespace.isValidElement(children)) {
4124
- const childrenRef = getElementRef(children);
4124
+ const childrenRef = getElementRef$1(children);
4125
4125
  const props2 = mergeProps(slotProps, children.props);
4126
4126
  if (children.type !== React__namespace.Fragment) {
4127
4127
  props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
@@ -4161,7 +4161,7 @@ function mergeProps(slotProps, childProps) {
4161
4161
  }
4162
4162
  return { ...slotProps, ...overrideProps };
4163
4163
  }
4164
- function getElementRef(element) {
4164
+ function getElementRef$1(element) {
4165
4165
  let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get;
4166
4166
  let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
4167
4167
  if (mayWarn) {
@@ -7312,7 +7312,7 @@ function useControllableState({
7312
7312
  const setValue = React__namespace.useCallback(
7313
7313
  (nextValue) => {
7314
7314
  if (isControlled) {
7315
- const value2 = isFunction(nextValue) ? nextValue(prop) : nextValue;
7315
+ const value2 = isFunction$1(nextValue) ? nextValue(prop) : nextValue;
7316
7316
  if (value2 !== prop) {
7317
7317
  onChangeRef.current?.(value2);
7318
7318
  }
@@ -7342,7 +7342,7 @@ function useUncontrolledState({
7342
7342
  }, [value, prevValueRef]);
7343
7343
  return [value, setValue, onChangeRef];
7344
7344
  }
7345
- function isFunction(value) {
7345
+ function isFunction$1(value) {
7346
7346
  return typeof value === "function";
7347
7347
  }
7348
7348
 
@@ -8336,12 +8336,12 @@ var Select = (props) => {
8336
8336
  ) });
8337
8337
  };
8338
8338
  Select.displayName = SELECT_NAME;
8339
- var TRIGGER_NAME = "SelectTrigger";
8339
+ var TRIGGER_NAME$1 = "SelectTrigger";
8340
8340
  var SelectTrigger = React__namespace.forwardRef(
8341
8341
  (props, forwardedRef) => {
8342
8342
  const { __scopeSelect, disabled = false, ...triggerProps } = props;
8343
8343
  const popperScope = usePopperScope(__scopeSelect);
8344
- const context = useSelectContext(TRIGGER_NAME, __scopeSelect);
8344
+ const context = useSelectContext(TRIGGER_NAME$1, __scopeSelect);
8345
8345
  const isDisabled = context.disabled || disabled;
8346
8346
  const composedRefs = useComposedRefs(forwardedRef, context.onTriggerChange);
8347
8347
  const getItems = useCollection(__scopeSelect);
@@ -8413,7 +8413,7 @@ var SelectTrigger = React__namespace.forwardRef(
8413
8413
  ) });
8414
8414
  }
8415
8415
  );
8416
- SelectTrigger.displayName = TRIGGER_NAME;
8416
+ SelectTrigger.displayName = TRIGGER_NAME$1;
8417
8417
  var VALUE_NAME = "SelectValue";
8418
8418
  var SelectValue = React__namespace.forwardRef(
8419
8419
  (props, forwardedRef) => {
@@ -9264,7 +9264,7 @@ var SelectArrow = React__namespace.forwardRef(
9264
9264
  }
9265
9265
  );
9266
9266
  SelectArrow.displayName = ARROW_NAME;
9267
- var BUBBLE_INPUT_NAME$1 = "SelectBubbleInput";
9267
+ var BUBBLE_INPUT_NAME$2 = "SelectBubbleInput";
9268
9268
  var SelectBubbleInput = React__namespace.forwardRef(
9269
9269
  ({ __scopeSelect, value, ...props }, forwardedRef) => {
9270
9270
  const ref = React__namespace.useRef(null);
@@ -9296,7 +9296,7 @@ var SelectBubbleInput = React__namespace.forwardRef(
9296
9296
  );
9297
9297
  }
9298
9298
  );
9299
- SelectBubbleInput.displayName = BUBBLE_INPUT_NAME$1;
9299
+ SelectBubbleInput.displayName = BUBBLE_INPUT_NAME$2;
9300
9300
  function shouldShowPlaceholder(value) {
9301
9301
  return value === "" || value === void 0;
9302
9302
  }
@@ -9439,7 +9439,7 @@ var Switch = React__namespace.forwardRef(
9439
9439
  role: "switch",
9440
9440
  "aria-checked": checked,
9441
9441
  "aria-required": required,
9442
- "data-state": getState(checked),
9442
+ "data-state": getState$1(checked),
9443
9443
  "data-disabled": disabled ? "" : void 0,
9444
9444
  disabled,
9445
9445
  value,
@@ -9480,7 +9480,7 @@ var SwitchThumb = React__namespace.forwardRef(
9480
9480
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
9481
9481
  Primitive$1.span,
9482
9482
  {
9483
- "data-state": getState(context.checked),
9483
+ "data-state": getState$1(context.checked),
9484
9484
  "data-disabled": context.disabled ? "" : void 0,
9485
9485
  ...thumbProps,
9486
9486
  ref: forwardedRef
@@ -9489,7 +9489,7 @@ var SwitchThumb = React__namespace.forwardRef(
9489
9489
  }
9490
9490
  );
9491
9491
  SwitchThumb.displayName = THUMB_NAME;
9492
- var BUBBLE_INPUT_NAME = "SwitchBubbleInput";
9492
+ var BUBBLE_INPUT_NAME$1 = "SwitchBubbleInput";
9493
9493
  var SwitchBubbleInput = React__namespace.forwardRef(
9494
9494
  ({
9495
9495
  __scopeSwitch,
@@ -9538,8 +9538,8 @@ var SwitchBubbleInput = React__namespace.forwardRef(
9538
9538
  );
9539
9539
  }
9540
9540
  );
9541
- SwitchBubbleInput.displayName = BUBBLE_INPUT_NAME;
9542
- function getState(checked) {
9541
+ SwitchBubbleInput.displayName = BUBBLE_INPUT_NAME$1;
9542
+ function getState$1(checked) {
9543
9543
  return checked ? "checked" : "unchecked";
9544
9544
  }
9545
9545
  var Root$1 = Switch;
@@ -21772,7 +21772,7 @@ var PromInput = function (_a) {
21772
21772
  };
21773
21773
  return (jsxRuntimeExports.jsx(PromFormFiled, { control: control, name: name, render: function (_a) {
21774
21774
  var field = _a.field, fieldState = _a.fieldState;
21775
- return (jsxRuntimeExports.jsxs("div", { className: "space-y-2 relative flex flex-col", children: [label && (jsxRuntimeExports.jsx(PromLabel, { className: cn("block text-sm font-medium", styleTitle), children: label })), jsxRuntimeExports.jsxs("div", { className: "relative w-full", children: [jsxRuntimeExports.jsx("input", __assign({}, field, props, { type: inputType, onChange: function (e) { return handleChange(e.target.value); }, disabled: isLoad || props.disabled, className: cn("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm", "focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]", "aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive", styleWrapper) })), type === "password" && (jsxRuntimeExports.jsx("button", { type: "button", onClick: togglePasswordVisibility, className: "absolute right-3 top-1/2 -translate-y-1/2 text-gray-500 hover:text-gray-700 focus:outline-none", tabIndex: -1, disabled: props.disabled, children: showPassword ? (jsxRuntimeExports.jsx(EyeOff, { className: "h-4 w-4" })) : (jsxRuntimeExports.jsx(Eye, { className: "h-4 w-4" })) }))] }), fieldState.error && (jsxRuntimeExports.jsx("p", { className: "text-red-500 text-sm mt-1 text-center w-full", children: fieldState.error.message }))] }));
21775
+ return (jsxRuntimeExports.jsxs("div", { className: "space-y-2 relative flex flex-col w-full", children: [label && (jsxRuntimeExports.jsx(PromLabel, { className: cn("block text-sm font-medium", styleTitle), children: label })), jsxRuntimeExports.jsxs("div", { className: "relative w-full", children: [jsxRuntimeExports.jsx("input", __assign({}, field, props, { type: inputType, onChange: function (e) { return handleChange(e.target.value); }, disabled: isLoad || props.disabled, className: cn("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm", "focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]", "aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive", styleWrapper) })), type === "password" && (jsxRuntimeExports.jsx("button", { type: "button", onClick: togglePasswordVisibility, className: "absolute right-3 top-1/2 -translate-y-1/2 text-gray-500 hover:text-gray-700 focus:outline-none", tabIndex: -1, disabled: props.disabled, children: showPassword ? (jsxRuntimeExports.jsx(EyeOff, { className: "h-4 w-4" })) : (jsxRuntimeExports.jsx(Eye, { className: "h-4 w-4" })) }))] }), fieldState.error && (jsxRuntimeExports.jsx("p", { className: "text-red-500 text-sm mt-1 text-center w-full", children: fieldState.error.message }))] }));
21776
21776
  } }));
21777
21777
  };
21778
21778
 
@@ -21823,6 +21823,411 @@ function promSelectFilterOptions(obj, allowedKeys) {
21823
21823
  });
21824
21824
  }
21825
21825
 
21826
+ function useStateMachine(initialState, machine) {
21827
+ return React__namespace.useReducer((state, event) => {
21828
+ const nextState = machine[state][event];
21829
+ return nextState ?? state;
21830
+ }, initialState);
21831
+ }
21832
+
21833
+ // src/presence.tsx
21834
+ var Presence = (props) => {
21835
+ const { present, children } = props;
21836
+ const presence = usePresence(present);
21837
+ const child = typeof children === "function" ? children({ present: presence.isPresent }) : React__namespace.Children.only(children);
21838
+ const ref = useComposedRefs(presence.ref, getElementRef(child));
21839
+ const forceMount = typeof children === "function";
21840
+ return forceMount || presence.isPresent ? React__namespace.cloneElement(child, { ref }) : null;
21841
+ };
21842
+ Presence.displayName = "Presence";
21843
+ function usePresence(present) {
21844
+ const [node, setNode] = React__namespace.useState();
21845
+ const stylesRef = React__namespace.useRef(null);
21846
+ const prevPresentRef = React__namespace.useRef(present);
21847
+ const prevAnimationNameRef = React__namespace.useRef("none");
21848
+ const initialState = present ? "mounted" : "unmounted";
21849
+ const [state, send] = useStateMachine(initialState, {
21850
+ mounted: {
21851
+ UNMOUNT: "unmounted",
21852
+ ANIMATION_OUT: "unmountSuspended"
21853
+ },
21854
+ unmountSuspended: {
21855
+ MOUNT: "mounted",
21856
+ ANIMATION_END: "unmounted"
21857
+ },
21858
+ unmounted: {
21859
+ MOUNT: "mounted"
21860
+ }
21861
+ });
21862
+ React__namespace.useEffect(() => {
21863
+ const currentAnimationName = getAnimationName(stylesRef.current);
21864
+ prevAnimationNameRef.current = state === "mounted" ? currentAnimationName : "none";
21865
+ }, [state]);
21866
+ useLayoutEffect2(() => {
21867
+ const styles = stylesRef.current;
21868
+ const wasPresent = prevPresentRef.current;
21869
+ const hasPresentChanged = wasPresent !== present;
21870
+ if (hasPresentChanged) {
21871
+ const prevAnimationName = prevAnimationNameRef.current;
21872
+ const currentAnimationName = getAnimationName(styles);
21873
+ if (present) {
21874
+ send("MOUNT");
21875
+ } else if (currentAnimationName === "none" || styles?.display === "none") {
21876
+ send("UNMOUNT");
21877
+ } else {
21878
+ const isAnimating = prevAnimationName !== currentAnimationName;
21879
+ if (wasPresent && isAnimating) {
21880
+ send("ANIMATION_OUT");
21881
+ } else {
21882
+ send("UNMOUNT");
21883
+ }
21884
+ }
21885
+ prevPresentRef.current = present;
21886
+ }
21887
+ }, [present, send]);
21888
+ useLayoutEffect2(() => {
21889
+ if (node) {
21890
+ let timeoutId;
21891
+ const ownerWindow = node.ownerDocument.defaultView ?? window;
21892
+ const handleAnimationEnd = (event) => {
21893
+ const currentAnimationName = getAnimationName(stylesRef.current);
21894
+ const isCurrentAnimation = currentAnimationName.includes(CSS.escape(event.animationName));
21895
+ if (event.target === node && isCurrentAnimation) {
21896
+ send("ANIMATION_END");
21897
+ if (!prevPresentRef.current) {
21898
+ const currentFillMode = node.style.animationFillMode;
21899
+ node.style.animationFillMode = "forwards";
21900
+ timeoutId = ownerWindow.setTimeout(() => {
21901
+ if (node.style.animationFillMode === "forwards") {
21902
+ node.style.animationFillMode = currentFillMode;
21903
+ }
21904
+ });
21905
+ }
21906
+ }
21907
+ };
21908
+ const handleAnimationStart = (event) => {
21909
+ if (event.target === node) {
21910
+ prevAnimationNameRef.current = getAnimationName(stylesRef.current);
21911
+ }
21912
+ };
21913
+ node.addEventListener("animationstart", handleAnimationStart);
21914
+ node.addEventListener("animationcancel", handleAnimationEnd);
21915
+ node.addEventListener("animationend", handleAnimationEnd);
21916
+ return () => {
21917
+ ownerWindow.clearTimeout(timeoutId);
21918
+ node.removeEventListener("animationstart", handleAnimationStart);
21919
+ node.removeEventListener("animationcancel", handleAnimationEnd);
21920
+ node.removeEventListener("animationend", handleAnimationEnd);
21921
+ };
21922
+ } else {
21923
+ send("ANIMATION_END");
21924
+ }
21925
+ }, [node, send]);
21926
+ return {
21927
+ isPresent: ["mounted", "unmountSuspended"].includes(state),
21928
+ ref: React__namespace.useCallback((node2) => {
21929
+ stylesRef.current = node2 ? getComputedStyle(node2) : null;
21930
+ setNode(node2);
21931
+ }, [])
21932
+ };
21933
+ }
21934
+ function getAnimationName(styles) {
21935
+ return styles?.animationName || "none";
21936
+ }
21937
+ function getElementRef(element) {
21938
+ let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get;
21939
+ let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
21940
+ if (mayWarn) {
21941
+ return element.ref;
21942
+ }
21943
+ getter = Object.getOwnPropertyDescriptor(element, "ref")?.get;
21944
+ mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
21945
+ if (mayWarn) {
21946
+ return element.props.ref;
21947
+ }
21948
+ return element.props.ref || element.ref;
21949
+ }
21950
+
21951
+ var CHECKBOX_NAME = "Checkbox";
21952
+ var [createCheckboxContext] = createContextScope(CHECKBOX_NAME);
21953
+ var [CheckboxProviderImpl, useCheckboxContext] = createCheckboxContext(CHECKBOX_NAME);
21954
+ function CheckboxProvider(props) {
21955
+ const {
21956
+ __scopeCheckbox,
21957
+ checked: checkedProp,
21958
+ children,
21959
+ defaultChecked,
21960
+ disabled,
21961
+ form,
21962
+ name,
21963
+ onCheckedChange,
21964
+ required,
21965
+ value = "on",
21966
+ // @ts-expect-error
21967
+ internal_do_not_use_render
21968
+ } = props;
21969
+ const [checked, setChecked] = useControllableState({
21970
+ prop: checkedProp,
21971
+ defaultProp: defaultChecked ?? false,
21972
+ onChange: onCheckedChange,
21973
+ caller: CHECKBOX_NAME
21974
+ });
21975
+ const [control, setControl] = React__namespace.useState(null);
21976
+ const [bubbleInput, setBubbleInput] = React__namespace.useState(null);
21977
+ const hasConsumerStoppedPropagationRef = React__namespace.useRef(false);
21978
+ const isFormControl = control ? !!form || !!control.closest("form") : (
21979
+ // We set this to true by default so that events bubble to forms without JS (SSR)
21980
+ true
21981
+ );
21982
+ const context = {
21983
+ checked,
21984
+ disabled,
21985
+ setChecked,
21986
+ control,
21987
+ setControl,
21988
+ name,
21989
+ form,
21990
+ value,
21991
+ hasConsumerStoppedPropagationRef,
21992
+ required,
21993
+ defaultChecked: isIndeterminate(defaultChecked) ? false : defaultChecked,
21994
+ isFormControl,
21995
+ bubbleInput,
21996
+ setBubbleInput
21997
+ };
21998
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
21999
+ CheckboxProviderImpl,
22000
+ {
22001
+ scope: __scopeCheckbox,
22002
+ ...context,
22003
+ children: isFunction(internal_do_not_use_render) ? internal_do_not_use_render(context) : children
22004
+ }
22005
+ );
22006
+ }
22007
+ var TRIGGER_NAME = "CheckboxTrigger";
22008
+ var CheckboxTrigger = React__namespace.forwardRef(
22009
+ ({ __scopeCheckbox, onKeyDown, onClick, ...checkboxProps }, forwardedRef) => {
22010
+ const {
22011
+ control,
22012
+ value,
22013
+ disabled,
22014
+ checked,
22015
+ required,
22016
+ setControl,
22017
+ setChecked,
22018
+ hasConsumerStoppedPropagationRef,
22019
+ isFormControl,
22020
+ bubbleInput
22021
+ } = useCheckboxContext(TRIGGER_NAME, __scopeCheckbox);
22022
+ const composedRefs = useComposedRefs(forwardedRef, setControl);
22023
+ const initialCheckedStateRef = React__namespace.useRef(checked);
22024
+ React__namespace.useEffect(() => {
22025
+ const form = control?.form;
22026
+ if (form) {
22027
+ const reset = () => setChecked(initialCheckedStateRef.current);
22028
+ form.addEventListener("reset", reset);
22029
+ return () => form.removeEventListener("reset", reset);
22030
+ }
22031
+ }, [control, setChecked]);
22032
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
22033
+ Primitive$1.button,
22034
+ {
22035
+ type: "button",
22036
+ role: "checkbox",
22037
+ "aria-checked": isIndeterminate(checked) ? "mixed" : checked,
22038
+ "aria-required": required,
22039
+ "data-state": getState(checked),
22040
+ "data-disabled": disabled ? "" : void 0,
22041
+ disabled,
22042
+ value,
22043
+ ...checkboxProps,
22044
+ ref: composedRefs,
22045
+ onKeyDown: composeEventHandlers(onKeyDown, (event) => {
22046
+ if (event.key === "Enter") event.preventDefault();
22047
+ }),
22048
+ onClick: composeEventHandlers(onClick, (event) => {
22049
+ setChecked((prevChecked) => isIndeterminate(prevChecked) ? true : !prevChecked);
22050
+ if (bubbleInput && isFormControl) {
22051
+ hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();
22052
+ if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();
22053
+ }
22054
+ })
22055
+ }
22056
+ );
22057
+ }
22058
+ );
22059
+ CheckboxTrigger.displayName = TRIGGER_NAME;
22060
+ var Checkbox = React__namespace.forwardRef(
22061
+ (props, forwardedRef) => {
22062
+ const {
22063
+ __scopeCheckbox,
22064
+ name,
22065
+ checked,
22066
+ defaultChecked,
22067
+ required,
22068
+ disabled,
22069
+ value,
22070
+ onCheckedChange,
22071
+ form,
22072
+ ...checkboxProps
22073
+ } = props;
22074
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
22075
+ CheckboxProvider,
22076
+ {
22077
+ __scopeCheckbox,
22078
+ checked,
22079
+ defaultChecked,
22080
+ disabled,
22081
+ required,
22082
+ onCheckedChange,
22083
+ name,
22084
+ form,
22085
+ value,
22086
+ internal_do_not_use_render: ({ isFormControl }) => /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
22087
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
22088
+ CheckboxTrigger,
22089
+ {
22090
+ ...checkboxProps,
22091
+ ref: forwardedRef,
22092
+ __scopeCheckbox
22093
+ }
22094
+ ),
22095
+ isFormControl && /* @__PURE__ */ jsxRuntimeExports.jsx(
22096
+ CheckboxBubbleInput,
22097
+ {
22098
+ __scopeCheckbox
22099
+ }
22100
+ )
22101
+ ] })
22102
+ }
22103
+ );
22104
+ }
22105
+ );
22106
+ Checkbox.displayName = CHECKBOX_NAME;
22107
+ var INDICATOR_NAME = "CheckboxIndicator";
22108
+ var CheckboxIndicator = React__namespace.forwardRef(
22109
+ (props, forwardedRef) => {
22110
+ const { __scopeCheckbox, forceMount, ...indicatorProps } = props;
22111
+ const context = useCheckboxContext(INDICATOR_NAME, __scopeCheckbox);
22112
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
22113
+ Presence,
22114
+ {
22115
+ present: forceMount || isIndeterminate(context.checked) || context.checked === true,
22116
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(
22117
+ Primitive$1.span,
22118
+ {
22119
+ "data-state": getState(context.checked),
22120
+ "data-disabled": context.disabled ? "" : void 0,
22121
+ ...indicatorProps,
22122
+ ref: forwardedRef,
22123
+ style: { pointerEvents: "none", ...props.style }
22124
+ }
22125
+ )
22126
+ }
22127
+ );
22128
+ }
22129
+ );
22130
+ CheckboxIndicator.displayName = INDICATOR_NAME;
22131
+ var BUBBLE_INPUT_NAME = "CheckboxBubbleInput";
22132
+ var CheckboxBubbleInput = React__namespace.forwardRef(
22133
+ ({ __scopeCheckbox, ...props }, forwardedRef) => {
22134
+ const {
22135
+ control,
22136
+ hasConsumerStoppedPropagationRef,
22137
+ checked,
22138
+ defaultChecked,
22139
+ required,
22140
+ disabled,
22141
+ name,
22142
+ value,
22143
+ form,
22144
+ bubbleInput,
22145
+ setBubbleInput
22146
+ } = useCheckboxContext(BUBBLE_INPUT_NAME, __scopeCheckbox);
22147
+ const composedRefs = useComposedRefs(forwardedRef, setBubbleInput);
22148
+ const prevChecked = usePrevious(checked);
22149
+ const controlSize = useSize(control);
22150
+ React__namespace.useEffect(() => {
22151
+ const input = bubbleInput;
22152
+ if (!input) return;
22153
+ const inputProto = window.HTMLInputElement.prototype;
22154
+ const descriptor = Object.getOwnPropertyDescriptor(
22155
+ inputProto,
22156
+ "checked"
22157
+ );
22158
+ const setChecked = descriptor.set;
22159
+ const bubbles = !hasConsumerStoppedPropagationRef.current;
22160
+ if (prevChecked !== checked && setChecked) {
22161
+ const event = new Event("click", { bubbles });
22162
+ input.indeterminate = isIndeterminate(checked);
22163
+ setChecked.call(input, isIndeterminate(checked) ? false : checked);
22164
+ input.dispatchEvent(event);
22165
+ }
22166
+ }, [bubbleInput, prevChecked, checked, hasConsumerStoppedPropagationRef]);
22167
+ const defaultCheckedRef = React__namespace.useRef(isIndeterminate(checked) ? false : checked);
22168
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
22169
+ Primitive$1.input,
22170
+ {
22171
+ type: "checkbox",
22172
+ "aria-hidden": true,
22173
+ defaultChecked: defaultChecked ?? defaultCheckedRef.current,
22174
+ required,
22175
+ disabled,
22176
+ name,
22177
+ value,
22178
+ form,
22179
+ ...props,
22180
+ tabIndex: -1,
22181
+ ref: composedRefs,
22182
+ style: {
22183
+ ...props.style,
22184
+ ...controlSize,
22185
+ position: "absolute",
22186
+ pointerEvents: "none",
22187
+ opacity: 0,
22188
+ margin: 0,
22189
+ // We transform because the input is absolutely positioned but we have
22190
+ // rendered it **after** the button. This pulls it back to sit on top
22191
+ // of the button.
22192
+ transform: "translateX(-100%)"
22193
+ }
22194
+ }
22195
+ );
22196
+ }
22197
+ );
22198
+ CheckboxBubbleInput.displayName = BUBBLE_INPUT_NAME;
22199
+ function isFunction(value) {
22200
+ return typeof value === "function";
22201
+ }
22202
+ function isIndeterminate(checked) {
22203
+ return checked === "indeterminate";
22204
+ }
22205
+ function getState(checked) {
22206
+ return isIndeterminate(checked) ? "indeterminate" : checked ? "checked" : "unchecked";
22207
+ }
22208
+
22209
+ function PromCheckbox(_a) {
22210
+ var className = _a.className, props = __rest(_a, ["className"]);
22211
+ return (jsxRuntimeExports.jsx(Checkbox, __assign({ "data-slot": "checkbox", className: cn("peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50", className) }, props, { children: jsxRuntimeExports.jsx(CheckboxIndicator, { "data-slot": "checkbox-indicator", className: "grid place-content-center text-current transition-none", children: jsxRuntimeExports.jsx(Check, { className: "size-3.5" }) }) })));
22212
+ }
22213
+
22214
+ var PromSwitchListField = function (_a) {
22215
+ var name = _a.name, label = _a.label, options = _a.options, error = _a.error; _a.errorMsg; var _b = _a.isLoad, isLoad = _b === void 0 ? false : _b, _c = _a.disabled, disabled = _c === void 0 ? false : _c, _d = _a.errorDisplay, errorDisplay = _d === void 0 ? true : _d, className = _a.className, props = __rest(_a, ["name", "label", "options", "error", "errorMsg", "isLoad", "disabled", "errorDisplay", "className"]);
22216
+ var control = reactHookForm.useFormContext().control;
22217
+ return (jsxRuntimeExports.jsx(PromFormFiled, { name: name, control: control, render: function (_a) {
22218
+ var field = _a.field, fieldState = _a.fieldState;
22219
+ return (jsxRuntimeExports.jsxs("div", { className: cn("relative space-y-3", className), children: [label && jsxRuntimeExports.jsx(PromLabel, { children: label }), !isLoad ? (jsxRuntimeExports.jsx("div", { className: "flex flex-wrap gap-5", children: options.map(function (option) {
22220
+ var values = field.value || [];
22221
+ var isChecked = values.includes(option.id);
22222
+ return (jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2", children: [jsxRuntimeExports.jsx(PromCheckbox, __assign({ id: "".concat(name, "-").concat(option.id), checked: isChecked, disabled: disabled, onCheckedChange: function (checked) {
22223
+ var newValues = checked
22224
+ ? __spreadArray(__spreadArray([], values, true), [option.id], false) : values.filter(function (id) { return id !== option.id; });
22225
+ field.onChange(newValues);
22226
+ } }, props)), jsxRuntimeExports.jsx(PromLabel, { htmlFor: "".concat(name, "-").concat(option.id), className: cn("text-gray-500 cursor-pointer", disabled && "cursor-not-allowed opacity-50"), children: option.title })] }, option.id));
22227
+ }) })) : (jsxRuntimeExports.jsx("div", { className: "flex flex-wrap gap-5", children: [1, 2, 3].map(function (i) { return (jsxRuntimeExports.jsx(PromSkeleton, { className: "w-10 h-5" }, i)); }) })), errorDisplay && fieldState.error && (jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: error ? (error(fieldState.error.message)) : (jsxRuntimeExports.jsx("p", { className: "text-red-500 text-sm mt-1", children: fieldState.error.message })) }))] }));
22228
+ } }));
22229
+ };
22230
+
21826
22231
  var promAllowedPatternUrlSocial = /^[a-zA-Z0-9_@:\/\.\-]*$/;
21827
22232
  var promAllowedPatternOnlyRu = /^[а-яёА-ЯЁ]*$/;
21828
22233
  var promAllowedPatternPhone = /^\+7\d{0,10}$/;
@@ -21898,6 +22303,14 @@ var promMaskPhoneWithoutPlus = function (val) {
21898
22303
  }
21899
22304
  return cleaned;
21900
22305
  };
22306
+ var promMaskUrl = function (val) {
22307
+ if (!val)
22308
+ return val;
22309
+ var httpsIndex = val.indexOf("https");
22310
+ if (httpsIndex === -1)
22311
+ return val;
22312
+ return val.substring(httpsIndex);
22313
+ };
21901
22314
  var promMaskEmail = function (val) {
21902
22315
  if (!val)
21903
22316
  return val;
@@ -24271,6 +24684,7 @@ var PROM_MSG_ERROR = {
24271
24684
 
24272
24685
  exports.PROM_MSG_ERROR = PROM_MSG_ERROR;
24273
24686
  exports.PromButton = PromButton;
24687
+ exports.PromCheckbox = PromCheckbox;
24274
24688
  exports.PromFormFiled = PromFormFiled;
24275
24689
  exports.PromFrom = PromFrom;
24276
24690
  exports.PromInput = PromInput;
@@ -24290,6 +24704,7 @@ exports.PromSelectValue = PromSelectValue;
24290
24704
  exports.PromSkeleton = PromSkeleton;
24291
24705
  exports.PromSwitch = PromSwitch;
24292
24706
  exports.PromSwitchField = PromSwitchField;
24707
+ exports.PromSwitchListField = PromSwitchListField;
24293
24708
  exports.PromTextarea = PromTextarea;
24294
24709
  exports.promAllowedPatternEmail = promAllowedPatternEmail;
24295
24710
  exports.promAllowedPatternNaturalNumbers = promAllowedPatternNaturalNumbers;
@@ -24301,6 +24716,7 @@ exports.promMaskEmail = promMaskEmail;
24301
24716
  exports.promMaskPhone = promMaskPhone;
24302
24717
  exports.promMaskPhoneWithoutPlus = promMaskPhoneWithoutPlus;
24303
24718
  exports.promMaskTelegram = promMaskTelegram;
24719
+ exports.promMaskUrl = promMaskUrl;
24304
24720
  exports.promMaskWhatsapp = promMaskWhatsapp;
24305
24721
  exports.promSchemaPhone = promSchemaPhone;
24306
24722
  exports.promSelectFilterOptions = promSelectFilterOptions;
@@ -600,7 +600,7 @@ function createSlotClone$1(ownerName) {
600
600
  children = use(children._payload);
601
601
  }
602
602
  if (React.isValidElement(children)) {
603
- const childrenRef = getElementRef$1(children);
603
+ const childrenRef = getElementRef$2(children);
604
604
  const props2 = mergeProps$1(slotProps, children.props);
605
605
  if (children.type !== React.Fragment) {
606
606
  props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
@@ -640,7 +640,7 @@ function mergeProps$1(slotProps, childProps) {
640
640
  }
641
641
  return { ...slotProps, ...overrideProps };
642
642
  }
643
- function getElementRef$1(element) {
643
+ function getElementRef$2(element) {
644
644
  let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get;
645
645
  let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
646
646
  if (mayWarn) {
@@ -4101,7 +4101,7 @@ function createSlotClone(ownerName) {
4101
4101
  const SlotClone = React.forwardRef((props, forwardedRef) => {
4102
4102
  const { children, ...slotProps } = props;
4103
4103
  if (React.isValidElement(children)) {
4104
- const childrenRef = getElementRef(children);
4104
+ const childrenRef = getElementRef$1(children);
4105
4105
  const props2 = mergeProps(slotProps, children.props);
4106
4106
  if (children.type !== React.Fragment) {
4107
4107
  props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
@@ -4141,7 +4141,7 @@ function mergeProps(slotProps, childProps) {
4141
4141
  }
4142
4142
  return { ...slotProps, ...overrideProps };
4143
4143
  }
4144
- function getElementRef(element) {
4144
+ function getElementRef$1(element) {
4145
4145
  let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get;
4146
4146
  let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
4147
4147
  if (mayWarn) {
@@ -7292,7 +7292,7 @@ function useControllableState({
7292
7292
  const setValue = React.useCallback(
7293
7293
  (nextValue) => {
7294
7294
  if (isControlled) {
7295
- const value2 = isFunction(nextValue) ? nextValue(prop) : nextValue;
7295
+ const value2 = isFunction$1(nextValue) ? nextValue(prop) : nextValue;
7296
7296
  if (value2 !== prop) {
7297
7297
  onChangeRef.current?.(value2);
7298
7298
  }
@@ -7322,7 +7322,7 @@ function useUncontrolledState({
7322
7322
  }, [value, prevValueRef]);
7323
7323
  return [value, setValue, onChangeRef];
7324
7324
  }
7325
- function isFunction(value) {
7325
+ function isFunction$1(value) {
7326
7326
  return typeof value === "function";
7327
7327
  }
7328
7328
 
@@ -8316,12 +8316,12 @@ var Select = (props) => {
8316
8316
  ) });
8317
8317
  };
8318
8318
  Select.displayName = SELECT_NAME;
8319
- var TRIGGER_NAME = "SelectTrigger";
8319
+ var TRIGGER_NAME$1 = "SelectTrigger";
8320
8320
  var SelectTrigger = React.forwardRef(
8321
8321
  (props, forwardedRef) => {
8322
8322
  const { __scopeSelect, disabled = false, ...triggerProps } = props;
8323
8323
  const popperScope = usePopperScope(__scopeSelect);
8324
- const context = useSelectContext(TRIGGER_NAME, __scopeSelect);
8324
+ const context = useSelectContext(TRIGGER_NAME$1, __scopeSelect);
8325
8325
  const isDisabled = context.disabled || disabled;
8326
8326
  const composedRefs = useComposedRefs(forwardedRef, context.onTriggerChange);
8327
8327
  const getItems = useCollection(__scopeSelect);
@@ -8393,7 +8393,7 @@ var SelectTrigger = React.forwardRef(
8393
8393
  ) });
8394
8394
  }
8395
8395
  );
8396
- SelectTrigger.displayName = TRIGGER_NAME;
8396
+ SelectTrigger.displayName = TRIGGER_NAME$1;
8397
8397
  var VALUE_NAME = "SelectValue";
8398
8398
  var SelectValue = React.forwardRef(
8399
8399
  (props, forwardedRef) => {
@@ -9244,7 +9244,7 @@ var SelectArrow = React.forwardRef(
9244
9244
  }
9245
9245
  );
9246
9246
  SelectArrow.displayName = ARROW_NAME;
9247
- var BUBBLE_INPUT_NAME$1 = "SelectBubbleInput";
9247
+ var BUBBLE_INPUT_NAME$2 = "SelectBubbleInput";
9248
9248
  var SelectBubbleInput = React.forwardRef(
9249
9249
  ({ __scopeSelect, value, ...props }, forwardedRef) => {
9250
9250
  const ref = React.useRef(null);
@@ -9276,7 +9276,7 @@ var SelectBubbleInput = React.forwardRef(
9276
9276
  );
9277
9277
  }
9278
9278
  );
9279
- SelectBubbleInput.displayName = BUBBLE_INPUT_NAME$1;
9279
+ SelectBubbleInput.displayName = BUBBLE_INPUT_NAME$2;
9280
9280
  function shouldShowPlaceholder(value) {
9281
9281
  return value === "" || value === void 0;
9282
9282
  }
@@ -9419,7 +9419,7 @@ var Switch = React.forwardRef(
9419
9419
  role: "switch",
9420
9420
  "aria-checked": checked,
9421
9421
  "aria-required": required,
9422
- "data-state": getState(checked),
9422
+ "data-state": getState$1(checked),
9423
9423
  "data-disabled": disabled ? "" : void 0,
9424
9424
  disabled,
9425
9425
  value,
@@ -9460,7 +9460,7 @@ var SwitchThumb = React.forwardRef(
9460
9460
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
9461
9461
  Primitive$1.span,
9462
9462
  {
9463
- "data-state": getState(context.checked),
9463
+ "data-state": getState$1(context.checked),
9464
9464
  "data-disabled": context.disabled ? "" : void 0,
9465
9465
  ...thumbProps,
9466
9466
  ref: forwardedRef
@@ -9469,7 +9469,7 @@ var SwitchThumb = React.forwardRef(
9469
9469
  }
9470
9470
  );
9471
9471
  SwitchThumb.displayName = THUMB_NAME;
9472
- var BUBBLE_INPUT_NAME = "SwitchBubbleInput";
9472
+ var BUBBLE_INPUT_NAME$1 = "SwitchBubbleInput";
9473
9473
  var SwitchBubbleInput = React.forwardRef(
9474
9474
  ({
9475
9475
  __scopeSwitch,
@@ -9518,8 +9518,8 @@ var SwitchBubbleInput = React.forwardRef(
9518
9518
  );
9519
9519
  }
9520
9520
  );
9521
- SwitchBubbleInput.displayName = BUBBLE_INPUT_NAME;
9522
- function getState(checked) {
9521
+ SwitchBubbleInput.displayName = BUBBLE_INPUT_NAME$1;
9522
+ function getState$1(checked) {
9523
9523
  return checked ? "checked" : "unchecked";
9524
9524
  }
9525
9525
  var Root$1 = Switch;
@@ -21752,7 +21752,7 @@ var PromInput = function (_a) {
21752
21752
  };
21753
21753
  return (jsxRuntimeExports.jsx(PromFormFiled, { control: control, name: name, render: function (_a) {
21754
21754
  var field = _a.field, fieldState = _a.fieldState;
21755
- return (jsxRuntimeExports.jsxs("div", { className: "space-y-2 relative flex flex-col", children: [label && (jsxRuntimeExports.jsx(PromLabel, { className: cn("block text-sm font-medium", styleTitle), children: label })), jsxRuntimeExports.jsxs("div", { className: "relative w-full", children: [jsxRuntimeExports.jsx("input", __assign({}, field, props, { type: inputType, onChange: function (e) { return handleChange(e.target.value); }, disabled: isLoad || props.disabled, className: cn("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm", "focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]", "aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive", styleWrapper) })), type === "password" && (jsxRuntimeExports.jsx("button", { type: "button", onClick: togglePasswordVisibility, className: "absolute right-3 top-1/2 -translate-y-1/2 text-gray-500 hover:text-gray-700 focus:outline-none", tabIndex: -1, disabled: props.disabled, children: showPassword ? (jsxRuntimeExports.jsx(EyeOff, { className: "h-4 w-4" })) : (jsxRuntimeExports.jsx(Eye, { className: "h-4 w-4" })) }))] }), fieldState.error && (jsxRuntimeExports.jsx("p", { className: "text-red-500 text-sm mt-1 text-center w-full", children: fieldState.error.message }))] }));
21755
+ return (jsxRuntimeExports.jsxs("div", { className: "space-y-2 relative flex flex-col w-full", children: [label && (jsxRuntimeExports.jsx(PromLabel, { className: cn("block text-sm font-medium", styleTitle), children: label })), jsxRuntimeExports.jsxs("div", { className: "relative w-full", children: [jsxRuntimeExports.jsx("input", __assign({}, field, props, { type: inputType, onChange: function (e) { return handleChange(e.target.value); }, disabled: isLoad || props.disabled, className: cn("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm", "focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]", "aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive", styleWrapper) })), type === "password" && (jsxRuntimeExports.jsx("button", { type: "button", onClick: togglePasswordVisibility, className: "absolute right-3 top-1/2 -translate-y-1/2 text-gray-500 hover:text-gray-700 focus:outline-none", tabIndex: -1, disabled: props.disabled, children: showPassword ? (jsxRuntimeExports.jsx(EyeOff, { className: "h-4 w-4" })) : (jsxRuntimeExports.jsx(Eye, { className: "h-4 w-4" })) }))] }), fieldState.error && (jsxRuntimeExports.jsx("p", { className: "text-red-500 text-sm mt-1 text-center w-full", children: fieldState.error.message }))] }));
21756
21756
  } }));
21757
21757
  };
21758
21758
 
@@ -21803,6 +21803,411 @@ function promSelectFilterOptions(obj, allowedKeys) {
21803
21803
  });
21804
21804
  }
21805
21805
 
21806
+ function useStateMachine(initialState, machine) {
21807
+ return React.useReducer((state, event) => {
21808
+ const nextState = machine[state][event];
21809
+ return nextState ?? state;
21810
+ }, initialState);
21811
+ }
21812
+
21813
+ // src/presence.tsx
21814
+ var Presence = (props) => {
21815
+ const { present, children } = props;
21816
+ const presence = usePresence(present);
21817
+ const child = typeof children === "function" ? children({ present: presence.isPresent }) : React.Children.only(children);
21818
+ const ref = useComposedRefs(presence.ref, getElementRef(child));
21819
+ const forceMount = typeof children === "function";
21820
+ return forceMount || presence.isPresent ? React.cloneElement(child, { ref }) : null;
21821
+ };
21822
+ Presence.displayName = "Presence";
21823
+ function usePresence(present) {
21824
+ const [node, setNode] = React.useState();
21825
+ const stylesRef = React.useRef(null);
21826
+ const prevPresentRef = React.useRef(present);
21827
+ const prevAnimationNameRef = React.useRef("none");
21828
+ const initialState = present ? "mounted" : "unmounted";
21829
+ const [state, send] = useStateMachine(initialState, {
21830
+ mounted: {
21831
+ UNMOUNT: "unmounted",
21832
+ ANIMATION_OUT: "unmountSuspended"
21833
+ },
21834
+ unmountSuspended: {
21835
+ MOUNT: "mounted",
21836
+ ANIMATION_END: "unmounted"
21837
+ },
21838
+ unmounted: {
21839
+ MOUNT: "mounted"
21840
+ }
21841
+ });
21842
+ React.useEffect(() => {
21843
+ const currentAnimationName = getAnimationName(stylesRef.current);
21844
+ prevAnimationNameRef.current = state === "mounted" ? currentAnimationName : "none";
21845
+ }, [state]);
21846
+ useLayoutEffect2(() => {
21847
+ const styles = stylesRef.current;
21848
+ const wasPresent = prevPresentRef.current;
21849
+ const hasPresentChanged = wasPresent !== present;
21850
+ if (hasPresentChanged) {
21851
+ const prevAnimationName = prevAnimationNameRef.current;
21852
+ const currentAnimationName = getAnimationName(styles);
21853
+ if (present) {
21854
+ send("MOUNT");
21855
+ } else if (currentAnimationName === "none" || styles?.display === "none") {
21856
+ send("UNMOUNT");
21857
+ } else {
21858
+ const isAnimating = prevAnimationName !== currentAnimationName;
21859
+ if (wasPresent && isAnimating) {
21860
+ send("ANIMATION_OUT");
21861
+ } else {
21862
+ send("UNMOUNT");
21863
+ }
21864
+ }
21865
+ prevPresentRef.current = present;
21866
+ }
21867
+ }, [present, send]);
21868
+ useLayoutEffect2(() => {
21869
+ if (node) {
21870
+ let timeoutId;
21871
+ const ownerWindow = node.ownerDocument.defaultView ?? window;
21872
+ const handleAnimationEnd = (event) => {
21873
+ const currentAnimationName = getAnimationName(stylesRef.current);
21874
+ const isCurrentAnimation = currentAnimationName.includes(CSS.escape(event.animationName));
21875
+ if (event.target === node && isCurrentAnimation) {
21876
+ send("ANIMATION_END");
21877
+ if (!prevPresentRef.current) {
21878
+ const currentFillMode = node.style.animationFillMode;
21879
+ node.style.animationFillMode = "forwards";
21880
+ timeoutId = ownerWindow.setTimeout(() => {
21881
+ if (node.style.animationFillMode === "forwards") {
21882
+ node.style.animationFillMode = currentFillMode;
21883
+ }
21884
+ });
21885
+ }
21886
+ }
21887
+ };
21888
+ const handleAnimationStart = (event) => {
21889
+ if (event.target === node) {
21890
+ prevAnimationNameRef.current = getAnimationName(stylesRef.current);
21891
+ }
21892
+ };
21893
+ node.addEventListener("animationstart", handleAnimationStart);
21894
+ node.addEventListener("animationcancel", handleAnimationEnd);
21895
+ node.addEventListener("animationend", handleAnimationEnd);
21896
+ return () => {
21897
+ ownerWindow.clearTimeout(timeoutId);
21898
+ node.removeEventListener("animationstart", handleAnimationStart);
21899
+ node.removeEventListener("animationcancel", handleAnimationEnd);
21900
+ node.removeEventListener("animationend", handleAnimationEnd);
21901
+ };
21902
+ } else {
21903
+ send("ANIMATION_END");
21904
+ }
21905
+ }, [node, send]);
21906
+ return {
21907
+ isPresent: ["mounted", "unmountSuspended"].includes(state),
21908
+ ref: React.useCallback((node2) => {
21909
+ stylesRef.current = node2 ? getComputedStyle(node2) : null;
21910
+ setNode(node2);
21911
+ }, [])
21912
+ };
21913
+ }
21914
+ function getAnimationName(styles) {
21915
+ return styles?.animationName || "none";
21916
+ }
21917
+ function getElementRef(element) {
21918
+ let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get;
21919
+ let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
21920
+ if (mayWarn) {
21921
+ return element.ref;
21922
+ }
21923
+ getter = Object.getOwnPropertyDescriptor(element, "ref")?.get;
21924
+ mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
21925
+ if (mayWarn) {
21926
+ return element.props.ref;
21927
+ }
21928
+ return element.props.ref || element.ref;
21929
+ }
21930
+
21931
+ var CHECKBOX_NAME = "Checkbox";
21932
+ var [createCheckboxContext] = createContextScope(CHECKBOX_NAME);
21933
+ var [CheckboxProviderImpl, useCheckboxContext] = createCheckboxContext(CHECKBOX_NAME);
21934
+ function CheckboxProvider(props) {
21935
+ const {
21936
+ __scopeCheckbox,
21937
+ checked: checkedProp,
21938
+ children,
21939
+ defaultChecked,
21940
+ disabled,
21941
+ form,
21942
+ name,
21943
+ onCheckedChange,
21944
+ required,
21945
+ value = "on",
21946
+ // @ts-expect-error
21947
+ internal_do_not_use_render
21948
+ } = props;
21949
+ const [checked, setChecked] = useControllableState({
21950
+ prop: checkedProp,
21951
+ defaultProp: defaultChecked ?? false,
21952
+ onChange: onCheckedChange,
21953
+ caller: CHECKBOX_NAME
21954
+ });
21955
+ const [control, setControl] = React.useState(null);
21956
+ const [bubbleInput, setBubbleInput] = React.useState(null);
21957
+ const hasConsumerStoppedPropagationRef = React.useRef(false);
21958
+ const isFormControl = control ? !!form || !!control.closest("form") : (
21959
+ // We set this to true by default so that events bubble to forms without JS (SSR)
21960
+ true
21961
+ );
21962
+ const context = {
21963
+ checked,
21964
+ disabled,
21965
+ setChecked,
21966
+ control,
21967
+ setControl,
21968
+ name,
21969
+ form,
21970
+ value,
21971
+ hasConsumerStoppedPropagationRef,
21972
+ required,
21973
+ defaultChecked: isIndeterminate(defaultChecked) ? false : defaultChecked,
21974
+ isFormControl,
21975
+ bubbleInput,
21976
+ setBubbleInput
21977
+ };
21978
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
21979
+ CheckboxProviderImpl,
21980
+ {
21981
+ scope: __scopeCheckbox,
21982
+ ...context,
21983
+ children: isFunction(internal_do_not_use_render) ? internal_do_not_use_render(context) : children
21984
+ }
21985
+ );
21986
+ }
21987
+ var TRIGGER_NAME = "CheckboxTrigger";
21988
+ var CheckboxTrigger = React.forwardRef(
21989
+ ({ __scopeCheckbox, onKeyDown, onClick, ...checkboxProps }, forwardedRef) => {
21990
+ const {
21991
+ control,
21992
+ value,
21993
+ disabled,
21994
+ checked,
21995
+ required,
21996
+ setControl,
21997
+ setChecked,
21998
+ hasConsumerStoppedPropagationRef,
21999
+ isFormControl,
22000
+ bubbleInput
22001
+ } = useCheckboxContext(TRIGGER_NAME, __scopeCheckbox);
22002
+ const composedRefs = useComposedRefs(forwardedRef, setControl);
22003
+ const initialCheckedStateRef = React.useRef(checked);
22004
+ React.useEffect(() => {
22005
+ const form = control?.form;
22006
+ if (form) {
22007
+ const reset = () => setChecked(initialCheckedStateRef.current);
22008
+ form.addEventListener("reset", reset);
22009
+ return () => form.removeEventListener("reset", reset);
22010
+ }
22011
+ }, [control, setChecked]);
22012
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
22013
+ Primitive$1.button,
22014
+ {
22015
+ type: "button",
22016
+ role: "checkbox",
22017
+ "aria-checked": isIndeterminate(checked) ? "mixed" : checked,
22018
+ "aria-required": required,
22019
+ "data-state": getState(checked),
22020
+ "data-disabled": disabled ? "" : void 0,
22021
+ disabled,
22022
+ value,
22023
+ ...checkboxProps,
22024
+ ref: composedRefs,
22025
+ onKeyDown: composeEventHandlers(onKeyDown, (event) => {
22026
+ if (event.key === "Enter") event.preventDefault();
22027
+ }),
22028
+ onClick: composeEventHandlers(onClick, (event) => {
22029
+ setChecked((prevChecked) => isIndeterminate(prevChecked) ? true : !prevChecked);
22030
+ if (bubbleInput && isFormControl) {
22031
+ hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();
22032
+ if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();
22033
+ }
22034
+ })
22035
+ }
22036
+ );
22037
+ }
22038
+ );
22039
+ CheckboxTrigger.displayName = TRIGGER_NAME;
22040
+ var Checkbox = React.forwardRef(
22041
+ (props, forwardedRef) => {
22042
+ const {
22043
+ __scopeCheckbox,
22044
+ name,
22045
+ checked,
22046
+ defaultChecked,
22047
+ required,
22048
+ disabled,
22049
+ value,
22050
+ onCheckedChange,
22051
+ form,
22052
+ ...checkboxProps
22053
+ } = props;
22054
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
22055
+ CheckboxProvider,
22056
+ {
22057
+ __scopeCheckbox,
22058
+ checked,
22059
+ defaultChecked,
22060
+ disabled,
22061
+ required,
22062
+ onCheckedChange,
22063
+ name,
22064
+ form,
22065
+ value,
22066
+ internal_do_not_use_render: ({ isFormControl }) => /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
22067
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
22068
+ CheckboxTrigger,
22069
+ {
22070
+ ...checkboxProps,
22071
+ ref: forwardedRef,
22072
+ __scopeCheckbox
22073
+ }
22074
+ ),
22075
+ isFormControl && /* @__PURE__ */ jsxRuntimeExports.jsx(
22076
+ CheckboxBubbleInput,
22077
+ {
22078
+ __scopeCheckbox
22079
+ }
22080
+ )
22081
+ ] })
22082
+ }
22083
+ );
22084
+ }
22085
+ );
22086
+ Checkbox.displayName = CHECKBOX_NAME;
22087
+ var INDICATOR_NAME = "CheckboxIndicator";
22088
+ var CheckboxIndicator = React.forwardRef(
22089
+ (props, forwardedRef) => {
22090
+ const { __scopeCheckbox, forceMount, ...indicatorProps } = props;
22091
+ const context = useCheckboxContext(INDICATOR_NAME, __scopeCheckbox);
22092
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
22093
+ Presence,
22094
+ {
22095
+ present: forceMount || isIndeterminate(context.checked) || context.checked === true,
22096
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(
22097
+ Primitive$1.span,
22098
+ {
22099
+ "data-state": getState(context.checked),
22100
+ "data-disabled": context.disabled ? "" : void 0,
22101
+ ...indicatorProps,
22102
+ ref: forwardedRef,
22103
+ style: { pointerEvents: "none", ...props.style }
22104
+ }
22105
+ )
22106
+ }
22107
+ );
22108
+ }
22109
+ );
22110
+ CheckboxIndicator.displayName = INDICATOR_NAME;
22111
+ var BUBBLE_INPUT_NAME = "CheckboxBubbleInput";
22112
+ var CheckboxBubbleInput = React.forwardRef(
22113
+ ({ __scopeCheckbox, ...props }, forwardedRef) => {
22114
+ const {
22115
+ control,
22116
+ hasConsumerStoppedPropagationRef,
22117
+ checked,
22118
+ defaultChecked,
22119
+ required,
22120
+ disabled,
22121
+ name,
22122
+ value,
22123
+ form,
22124
+ bubbleInput,
22125
+ setBubbleInput
22126
+ } = useCheckboxContext(BUBBLE_INPUT_NAME, __scopeCheckbox);
22127
+ const composedRefs = useComposedRefs(forwardedRef, setBubbleInput);
22128
+ const prevChecked = usePrevious(checked);
22129
+ const controlSize = useSize(control);
22130
+ React.useEffect(() => {
22131
+ const input = bubbleInput;
22132
+ if (!input) return;
22133
+ const inputProto = window.HTMLInputElement.prototype;
22134
+ const descriptor = Object.getOwnPropertyDescriptor(
22135
+ inputProto,
22136
+ "checked"
22137
+ );
22138
+ const setChecked = descriptor.set;
22139
+ const bubbles = !hasConsumerStoppedPropagationRef.current;
22140
+ if (prevChecked !== checked && setChecked) {
22141
+ const event = new Event("click", { bubbles });
22142
+ input.indeterminate = isIndeterminate(checked);
22143
+ setChecked.call(input, isIndeterminate(checked) ? false : checked);
22144
+ input.dispatchEvent(event);
22145
+ }
22146
+ }, [bubbleInput, prevChecked, checked, hasConsumerStoppedPropagationRef]);
22147
+ const defaultCheckedRef = React.useRef(isIndeterminate(checked) ? false : checked);
22148
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
22149
+ Primitive$1.input,
22150
+ {
22151
+ type: "checkbox",
22152
+ "aria-hidden": true,
22153
+ defaultChecked: defaultChecked ?? defaultCheckedRef.current,
22154
+ required,
22155
+ disabled,
22156
+ name,
22157
+ value,
22158
+ form,
22159
+ ...props,
22160
+ tabIndex: -1,
22161
+ ref: composedRefs,
22162
+ style: {
22163
+ ...props.style,
22164
+ ...controlSize,
22165
+ position: "absolute",
22166
+ pointerEvents: "none",
22167
+ opacity: 0,
22168
+ margin: 0,
22169
+ // We transform because the input is absolutely positioned but we have
22170
+ // rendered it **after** the button. This pulls it back to sit on top
22171
+ // of the button.
22172
+ transform: "translateX(-100%)"
22173
+ }
22174
+ }
22175
+ );
22176
+ }
22177
+ );
22178
+ CheckboxBubbleInput.displayName = BUBBLE_INPUT_NAME;
22179
+ function isFunction(value) {
22180
+ return typeof value === "function";
22181
+ }
22182
+ function isIndeterminate(checked) {
22183
+ return checked === "indeterminate";
22184
+ }
22185
+ function getState(checked) {
22186
+ return isIndeterminate(checked) ? "indeterminate" : checked ? "checked" : "unchecked";
22187
+ }
22188
+
22189
+ function PromCheckbox(_a) {
22190
+ var className = _a.className, props = __rest(_a, ["className"]);
22191
+ return (jsxRuntimeExports.jsx(Checkbox, __assign({ "data-slot": "checkbox", className: cn("peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50", className) }, props, { children: jsxRuntimeExports.jsx(CheckboxIndicator, { "data-slot": "checkbox-indicator", className: "grid place-content-center text-current transition-none", children: jsxRuntimeExports.jsx(Check, { className: "size-3.5" }) }) })));
22192
+ }
22193
+
22194
+ var PromSwitchListField = function (_a) {
22195
+ var name = _a.name, label = _a.label, options = _a.options, error = _a.error; _a.errorMsg; var _b = _a.isLoad, isLoad = _b === void 0 ? false : _b, _c = _a.disabled, disabled = _c === void 0 ? false : _c, _d = _a.errorDisplay, errorDisplay = _d === void 0 ? true : _d, className = _a.className, props = __rest(_a, ["name", "label", "options", "error", "errorMsg", "isLoad", "disabled", "errorDisplay", "className"]);
22196
+ var control = useFormContext().control;
22197
+ return (jsxRuntimeExports.jsx(PromFormFiled, { name: name, control: control, render: function (_a) {
22198
+ var field = _a.field, fieldState = _a.fieldState;
22199
+ return (jsxRuntimeExports.jsxs("div", { className: cn("relative space-y-3", className), children: [label && jsxRuntimeExports.jsx(PromLabel, { children: label }), !isLoad ? (jsxRuntimeExports.jsx("div", { className: "flex flex-wrap gap-5", children: options.map(function (option) {
22200
+ var values = field.value || [];
22201
+ var isChecked = values.includes(option.id);
22202
+ return (jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2", children: [jsxRuntimeExports.jsx(PromCheckbox, __assign({ id: "".concat(name, "-").concat(option.id), checked: isChecked, disabled: disabled, onCheckedChange: function (checked) {
22203
+ var newValues = checked
22204
+ ? __spreadArray(__spreadArray([], values, true), [option.id], false) : values.filter(function (id) { return id !== option.id; });
22205
+ field.onChange(newValues);
22206
+ } }, props)), jsxRuntimeExports.jsx(PromLabel, { htmlFor: "".concat(name, "-").concat(option.id), className: cn("text-gray-500 cursor-pointer", disabled && "cursor-not-allowed opacity-50"), children: option.title })] }, option.id));
22207
+ }) })) : (jsxRuntimeExports.jsx("div", { className: "flex flex-wrap gap-5", children: [1, 2, 3].map(function (i) { return (jsxRuntimeExports.jsx(PromSkeleton, { className: "w-10 h-5" }, i)); }) })), errorDisplay && fieldState.error && (jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: error ? (error(fieldState.error.message)) : (jsxRuntimeExports.jsx("p", { className: "text-red-500 text-sm mt-1", children: fieldState.error.message })) }))] }));
22208
+ } }));
22209
+ };
22210
+
21806
22211
  var promAllowedPatternUrlSocial = /^[a-zA-Z0-9_@:\/\.\-]*$/;
21807
22212
  var promAllowedPatternOnlyRu = /^[а-яёА-ЯЁ]*$/;
21808
22213
  var promAllowedPatternPhone = /^\+7\d{0,10}$/;
@@ -21878,6 +22283,14 @@ var promMaskPhoneWithoutPlus = function (val) {
21878
22283
  }
21879
22284
  return cleaned;
21880
22285
  };
22286
+ var promMaskUrl = function (val) {
22287
+ if (!val)
22288
+ return val;
22289
+ var httpsIndex = val.indexOf("https");
22290
+ if (httpsIndex === -1)
22291
+ return val;
22292
+ return val.substring(httpsIndex);
22293
+ };
21881
22294
  var promMaskEmail = function (val) {
21882
22295
  if (!val)
21883
22296
  return val;
@@ -24249,4 +24662,4 @@ var PROM_MSG_ERROR = {
24249
24662
  INVALID_VALUES: "Недопустимые значения",
24250
24663
  };
24251
24664
 
24252
- export { PROM_MSG_ERROR, PromButton, PromFormFiled, PromFrom, PromInput, PromLabel, PromMessage, PromSelect, PromSelectContent, PromSelectField, PromSelectGroup, PromSelectItem, PromSelectLabel, PromSelectScrollDownButton, PromSelectScrollUpButton, PromSelectSeparator, PromSelectTrigger, PromSelectValue, PromSkeleton, PromSwitch, PromSwitchField, PromTextarea, promAllowedPatternEmail, promAllowedPatternNaturalNumbers, promAllowedPatternOnlyRu, promAllowedPatternPhone, promAllowedPatternPhoneWithoutPlus, promAllowedPatternUrlSocial, promMaskEmail, promMaskPhone, promMaskPhoneWithoutPlus, promMaskTelegram, promMaskWhatsapp, promSchemaPhone, promSelectFilterOptions, useCreatePromForm, usePromForm };
24665
+ export { PROM_MSG_ERROR, PromButton, PromCheckbox, PromFormFiled, PromFrom, PromInput, PromLabel, PromMessage, PromSelect, PromSelectContent, PromSelectField, PromSelectGroup, PromSelectItem, PromSelectLabel, PromSelectScrollDownButton, PromSelectScrollUpButton, PromSelectSeparator, PromSelectTrigger, PromSelectValue, PromSkeleton, PromSwitch, PromSwitchField, PromSwitchListField, PromTextarea, promAllowedPatternEmail, promAllowedPatternNaturalNumbers, promAllowedPatternOnlyRu, promAllowedPatternPhone, promAllowedPatternPhoneWithoutPlus, promAllowedPatternUrlSocial, promMaskEmail, promMaskPhone, promMaskPhoneWithoutPlus, promMaskTelegram, promMaskUrl, promMaskWhatsapp, promSchemaPhone, promSelectFilterOptions, useCreatePromForm, usePromForm };
@@ -0,0 +1,4 @@
1
+ import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
2
+ import * as React from "react";
3
+ declare function PromCheckbox({ className, ...props }: React.ComponentProps<typeof CheckboxPrimitive.Root>): import("react/jsx-runtime").JSX.Element;
4
+ export { PromCheckbox };
@@ -3,4 +3,6 @@ export * from "./label";
3
3
  export * from "./textarea";
4
4
  export * from "./switch-field";
5
5
  export * from "./select-field";
6
+ export * from "./switch-field-list";
7
+ export * from "./checkbox";
6
8
  export * from "./types";
@@ -0,0 +1,15 @@
1
+ import * as React from "react";
2
+ import { PromDictionariesType } from "../../types";
3
+ interface PromSwitchListFieldProps {
4
+ name: string;
5
+ label?: string;
6
+ isLoad?: boolean;
7
+ errorMsg?: string;
8
+ className?: string;
9
+ disabled?: boolean;
10
+ errorDisplay?: boolean;
11
+ options: PromDictionariesType[];
12
+ error?: (msg: string) => React.ReactNode;
13
+ }
14
+ declare const PromSwitchListField: React.FC<PromSwitchListFieldProps>;
15
+ export { PromSwitchListField };
@@ -2,5 +2,6 @@ declare const promMaskTelegram: (val: string) => string;
2
2
  declare const promMaskWhatsapp: (val: string) => string;
3
3
  declare const promMaskPhone: (val: string) => string;
4
4
  declare const promMaskPhoneWithoutPlus: (val: string) => string;
5
+ declare const promMaskUrl: (val: string) => string;
5
6
  declare const promMaskEmail: (val: string) => string;
6
- export { promMaskEmail, promMaskPhone, promMaskTelegram, promMaskWhatsapp, promMaskPhoneWithoutPlus, };
7
+ export { promMaskUrl, promMaskEmail, promMaskPhone, promMaskTelegram, promMaskWhatsapp, promMaskPhoneWithoutPlus, };
@@ -6,3 +6,7 @@ export interface PromComponentProps {
6
6
  isLoad?: boolean;
7
7
  skeleton?: boolean;
8
8
  }
9
+ export interface PromDictionariesType {
10
+ id: number;
11
+ title: string;
12
+ }
@@ -0,0 +1,2 @@
1
+ declare class PromLoggerError {
2
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prom-pal-ui",
3
- "version": "1.4.2",
3
+ "version": "1.4.4",
4
4
  "type": "module",
5
5
  "main": "build/cjs/index.js",
6
6
  "module": "build/esm/index.js",
@@ -38,6 +38,7 @@
38
38
  "@radix-ui/react-slot": "^1.2.4",
39
39
  "@rollup/plugin-commonjs": "^29.0.0",
40
40
  "@rollup/plugin-node-resolve": "^16.0.3",
41
+ "@radix-ui/react-checkbox": "^1.3.3",
41
42
  "@rollup/plugin-typescript": "^12.3.0",
42
43
  "@tailwindcss/postcss": "^4.1.18",
43
44
  "@tailwindcss/vite": "^4.1.18",