@clubmed/trident-ui 2.0.0-beta.6 → 2.0.0-beta.60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -0
- package/assets/trident-ui.css +3 -0
- package/chunks/Carousel.context.js +1548 -0
- package/chunks/Carousel.context.js.map +1 -0
- package/chunks/ChatMessage.js +14395 -0
- package/chunks/ChatMessage.js.map +1 -0
- package/chunks/DateField.js +187 -126
- package/chunks/DateField.js.map +1 -1
- package/chunks/Datepicker.js +2064 -0
- package/chunks/Datepicker.js.map +1 -0
- package/chunks/Day.js +1210 -0
- package/chunks/Day.js.map +1 -0
- package/chunks/Range.js +2 -2
- package/chunks/Range.js.map +1 -1
- package/chunks/Tooltip.js +4461 -0
- package/chunks/Tooltip.js.map +1 -0
- package/chunks/addLeadingZeros.js +33 -0
- package/chunks/addLeadingZeros.js.map +1 -0
- package/chunks/chunk.js +11 -4
- package/chunks/client.js +18953 -0
- package/chunks/client.js.map +1 -0
- package/chunks/formatISO.js +29 -0
- package/chunks/formatISO.js.map +1 -0
- package/examples/advanced-toast-demo.js +2 -2
- package/examples/advanced-toast-demo.js.map +1 -1
- package/examples/advanced-toast-green-demo.js +1 -1
- package/examples/advanced-toast-green-demo.js.map +1 -1
- package/examples/advanced-toast-no-dismiss-demo.js +1 -1
- package/examples/advanced-toast-no-dismiss-demo.js.map +1 -1
- package/examples/advanced-toast-red-demo.js +1 -1
- package/examples/advanced-toast-red-demo.js.map +1 -1
- package/examples/advanced-toast-with-details-demo.js +2 -2
- package/examples/advanced-toast-with-details-demo.js.map +1 -1
- package/examples/button-demo.js +2 -2
- package/examples/button-demo.js.map +1 -1
- package/examples/chat-input-demo.d.ts +1 -0
- package/examples/chat-input-demo.js +21 -0
- package/examples/chat-input-demo.js.map +1 -0
- package/examples/chat-message-demo.d.ts +1 -0
- package/examples/chat-message-demo.js +20 -0
- package/examples/chat-message-demo.js.map +1 -0
- package/examples/chat-typing-indicator-demo.d.ts +1 -0
- package/examples/chat-typing-indicator-demo.js +14 -0
- package/examples/chat-typing-indicator-demo.js.map +1 -0
- package/examples/chat-window-csat-demo.d.ts +1 -0
- package/examples/chat-window-csat-demo.js +68 -0
- package/examples/chat-window-csat-demo.js.map +1 -0
- package/examples/chat-window-csat-prompt-demo.d.ts +1 -0
- package/examples/chat-window-csat-prompt-demo.js +40 -0
- package/examples/chat-window-csat-prompt-demo.js.map +1 -0
- package/examples/chat-window-demo.d.ts +1 -0
- package/examples/chat-window-demo.js +69 -0
- package/examples/chat-window-demo.js.map +1 -0
- package/examples/chat-window-quote-demo.d.ts +1 -0
- package/examples/chat-window-quote-demo.js +47 -0
- package/examples/chat-window-quote-demo.js.map +1 -0
- package/examples/chat-window-quotes-demo.d.ts +1 -0
- package/examples/chat-window-quotes-demo.js +67 -0
- package/examples/chat-window-quotes-demo.js.map +1 -0
- package/examples/checkbox-demo.js +17 -15
- package/examples/checkbox-demo.js.map +1 -1
- package/examples/checkbox-disabled-demo.js +12 -15
- package/examples/checkbox-disabled-demo.js.map +1 -1
- package/examples/checkbox-select-demo.d.ts +1 -0
- package/examples/checkbox-select-demo.js +101 -0
- package/examples/checkbox-select-demo.js.map +1 -0
- package/examples/checkboxes-demo.js +1 -1
- package/examples/checkboxes-demo.js.map +1 -1
- package/examples/checkboxes-with-form-control-demo.js +8 -8
- package/examples/checkboxes-with-form-control-demo.js.map +1 -1
- package/examples/choice-expander-demo.js +4 -67
- package/examples/choice-expander-demo.js.map +1 -1
- package/examples/countdown-demo.d.ts +1 -0
- package/examples/countdown-demo.js +39 -0
- package/examples/countdown-demo.js.map +1 -0
- package/examples/datepicker-demo.d.ts +1 -0
- package/examples/datepicker-demo.js +51 -0
- package/examples/datepicker-demo.js.map +1 -0
- package/examples/datepicker-disabled-days-demo.d.ts +1 -0
- package/examples/datepicker-disabled-days-demo.js +42 -0
- package/examples/datepicker-disabled-days-demo.js.map +1 -0
- package/examples/datepicker-duration-tooltip-demo.d.ts +1 -0
- package/examples/datepicker-duration-tooltip-demo.js +68 -0
- package/examples/datepicker-duration-tooltip-demo.js.map +1 -0
- package/examples/datepicker-no-prices-demo.d.ts +1 -0
- package/examples/datepicker-no-prices-demo.js +42 -0
- package/examples/datepicker-no-prices-demo.js.map +1 -0
- package/examples/datepicker-preselected-demo.d.ts +1 -0
- package/examples/datepicker-preselected-demo.js +77 -0
- package/examples/datepicker-preselected-demo.js.map +1 -0
- package/examples/dropdown-demo.js +9 -1
- package/examples/dropdown-demo.js.map +1 -1
- package/examples/elastic-height-demo.js +2 -1
- package/examples/elastic-height-demo.js.map +1 -1
- package/examples/expandable-text-demo.d.ts +1 -0
- package/examples/expandable-text-demo.js +22 -0
- package/examples/expandable-text-demo.js.map +1 -0
- package/examples/floating-label-text-field-demo.d.ts +1 -0
- package/examples/floating-label-text-field-demo.js +32 -0
- package/examples/floating-label-text-field-demo.js.map +1 -0
- package/examples/frame-demo.d.ts +1 -0
- package/examples/frame-demo.js +36 -0
- package/examples/frame-demo.js.map +1 -0
- package/examples/frame-horizontal-demo.d.ts +1 -0
- package/examples/frame-horizontal-demo.js +44 -0
- package/examples/frame-horizontal-demo.js.map +1 -0
- package/examples/frame-no-image-demo.d.ts +1 -0
- package/examples/frame-no-image-demo.js +47 -0
- package/examples/frame-no-image-demo.js.map +1 -0
- package/examples/frame-vertical-demo.d.ts +1 -0
- package/examples/frame-vertical-demo.js +44 -0
- package/examples/frame-vertical-demo.js.map +1 -0
- package/examples/frame-with-tag-demo.d.ts +1 -0
- package/examples/frame-with-tag-demo.js +48 -0
- package/examples/frame-with-tag-demo.js.map +1 -0
- package/examples/radio-demo.js +3 -3
- package/examples/radio-demo.js.map +1 -1
- package/examples/scrollbar-demo.d.ts +1 -0
- package/examples/scrollbar-demo.js +40 -0
- package/examples/scrollbar-demo.js.map +1 -0
- package/examples/slider-frame-demo.d.ts +1 -0
- package/examples/slider-frame-demo.js +38 -0
- package/examples/slider-frame-demo.js.map +1 -0
- package/examples/slider-frame-with-button-demo.d.ts +1 -0
- package/examples/slider-frame-with-button-demo.js +46 -0
- package/examples/slider-frame-with-button-demo.js.map +1 -0
- package/examples/slider-frame-with-tag-demo.d.ts +1 -0
- package/examples/slider-frame-with-tag-demo.js +50 -0
- package/examples/slider-frame-with-tag-demo.js.map +1 -0
- package/examples/switch-demo.js +1 -1
- package/examples/switch-demo.js.map +1 -1
- package/examples/tabs-demo.js +2 -5
- package/examples/tabs-demo.js.map +1 -1
- package/examples/text-field-demo.js +1 -0
- package/examples/text-field-demo.js.map +1 -1
- package/examples/toggle-demo.d.ts +1 -0
- package/examples/toggle-demo.js +43 -0
- package/examples/toggle-demo.js.map +1 -0
- package/examples/tooltip-demo.d.ts +1 -0
- package/examples/tooltip-demo.js +103 -0
- package/examples/tooltip-demo.js.map +1 -0
- package/package.json +10 -3
- package/styles/components.css +99 -0
- package/styles/theme.css +5 -2
- package/styles/ui/button.css +1 -1
- package/styles/ui/chat-button.css +68 -1
- package/styles/ui/controls.css +8 -52
- package/styles/ui/range.css +1 -1
- package/ui/AdvancedToast.js +17 -14
- package/ui/AdvancedToast.js.map +1 -1
- package/ui/BasicToast.js +1 -1
- package/ui/BasicToast.js.map +1 -1
- package/ui/ChatButton.js +1 -1
- package/ui/ChatButton.js.map +1 -1
- package/ui/ChatInput.d.ts +10 -0
- package/ui/ChatInput.js +149 -0
- package/ui/ChatInput.js.map +1 -0
- package/ui/ChatMessage.d.ts +6 -0
- package/ui/ChatMessage.js +2 -0
- package/ui/ChatTypingIndicator.d.ts +2 -0
- package/ui/ChatTypingIndicator.js +30 -0
- package/ui/ChatTypingIndicator.js.map +1 -0
- package/ui/ChatWindow.d.ts +34 -0
- package/ui/ChatWindow.js +142 -0
- package/ui/ChatWindow.js.map +1 -0
- package/ui/ChatWindowCsatPrompt.d.ts +15 -0
- package/ui/ChatWindowCsatPrompt.js +71 -0
- package/ui/ChatWindowCsatPrompt.js.map +1 -0
- package/ui/ChatWindowCsatThankYou.d.ts +9 -0
- package/ui/ChatWindowCsatThankYou.js +29 -0
- package/ui/ChatWindowCsatThankYou.js.map +1 -0
- package/ui/ChatWindowQuote.d.ts +22 -0
- package/ui/ChatWindowQuote.js +141 -0
- package/ui/ChatWindowQuote.js.map +1 -0
- package/ui/ChoiceExpander.js +1 -1
- package/ui/ChoiceExpander.js.map +1 -1
- package/ui/Countdown.d.ts +16 -0
- package/ui/Countdown.js +61 -0
- package/ui/Countdown.js.map +1 -0
- package/ui/Datepicker.d.ts +26 -0
- package/ui/Datepicker.js +3 -0
- package/ui/Day.d.ts +25 -0
- package/ui/Day.js +2 -0
- package/ui/Dropdown.d.ts +20 -3
- package/ui/Dropdown.js +57 -23
- package/ui/Dropdown.js.map +1 -1
- package/ui/ElasticHeight.d.ts +0 -1
- package/ui/ElasticHeight.js +14 -23
- package/ui/ElasticHeight.js.map +1 -1
- package/ui/ExpandableText.d.ts +14 -0
- package/ui/ExpandableText.js +40 -0
- package/ui/ExpandableText.js.map +1 -0
- package/ui/FlipCard.d.ts +7 -0
- package/ui/FlipCard.js +59 -0
- package/ui/FlipCard.js.map +1 -0
- package/ui/Scrollbar.d.ts +14 -0
- package/ui/Scrollbar.js +68 -0
- package/ui/Scrollbar.js.map +1 -0
- package/ui/SidebarLayout.d.ts +3 -1
- package/ui/SidebarLayout.js +32 -24
- package/ui/SidebarLayout.js.map +1 -1
- package/ui/Toggle.d.ts +14 -0
- package/ui/Toggle.js +42 -0
- package/ui/Toggle.js.map +1 -0
- package/ui/Tooltip.d.ts +8 -0
- package/ui/Tooltip.js +2 -0
- package/ui/buttons/Button.type.d.ts +1 -1
- package/ui/buttons/Button.type.js.map +1 -1
- package/ui/carousel/Carousel.context.d.ts +27 -0
- package/ui/carousel/Carousel.context.js +2 -0
- package/ui/carousel/Carousel.d.ts +3 -0
- package/ui/carousel/Carousel.js +12 -0
- package/ui/carousel/Carousel.js.map +1 -0
- package/ui/carousel/CarouselBody.d.ts +6 -0
- package/ui/carousel/CarouselBody.js +21 -0
- package/ui/carousel/CarouselBody.js.map +1 -0
- package/ui/carousel/CarouselItem.d.ts +6 -0
- package/ui/carousel/CarouselItem.js +21 -0
- package/ui/carousel/CarouselItem.js.map +1 -0
- package/ui/carousel/CarouselNext.d.ts +8 -0
- package/ui/carousel/CarouselNext.js +23 -0
- package/ui/carousel/CarouselNext.js.map +1 -0
- package/ui/carousel/CarouselPrevious.d.ts +8 -0
- package/ui/carousel/CarouselPrevious.js +23 -0
- package/ui/carousel/CarouselPrevious.js.map +1 -0
- package/ui/contexts/TridentUIConfig.js +1 -1
- package/ui/forms/CheckboxSelect.d.ts +31 -0
- package/ui/forms/CheckboxSelect.js +119 -0
- package/ui/forms/CheckboxSelect.js.map +1 -0
- package/ui/forms/Filter.d.ts +10 -4
- package/ui/forms/Filter.js +27 -45
- package/ui/forms/Filter.js.map +1 -1
- package/ui/forms/FloatingLabelTextField.d.ts +12 -0
- package/ui/forms/FloatingLabelTextField.js +132 -0
- package/ui/forms/FloatingLabelTextField.js.map +1 -0
- package/ui/forms/FormControl.d.ts +1 -1
- package/ui/forms/FormControl.js +4 -4
- package/ui/forms/FormControl.js.map +1 -1
- package/ui/forms/NumberField.d.ts +34 -34
- package/ui/forms/NumberField.js +15 -16
- package/ui/forms/NumberField.js.map +1 -1
- package/ui/forms/PhoneField.d.ts +5 -10
- package/ui/forms/PhoneField.js +29 -211
- package/ui/forms/PhoneField.js.map +1 -1
- package/ui/forms/PhoneFieldFullInput.d.ts +16 -0
- package/ui/forms/PhoneFieldFullInput.js +110 -0
- package/ui/forms/PhoneFieldFullInput.js.map +1 -0
- package/ui/forms/PhoneFieldSplitInput.d.ts +19 -0
- package/ui/forms/PhoneFieldSplitInput.js +157 -0
- package/ui/forms/PhoneFieldSplitInput.js.map +1 -0
- package/ui/forms/Range.d.ts +1 -1
- package/ui/forms/Select.js +7 -8
- package/ui/forms/Select.js.map +1 -1
- package/ui/forms/Switch.d.ts +5 -3
- package/ui/forms/Switch.js +54 -34
- package/ui/forms/Switch.js.map +1 -1
- package/ui/forms/TextField.js +23 -14
- package/ui/forms/TextField.js.map +1 -1
- package/ui/forms/checkboxes/Checkbox.d.ts +9 -4
- package/ui/forms/checkboxes/Checkbox.js +36 -16
- package/ui/forms/checkboxes/Checkbox.js.map +1 -1
- package/ui/forms/checkboxes/Checkboxes.js +3 -3
- package/ui/forms/checkboxes/Checkboxes.js.map +1 -1
- package/ui/forms/checkboxes/index.d.ts +0 -1
- package/ui/forms/checkboxes/index.js +1 -2
- package/ui/forms/password/Password.js +7 -8
- package/ui/forms/password/Password.js.map +1 -1
- package/ui/forms/radios/Radio.d.ts +2 -1
- package/ui/forms/radios/Radio.js +6 -3
- package/ui/forms/radios/Radio.js.map +1 -1
- package/ui/forms/radios/RadioGroup.js +13 -14
- package/ui/forms/radios/RadioGroup.js.map +1 -1
- package/ui/frame/Frame.d.ts +8 -0
- package/ui/frame/Frame.js +16 -0
- package/ui/frame/Frame.js.map +1 -0
- package/ui/frame/FrameLabelsWrapper.d.ts +5 -0
- package/ui/frame/FrameLabelsWrapper.js +12 -0
- package/ui/frame/FrameLabelsWrapper.js.map +1 -0
- package/ui/frame/FrameTitle.d.ts +7 -0
- package/ui/frame/FrameTitle.js +25 -0
- package/ui/frame/FrameTitle.js.map +1 -0
- package/ui/frame/FrameWrapper.d.ts +6 -0
- package/ui/frame/FrameWrapper.js +14 -0
- package/ui/frame/FrameWrapper.js.map +1 -0
- package/ui/frame/SliderFrame.d.ts +14 -0
- package/ui/frame/SliderFrame.js +50 -0
- package/ui/frame/SliderFrame.js.map +1 -0
- package/ui/helpers/cn.d.ts +2 -0
- package/ui/helpers/cn.js +10 -0
- package/ui/helpers/cn.js.map +1 -0
- package/ui/helpers/phone/defaultPrefixes.d.ts +1 -0
- package/ui/helpers/phone/defaultPrefixes.js +52 -28
- package/ui/helpers/phone/defaultPrefixes.js.map +1 -1
- package/ui/helpers/phone/formatters.d.ts +11 -0
- package/ui/helpers/phone/formatters.js +32 -1
- package/ui/helpers/phone/formatters.js.map +1 -1
- package/ui/helpers/phone/index.d.ts +1 -1
- package/ui/helpers/phone/index.js +3 -3
- package/ui/hooks/useIsClient.d.ts +1 -0
- package/ui/hooks/useIsClient.js +12 -0
- package/ui/hooks/useIsClient.js.map +1 -0
- package/ui/hooks/useValue.d.ts +3 -4
- package/ui/hooks/useValue.js +11 -11
- package/ui/hooks/useValue.js.map +1 -1
- package/ui/tabs/Tabs.js +161 -93
- package/ui/tabs/Tabs.js.map +1 -1
- package/examples/form-checkbox-demo.d.ts +0 -1
- package/examples/form-checkbox-demo.js +0 -30
- package/examples/form-checkbox-demo.js.map +0 -1
- package/examples/form-checkbox-disabled-demo.d.ts +0 -1
- package/examples/form-checkbox-disabled-demo.js +0 -25
- package/examples/form-checkbox-disabled-demo.js.map +0 -1
- package/ui/forms/checkboxes/FormCheckbox.d.ts +0 -12
- package/ui/forms/checkboxes/FormCheckbox.js +0 -38
- package/ui/forms/checkboxes/FormCheckbox.js.map +0 -1
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Image as e } from "../Image.js";
|
|
3
|
+
import { FrameWrapper as t } from "./FrameWrapper.js";
|
|
4
|
+
import { Carousel as n } from "../carousel/Carousel.js";
|
|
5
|
+
import { CarouselBody as r } from "../carousel/CarouselBody.js";
|
|
6
|
+
import { CarouselItem as i } from "../carousel/CarouselItem.js";
|
|
7
|
+
import { CarouselNext as a } from "../carousel/CarouselNext.js";
|
|
8
|
+
import { CarouselPrevious as o } from "../carousel/CarouselPrevious.js";
|
|
9
|
+
import { useMemo as s } from "react";
|
|
10
|
+
import { jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
11
|
+
//#region lib/ui/frame/SliderFrame.tsx
|
|
12
|
+
var u = ({ children: u, describedby: d, items: f, labels: p, ...m }) => {
|
|
13
|
+
let h = f.length > 1, g = s(() => f.map((t) => /* @__PURE__ */ c(e, {
|
|
14
|
+
...t,
|
|
15
|
+
className: "pointer-events-none size-full object-cover"
|
|
16
|
+
}, t.src)), [f]);
|
|
17
|
+
return /* @__PURE__ */ l(t, {
|
|
18
|
+
...m,
|
|
19
|
+
children: [h ? /* @__PURE__ */ l(n, {
|
|
20
|
+
className: "rounded-16 h-full select-none",
|
|
21
|
+
children: [/* @__PURE__ */ c(r, {
|
|
22
|
+
className: "h-full",
|
|
23
|
+
scrollClassName: "h-full auto-cols-full",
|
|
24
|
+
children: g.map((e, t) => /* @__PURE__ */ c(i, {
|
|
25
|
+
index: t,
|
|
26
|
+
children: /* @__PURE__ */ c("div", {
|
|
27
|
+
className: "h-full overflow-hidden",
|
|
28
|
+
children: e
|
|
29
|
+
})
|
|
30
|
+
}, t))
|
|
31
|
+
}), /* @__PURE__ */ l("div", {
|
|
32
|
+
className: "pointer-events-none absolute inset-0 z-1 -mx-70 flex items-center justify-between gap-x-20 px-12 opacity-0 transition-all group-hover:mx-0 group-hover:opacity-100",
|
|
33
|
+
children: [/* @__PURE__ */ c(o, {
|
|
34
|
+
"aria-describedby": d,
|
|
35
|
+
label: p.previous
|
|
36
|
+
}), /* @__PURE__ */ c(a, {
|
|
37
|
+
"aria-describedby": d,
|
|
38
|
+
label: p.next
|
|
39
|
+
})]
|
|
40
|
+
})]
|
|
41
|
+
}) : /* @__PURE__ */ c(e, {
|
|
42
|
+
...f[0],
|
|
43
|
+
className: "size-full object-cover"
|
|
44
|
+
}), u]
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
//#endregion
|
|
48
|
+
export { u as SliderFrame };
|
|
49
|
+
|
|
50
|
+
//# sourceMappingURL=SliderFrame.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SliderFrame.js","names":[],"sources":["../../../lib/ui/frame/SliderFrame.tsx"],"sourcesContent":["'use client';\nimport { type FunctionComponent, useMemo } from 'react';\n\nimport { Image, type ImageProps } from '../Image';\nimport { Carousel } from '../carousel/Carousel';\nimport { CarouselBody } from '../carousel/CarouselBody';\nimport { CarouselItem } from '../carousel/CarouselItem';\nimport { CarouselNext } from '../carousel/CarouselNext';\nimport { CarouselPrevious } from '../carousel/CarouselPrevious';\n\nimport { FrameWrapper, type FrameWrapperProps } from './FrameWrapper';\n\ninterface SliderLabels {\n next: string;\n previous: string;\n}\n\nexport interface SliderFrameProps extends FrameWrapperProps {\n describedby?: string;\n items: ImageProps[];\n labels: SliderLabels;\n}\n\nexport const SliderFrame: FunctionComponent<SliderFrameProps> = ({\n children,\n describedby,\n items,\n labels,\n ...props\n}) => {\n const hasScroll = items.length > 1;\n\n const sliderItems = useMemo(\n () =>\n items.map((item) => (\n <Image key={item.src} {...item} className=\"pointer-events-none size-full object-cover\" />\n )),\n [items],\n );\n\n return (\n <FrameWrapper {...props}>\n {hasScroll ? (\n <Carousel className=\"rounded-16 h-full select-none\">\n <CarouselBody className=\"h-full\" scrollClassName=\"h-full auto-cols-full\">\n {sliderItems.map((item, i) => (\n <CarouselItem index={i} key={i}>\n <div className=\"h-full overflow-hidden\">{item}</div>\n </CarouselItem>\n ))}\n </CarouselBody>\n <div className=\"pointer-events-none absolute inset-0 z-1 -mx-70 flex items-center justify-between gap-x-20 px-12 opacity-0 transition-all group-hover:mx-0 group-hover:opacity-100\">\n <CarouselPrevious aria-describedby={describedby} label={labels.previous} />\n <CarouselNext aria-describedby={describedby} label={labels.next} />\n </div>\n </Carousel>\n ) : (\n <Image {...items[0]} className=\"size-full object-cover\" />\n )}\n {children}\n </FrameWrapper>\n );\n};\n"],"mappings":";;;;;;;;;;;AAuBA,IAAa,KAAoD,EAC/D,aACA,gBACA,UACA,WACA,GAAG,QACC;CACJ,IAAM,IAAY,EAAM,SAAS,GAE3B,IAAc,QAEhB,EAAM,KAAK,MACT,kBAAC,GAAD;EAAsB,GAAI;EAAM,WAAU;EAA+C,EAA7E,EAAK,IAAwE,CACzF,EACJ,CAAC,EAAM,CACR;AAED,QACE,kBAAC,GAAD;EAAc,GAAI;YAAlB,CACG,IACC,kBAAC,GAAD;GAAU,WAAU;aAApB,CACE,kBAAC,GAAD;IAAc,WAAU;IAAS,iBAAgB;cAC9C,EAAY,KAAK,GAAM,MACtB,kBAAC,GAAD;KAAc,OAAO;eACnB,kBAAC,OAAD;MAAK,WAAU;gBAA0B;MAAW,CAAA;KACvC,EAFc,EAEd,CAAA;IAEJ,CAAA,EACf,kBAAC,OAAD;IAAK,WAAU;cAAf,CACE,kBAAC,GAAD;KAAkB,oBAAkB;KAAa,OAAO,EAAO;KAAY,CAAA,EAC3E,kBAAC,GAAD;KAAc,oBAAkB;KAAa,OAAO,EAAO;KAAQ,CAAA,CAAA;;OAIvE,kBAAC,GAAD;GAAO,GAAI,EAAM;GAAI,WAAU;GAA2B,CAAA,EAE3D,EAAA"}
|
package/ui/helpers/cn.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cn.js","names":[],"sources":["../../../lib/ui/helpers/cn.ts"],"sourcesContent":["import clsx, { type ClassValue } from 'clsx';\n\nimport { twMerge } from './twMerge';\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n"],"mappings":";;;AAIA,SAAgB,EAAG,GAAG,GAAsB;AAC1C,QAAO,EAAQ,EAAK,EAAO,CAAC"}
|
|
@@ -1,123 +1,147 @@
|
|
|
1
1
|
//#region lib/ui/helpers/phone/defaultPrefixes.ts
|
|
2
2
|
var e = [
|
|
3
|
+
{
|
|
4
|
+
code: "+33",
|
|
5
|
+
label: "Fra +33",
|
|
6
|
+
fullLabel: "France +33",
|
|
7
|
+
country: "FR"
|
|
8
|
+
},
|
|
3
9
|
{
|
|
4
10
|
code: "+1",
|
|
5
|
-
label: "
|
|
11
|
+
label: "USA +1",
|
|
12
|
+
fullLabel: "United States +1",
|
|
6
13
|
country: "US"
|
|
7
14
|
},
|
|
8
15
|
{
|
|
9
16
|
code: "+44",
|
|
10
|
-
label: "UK
|
|
17
|
+
label: "UK +44",
|
|
18
|
+
fullLabel: "United Kingdom +44",
|
|
11
19
|
country: "GB"
|
|
12
20
|
},
|
|
13
|
-
{
|
|
14
|
-
code: "+33",
|
|
15
|
-
label: "France (+33)",
|
|
16
|
-
country: "FR"
|
|
17
|
-
},
|
|
18
21
|
{
|
|
19
22
|
code: "+49",
|
|
20
|
-
label: "
|
|
23
|
+
label: "Ger +49",
|
|
24
|
+
fullLabel: "Germany +49",
|
|
21
25
|
country: "DE"
|
|
22
26
|
},
|
|
23
27
|
{
|
|
24
28
|
code: "+39",
|
|
25
|
-
label: "
|
|
29
|
+
label: "Ita +39",
|
|
30
|
+
fullLabel: "Italy +39",
|
|
26
31
|
country: "IT"
|
|
27
32
|
},
|
|
28
33
|
{
|
|
29
34
|
code: "+34",
|
|
30
|
-
label: "
|
|
35
|
+
label: "Spn +34",
|
|
36
|
+
fullLabel: "Spain +34",
|
|
31
37
|
country: "ES"
|
|
32
38
|
},
|
|
33
39
|
{
|
|
34
40
|
code: "+86",
|
|
35
|
-
label: "
|
|
41
|
+
label: "Chn +86",
|
|
42
|
+
fullLabel: "China +86",
|
|
36
43
|
country: "CN"
|
|
37
44
|
},
|
|
38
45
|
{
|
|
39
46
|
code: "+91",
|
|
40
|
-
label: "
|
|
47
|
+
label: "Ind +91",
|
|
48
|
+
fullLabel: "India +91",
|
|
41
49
|
country: "IN"
|
|
42
50
|
},
|
|
43
51
|
{
|
|
44
52
|
code: "+81",
|
|
45
|
-
label: "
|
|
53
|
+
label: "JP +81",
|
|
54
|
+
fullLabel: "Japan +81",
|
|
46
55
|
country: "JP"
|
|
47
56
|
},
|
|
48
57
|
{
|
|
49
58
|
code: "+82",
|
|
50
|
-
label: "
|
|
59
|
+
label: "Kr +82",
|
|
60
|
+
fullLabel: "South Korea +82",
|
|
51
61
|
country: "KR"
|
|
52
62
|
},
|
|
53
63
|
{
|
|
54
64
|
code: "+7",
|
|
55
|
-
label: "
|
|
65
|
+
label: "Rus +7",
|
|
66
|
+
fullLabel: "Russia +7",
|
|
56
67
|
country: "RU"
|
|
57
68
|
},
|
|
58
69
|
{
|
|
59
70
|
code: "+61",
|
|
60
|
-
label: "
|
|
71
|
+
label: "Aus +61",
|
|
72
|
+
fullLabel: "Australia +61",
|
|
61
73
|
country: "AU"
|
|
62
74
|
},
|
|
63
75
|
{
|
|
64
76
|
code: "+55",
|
|
65
|
-
label: "
|
|
77
|
+
label: "Bra +55",
|
|
78
|
+
fullLabel: "Brazil +55",
|
|
66
79
|
country: "BR"
|
|
67
80
|
},
|
|
68
81
|
{
|
|
69
82
|
code: "+52",
|
|
70
|
-
label: "
|
|
83
|
+
label: "Mex +52",
|
|
84
|
+
fullLabel: "Mexico +52",
|
|
71
85
|
country: "MX"
|
|
72
86
|
},
|
|
73
87
|
{
|
|
74
88
|
code: "+31",
|
|
75
|
-
label: "
|
|
89
|
+
label: "NL +31",
|
|
90
|
+
fullLabel: "Netherlands +31",
|
|
76
91
|
country: "NL"
|
|
77
92
|
},
|
|
78
93
|
{
|
|
79
94
|
code: "+46",
|
|
80
|
-
label: "
|
|
95
|
+
label: "Swe +46",
|
|
96
|
+
fullLabel: "Sweden +46",
|
|
81
97
|
country: "SE"
|
|
82
98
|
},
|
|
83
99
|
{
|
|
84
100
|
code: "+41",
|
|
85
|
-
label: "
|
|
101
|
+
label: "Swi +41",
|
|
102
|
+
fullLabel: "Switzerland +41",
|
|
86
103
|
country: "CH"
|
|
87
104
|
},
|
|
88
105
|
{
|
|
89
106
|
code: "+32",
|
|
90
|
-
label: "
|
|
107
|
+
label: "Bel +32",
|
|
108
|
+
fullLabel: "Belgium +32",
|
|
91
109
|
country: "BE"
|
|
92
110
|
},
|
|
93
111
|
{
|
|
94
112
|
code: "+48",
|
|
95
|
-
label: "
|
|
113
|
+
label: "Pol +48",
|
|
114
|
+
fullLabel: "Poland +48",
|
|
96
115
|
country: "PL"
|
|
97
116
|
},
|
|
98
117
|
{
|
|
99
118
|
code: "+351",
|
|
100
|
-
label: "
|
|
119
|
+
label: "Por +351",
|
|
120
|
+
fullLabel: "Portugal +351",
|
|
101
121
|
country: "PT"
|
|
102
122
|
},
|
|
103
123
|
{
|
|
104
124
|
code: "+30",
|
|
105
|
-
label: "
|
|
125
|
+
label: "Gre +30",
|
|
126
|
+
fullLabel: "Greece +30",
|
|
106
127
|
country: "GR"
|
|
107
128
|
},
|
|
108
129
|
{
|
|
109
130
|
code: "+47",
|
|
110
|
-
label: "
|
|
131
|
+
label: "Nor +47",
|
|
132
|
+
fullLabel: "Norway +47",
|
|
111
133
|
country: "NO"
|
|
112
134
|
},
|
|
113
135
|
{
|
|
114
136
|
code: "+45",
|
|
115
|
-
label: "
|
|
137
|
+
label: "Den +45",
|
|
138
|
+
fullLabel: "Denmark +45",
|
|
116
139
|
country: "DK"
|
|
117
140
|
},
|
|
118
141
|
{
|
|
119
142
|
code: "+358",
|
|
120
|
-
label: "
|
|
143
|
+
label: "Fin +358",
|
|
144
|
+
fullLabel: "Finland +358",
|
|
121
145
|
country: "FI"
|
|
122
146
|
}
|
|
123
147
|
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaultPrefixes.js","names":[],"sources":["../../../../lib/ui/helpers/phone/defaultPrefixes.ts"],"sourcesContent":["/**\n * Default phone number prefixes for common countries\n */\n\nexport interface PhonePrefix {\n code: string;\n label?: string;\n country?: string;\n}\n\n/**\n * List of common country phone prefixes\n * Sorted by popularity/usage frequency\n */\nexport const DEFAULT_PHONE_PREFIXES: PhonePrefix[] = [\n { code: '+
|
|
1
|
+
{"version":3,"file":"defaultPrefixes.js","names":[],"sources":["../../../../lib/ui/helpers/phone/defaultPrefixes.ts"],"sourcesContent":["/**\n * Default phone number prefixes for common countries\n */\n\nexport interface PhonePrefix {\n code: string;\n label?: string;\n fullLabel?: string;\n country?: string;\n}\n\n/**\n * List of common country phone prefixes\n * Sorted by popularity/usage frequency\n */\nexport const DEFAULT_PHONE_PREFIXES: PhonePrefix[] = [\n { code: '+33', label: 'Fra +33', fullLabel: 'France +33', country: 'FR' },\n { code: '+1', label: 'USA +1', fullLabel: 'United States +1', country: 'US' },\n { code: '+44', label: 'UK +44', fullLabel: 'United Kingdom +44', country: 'GB' },\n { code: '+49', label: 'Ger +49', fullLabel: 'Germany +49', country: 'DE' },\n { code: '+39', label: 'Ita +39', fullLabel: 'Italy +39', country: 'IT' },\n { code: '+34', label: 'Spn +34', fullLabel: 'Spain +34', country: 'ES' },\n { code: '+86', label: 'Chn +86', fullLabel: 'China +86', country: 'CN' },\n { code: '+91', label: 'Ind +91', fullLabel: 'India +91', country: 'IN' },\n { code: '+81', label: 'JP +81', fullLabel: 'Japan +81', country: 'JP' },\n { code: '+82', label: 'Kr +82', fullLabel: 'South Korea +82', country: 'KR' },\n { code: '+7', label: 'Rus +7', fullLabel: 'Russia +7', country: 'RU' },\n { code: '+61', label: 'Aus +61', fullLabel: 'Australia +61', country: 'AU' },\n { code: '+55', label: 'Bra +55', fullLabel: 'Brazil +55', country: 'BR' },\n { code: '+52', label: 'Mex +52', fullLabel: 'Mexico +52', country: 'MX' },\n { code: '+31', label: 'NL +31', fullLabel: 'Netherlands +31', country: 'NL' },\n { code: '+46', label: 'Swe +46', fullLabel: 'Sweden +46', country: 'SE' },\n { code: '+41', label: 'Swi +41', fullLabel: 'Switzerland +41', country: 'CH' },\n { code: '+32', label: 'Bel +32', fullLabel: 'Belgium +32', country: 'BE' },\n { code: '+48', label: 'Pol +48', fullLabel: 'Poland +48', country: 'PL' },\n { code: '+351', label: 'Por +351', fullLabel: 'Portugal +351', country: 'PT' },\n { code: '+30', label: 'Gre +30', fullLabel: 'Greece +30', country: 'GR' },\n { code: '+47', label: 'Nor +47', fullLabel: 'Norway +47', country: 'NO' },\n { code: '+45', label: 'Den +45', fullLabel: 'Denmark +45', country: 'DK' },\n { code: '+358', label: 'Fin +358', fullLabel: 'Finland +358', country: 'FI' },\n];\n"],"mappings":";AAeA,IAAa,IAAwC;CACnD;EAAE,MAAM;EAAO,OAAO;EAAW,WAAW;EAAc,SAAS;EAAM;CACzE;EAAE,MAAM;EAAM,OAAO;EAAU,WAAW;EAAoB,SAAS;EAAM;CAC7E;EAAE,MAAM;EAAO,OAAO;EAAU,WAAW;EAAsB,SAAS;EAAM;CAChF;EAAE,MAAM;EAAO,OAAO;EAAW,WAAW;EAAe,SAAS;EAAM;CAC1E;EAAE,MAAM;EAAO,OAAO;EAAW,WAAW;EAAa,SAAS;EAAM;CACxE;EAAE,MAAM;EAAO,OAAO;EAAW,WAAW;EAAa,SAAS;EAAM;CACxE;EAAE,MAAM;EAAO,OAAO;EAAW,WAAW;EAAa,SAAS;EAAM;CACxE;EAAE,MAAM;EAAO,OAAO;EAAW,WAAW;EAAa,SAAS;EAAM;CACxE;EAAE,MAAM;EAAO,OAAO;EAAU,WAAW;EAAa,SAAS;EAAM;CACvE;EAAE,MAAM;EAAO,OAAO;EAAU,WAAW;EAAmB,SAAS;EAAM;CAC7E;EAAE,MAAM;EAAM,OAAO;EAAU,WAAW;EAAa,SAAS;EAAM;CACtE;EAAE,MAAM;EAAO,OAAO;EAAW,WAAW;EAAiB,SAAS;EAAM;CAC5E;EAAE,MAAM;EAAO,OAAO;EAAW,WAAW;EAAc,SAAS;EAAM;CACzE;EAAE,MAAM;EAAO,OAAO;EAAW,WAAW;EAAc,SAAS;EAAM;CACzE;EAAE,MAAM;EAAO,OAAO;EAAU,WAAW;EAAmB,SAAS;EAAM;CAC7E;EAAE,MAAM;EAAO,OAAO;EAAW,WAAW;EAAc,SAAS;EAAM;CACzE;EAAE,MAAM;EAAO,OAAO;EAAW,WAAW;EAAmB,SAAS;EAAM;CAC9E;EAAE,MAAM;EAAO,OAAO;EAAW,WAAW;EAAe,SAAS;EAAM;CAC1E;EAAE,MAAM;EAAO,OAAO;EAAW,WAAW;EAAc,SAAS;EAAM;CACzE;EAAE,MAAM;EAAQ,OAAO;EAAY,WAAW;EAAiB,SAAS;EAAM;CAC9E;EAAE,MAAM;EAAO,OAAO;EAAW,WAAW;EAAc,SAAS;EAAM;CACzE;EAAE,MAAM;EAAO,OAAO;EAAW,WAAW;EAAc,SAAS;EAAM;CACzE;EAAE,MAAM;EAAO,OAAO;EAAW,WAAW;EAAe,SAAS;EAAM;CAC1E;EAAE,MAAM;EAAQ,OAAO;EAAY,WAAW;EAAgB,SAAS;EAAM;CAC9E"}
|
|
@@ -44,3 +44,14 @@ export declare function getCursorPosition(oldValue: string, newValue: string, ol
|
|
|
44
44
|
* @returns Number of '#' characters in pattern
|
|
45
45
|
*/
|
|
46
46
|
export declare function countDigitPlaceholders(pattern: string): number;
|
|
47
|
+
export declare function getLiteralPrefixInfo(pattern: string): {
|
|
48
|
+
literalPrefix: string;
|
|
49
|
+
literalPrefixDigits: string;
|
|
50
|
+
};
|
|
51
|
+
export declare function stripLiteralPrefix(allDigits: string, literalPrefixDigits: string): string;
|
|
52
|
+
export declare function calculateCursorPosition(digitsBeforeCursor: number, formatted: string, literalPrefixDigits: string): number;
|
|
53
|
+
export declare function formatPhoneDigits(inputValue: string, pattern: string, cursorPosition: number): {
|
|
54
|
+
formatted: string;
|
|
55
|
+
nextCursor: number;
|
|
56
|
+
literalPrefixDigits: string;
|
|
57
|
+
} | null;
|
|
@@ -27,7 +27,38 @@ function n(t, n, r) {
|
|
|
27
27
|
function r(e) {
|
|
28
28
|
return (e.match(/#/g) || []).length;
|
|
29
29
|
}
|
|
30
|
+
function i(t) {
|
|
31
|
+
let n = t.indexOf("#"), r = n > 0 ? t.substring(0, n) : "";
|
|
32
|
+
return {
|
|
33
|
+
literalPrefix: r,
|
|
34
|
+
literalPrefixDigits: e(r)
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function a(e, t) {
|
|
38
|
+
return t.length > 0 && e.startsWith(t) ? e.substring(t.length) : e;
|
|
39
|
+
}
|
|
40
|
+
function o(e, t, n) {
|
|
41
|
+
let r = 0, i = 0;
|
|
42
|
+
for (let a = 0; a < t.length; a++) if (/\d/.test(t[a])) {
|
|
43
|
+
if (i < n.length) {
|
|
44
|
+
i++;
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
if (r++, r === e) return a + 1;
|
|
48
|
+
}
|
|
49
|
+
return t.length;
|
|
50
|
+
}
|
|
51
|
+
function s(n, s, c) {
|
|
52
|
+
let { literalPrefixDigits: l } = i(s), u = a(e(n), l), d = r(s);
|
|
53
|
+
if (u.length > d) return null;
|
|
54
|
+
let f = a(e(n.substring(0, c)), l).length, p = t(u, s);
|
|
55
|
+
return {
|
|
56
|
+
formatted: p,
|
|
57
|
+
nextCursor: o(f, p, l),
|
|
58
|
+
literalPrefixDigits: l
|
|
59
|
+
};
|
|
60
|
+
}
|
|
30
61
|
//#endregion
|
|
31
|
-
export { r as countDigitPlaceholders, e as extractDigits, t as formatWithPattern, n as getCursorPosition };
|
|
62
|
+
export { o as calculateCursorPosition, r as countDigitPlaceholders, e as extractDigits, s as formatPhoneDigits, t as formatWithPattern, n as getCursorPosition, i as getLiteralPrefixInfo, a as stripLiteralPrefix };
|
|
32
63
|
|
|
33
64
|
//# sourceMappingURL=formatters.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatters.js","names":[],"sources":["../../../../lib/ui/helpers/phone/formatters.ts"],"sourcesContent":["/**\n * Phone number formatting utilities\n * Provides pattern-based formatting without external dependencies\n */\n\n/**\n * Extract only digits from a string\n * @param value - Input string that may contain non-digit characters\n * @returns String containing only digits (0-9)\n */\nexport function extractDigits(value: string): string {\n return value.replace(/\\D/g, '');\n}\n\n/**\n * Apply a pattern to input digits\n * Pattern uses '#' as placeholder for digits, other characters are literals\n *\n * @example\n * formatWithPattern(\"5551234567\", \"+1 (###) ###-####\")\n * // returns \"+1 (555) 123-4567\"\n *\n * @param value - String containing the digits to format\n * @param pattern - Format pattern where '#' represents a digit placeholder\n * @returns Formatted string according to pattern\n */\nexport function formatWithPattern(value: string, pattern: string): string {\n const digits = extractDigits(value);\n if (digits.length === 0) return '';\n\n let digitIndex = 0;\n let result = '';\n let started = false;\n\n for (let i = 0; i < pattern.length; i++) {\n if (pattern[i] === '#') {\n if (digitIndex < digits.length) {\n // Add any leading literals before the first digit\n if (!started) {\n // Add all literals from start until this digit\n for (let j = 0; j < i; j++) {\n if (pattern[j] !== '#') {\n result += pattern[j];\n }\n }\n started = true;\n }\n\n result += digits[digitIndex];\n digitIndex++;\n } else {\n // No more digits available\n break;\n }\n } else if (started) {\n // Literal character after we've started\n result += pattern[i];\n }\n }\n\n return result;\n}\n\n/**\n * Calculate cursor position after formatting\n * Critical for UX - ensures cursor stays in correct position relative to digits\n *\n * @example\n * // User types \"4\" at position: \"1|23\" → \"1423\"\n * // After formatting: \"(14) 23\"\n * // Cursor should be: \"(14|) 23\" (after the 4, not at end)\n *\n * @param oldValue - Previous input value\n * @param newValue - New formatted value\n * @param oldCursor - Cursor position before formatting\n * @returns New cursor position after formatting\n */\nexport function getCursorPosition(oldValue: string, newValue: string, oldCursor: number): number {\n // Count digits before cursor in old value\n const digitsBeforeCursor = extractDigits(oldValue.substring(0, oldCursor)).length;\n\n // Find position in new value where we have the same number of digits\n let digitCount = 0;\n let newCursor = 0;\n\n for (let i = 0; i < newValue.length; i++) {\n if (/\\d/.test(newValue[i])) {\n digitCount++;\n if (digitCount === digitsBeforeCursor) {\n newCursor = i + 1;\n break;\n }\n }\n }\n\n // If we didn't find enough digits, cursor goes to end\n if (digitCount < digitsBeforeCursor) {\n newCursor = newValue.length;\n }\n\n return newCursor;\n}\n\n/**\n * Count digit placeholders in a pattern\n * Used to determine maximum number of digits allowed\n *\n * @param pattern - Format pattern\n * @returns Number of '#' characters in pattern\n */\nexport function countDigitPlaceholders(pattern: string): number {\n return (pattern.match(/#/g) || []).length;\n}\n"],"mappings":";AAUA,SAAgB,EAAc,GAAuB;AACnD,QAAO,EAAM,QAAQ,OAAO,GAAG;;AAejC,SAAgB,EAAkB,GAAe,GAAyB;CACxE,IAAM,IAAS,EAAc,EAAM;AACnC,KAAI,EAAO,WAAW,EAAG,QAAO;CAEhC,IAAI,IAAa,GACb,IAAS,IACT,IAAU;AAEd,MAAK,IAAI,IAAI,GAAG,IAAI,EAAQ,QAAQ,IAClC,KAAI,EAAQ,OAAO,IACjB,KAAI,IAAa,EAAO,QAAQ;AAE9B,MAAI,CAAC,GAAS;AAEZ,QAAK,IAAI,IAAI,GAAG,IAAI,GAAG,IACrB,CAAI,EAAQ,OAAO,QACjB,KAAU,EAAQ;AAGtB,OAAU;;AAIZ,EADA,KAAU,EAAO,IACjB;OAGA;MAEO,MAET,KAAU,EAAQ;AAItB,QAAO;;AAiBT,SAAgB,EAAkB,GAAkB,GAAkB,GAA2B;CAE/F,IAAM,IAAqB,EAAc,EAAS,UAAU,GAAG,EAAU,CAAC,CAAC,QAGvE,IAAa,GACb,IAAY;AAEhB,MAAK,IAAI,IAAI,GAAG,IAAI,EAAS,QAAQ,IACnC,KAAI,KAAK,KAAK,EAAS,GAAG,KACxB,KACI,MAAe,IAAoB;AACrC,MAAY,IAAI;AAChB;;AAUN,QAJI,IAAa,MACf,IAAY,EAAS,SAGhB;;AAUT,SAAgB,EAAuB,GAAyB;AAC9D,SAAQ,EAAQ,MAAM,KAAK,IAAI,EAAE,EAAE"}
|
|
1
|
+
{"version":3,"file":"formatters.js","names":[],"sources":["../../../../lib/ui/helpers/phone/formatters.ts"],"sourcesContent":["/**\n * Phone number formatting utilities\n * Provides pattern-based formatting without external dependencies\n */\n\n/**\n * Extract only digits from a string\n * @param value - Input string that may contain non-digit characters\n * @returns String containing only digits (0-9)\n */\nexport function extractDigits(value: string): string {\n return value.replace(/\\D/g, '');\n}\n\n/**\n * Apply a pattern to input digits\n * Pattern uses '#' as placeholder for digits, other characters are literals\n *\n * @example\n * formatWithPattern(\"5551234567\", \"+1 (###) ###-####\")\n * // returns \"+1 (555) 123-4567\"\n *\n * @param value - String containing the digits to format\n * @param pattern - Format pattern where '#' represents a digit placeholder\n * @returns Formatted string according to pattern\n */\nexport function formatWithPattern(value: string, pattern: string): string {\n const digits = extractDigits(value);\n if (digits.length === 0) return '';\n\n let digitIndex = 0;\n let result = '';\n let started = false;\n\n for (let i = 0; i < pattern.length; i++) {\n if (pattern[i] === '#') {\n if (digitIndex < digits.length) {\n // Add any leading literals before the first digit\n if (!started) {\n // Add all literals from start until this digit\n for (let j = 0; j < i; j++) {\n if (pattern[j] !== '#') {\n result += pattern[j];\n }\n }\n started = true;\n }\n\n result += digits[digitIndex];\n digitIndex++;\n } else {\n // No more digits available\n break;\n }\n } else if (started) {\n // Literal character after we've started\n result += pattern[i];\n }\n }\n\n return result;\n}\n\n/**\n * Calculate cursor position after formatting\n * Critical for UX - ensures cursor stays in correct position relative to digits\n *\n * @example\n * // User types \"4\" at position: \"1|23\" → \"1423\"\n * // After formatting: \"(14) 23\"\n * // Cursor should be: \"(14|) 23\" (after the 4, not at end)\n *\n * @param oldValue - Previous input value\n * @param newValue - New formatted value\n * @param oldCursor - Cursor position before formatting\n * @returns New cursor position after formatting\n */\nexport function getCursorPosition(oldValue: string, newValue: string, oldCursor: number): number {\n // Count digits before cursor in old value\n const digitsBeforeCursor = extractDigits(oldValue.substring(0, oldCursor)).length;\n\n // Find position in new value where we have the same number of digits\n let digitCount = 0;\n let newCursor = 0;\n\n for (let i = 0; i < newValue.length; i++) {\n if (/\\d/.test(newValue[i])) {\n digitCount++;\n if (digitCount === digitsBeforeCursor) {\n newCursor = i + 1;\n break;\n }\n }\n }\n\n // If we didn't find enough digits, cursor goes to end\n if (digitCount < digitsBeforeCursor) {\n newCursor = newValue.length;\n }\n\n return newCursor;\n}\n\n/**\n * Count digit placeholders in a pattern\n * Used to determine maximum number of digits allowed\n *\n * @param pattern - Format pattern\n * @returns Number of '#' characters in pattern\n */\nexport function countDigitPlaceholders(pattern: string): number {\n return (pattern.match(/#/g) || []).length;\n}\n\nexport function getLiteralPrefixInfo(pattern: string): {\n literalPrefix: string;\n literalPrefixDigits: string;\n} {\n const firstHashIndex = pattern.indexOf('#');\n const literalPrefix = firstHashIndex > 0 ? pattern.substring(0, firstHashIndex) : '';\n const literalPrefixDigits = extractDigits(literalPrefix);\n return { literalPrefix, literalPrefixDigits };\n}\n\nexport function stripLiteralPrefix(allDigits: string, literalPrefixDigits: string): string {\n if (literalPrefixDigits.length > 0 && allDigits.startsWith(literalPrefixDigits)) {\n return allDigits.substring(literalPrefixDigits.length);\n }\n return allDigits;\n}\n\nexport function calculateCursorPosition(\n digitsBeforeCursor: number,\n formatted: string,\n literalPrefixDigits: string,\n): number {\n let digitCount = 0;\n let skippedPrefixDigits = 0;\n\n for (let i = 0; i < formatted.length; i++) {\n if (/\\d/.test(formatted[i])) {\n if (skippedPrefixDigits < literalPrefixDigits.length) {\n skippedPrefixDigits++;\n continue;\n }\n digitCount++;\n if (digitCount === digitsBeforeCursor) {\n return i + 1;\n }\n }\n }\n\n return formatted.length;\n}\n\nexport function formatPhoneDigits(\n inputValue: string,\n pattern: string,\n cursorPosition: number,\n): { formatted: string; nextCursor: number; literalPrefixDigits: string } | null {\n const { literalPrefixDigits } = getLiteralPrefixInfo(pattern);\n const allDigits = stripLiteralPrefix(extractDigits(inputValue), literalPrefixDigits);\n const maxDigits = countDigitPlaceholders(pattern);\n if (allDigits.length > maxDigits) return null;\n\n const digitsBeforeCursorInInput = stripLiteralPrefix(\n extractDigits(inputValue.substring(0, cursorPosition)),\n literalPrefixDigits,\n );\n const digitsBeforeCursor = digitsBeforeCursorInInput.length;\n const formatted = formatWithPattern(allDigits, pattern);\n const nextCursor = calculateCursorPosition(digitsBeforeCursor, formatted, literalPrefixDigits);\n return { formatted, nextCursor, literalPrefixDigits };\n}\n"],"mappings":";AAUA,SAAgB,EAAc,GAAuB;AACnD,QAAO,EAAM,QAAQ,OAAO,GAAG;;AAejC,SAAgB,EAAkB,GAAe,GAAyB;CACxE,IAAM,IAAS,EAAc,EAAM;AACnC,KAAI,EAAO,WAAW,EAAG,QAAO;CAEhC,IAAI,IAAa,GACb,IAAS,IACT,IAAU;AAEd,MAAK,IAAI,IAAI,GAAG,IAAI,EAAQ,QAAQ,IAClC,KAAI,EAAQ,OAAO,IACjB,KAAI,IAAa,EAAO,QAAQ;AAE9B,MAAI,CAAC,GAAS;AAEZ,QAAK,IAAI,IAAI,GAAG,IAAI,GAAG,IACrB,CAAI,EAAQ,OAAO,QACjB,KAAU,EAAQ;AAGtB,OAAU;;AAIZ,EADA,KAAU,EAAO,IACjB;OAGA;MAEO,MAET,KAAU,EAAQ;AAItB,QAAO;;AAiBT,SAAgB,EAAkB,GAAkB,GAAkB,GAA2B;CAE/F,IAAM,IAAqB,EAAc,EAAS,UAAU,GAAG,EAAU,CAAC,CAAC,QAGvE,IAAa,GACb,IAAY;AAEhB,MAAK,IAAI,IAAI,GAAG,IAAI,EAAS,QAAQ,IACnC,KAAI,KAAK,KAAK,EAAS,GAAG,KACxB,KACI,MAAe,IAAoB;AACrC,MAAY,IAAI;AAChB;;AAUN,QAJI,IAAa,MACf,IAAY,EAAS,SAGhB;;AAUT,SAAgB,EAAuB,GAAyB;AAC9D,SAAQ,EAAQ,MAAM,KAAK,IAAI,EAAE,EAAE;;AAGrC,SAAgB,EAAqB,GAGnC;CACA,IAAM,IAAiB,EAAQ,QAAQ,IAAI,EACrC,IAAgB,IAAiB,IAAI,EAAQ,UAAU,GAAG,EAAe,GAAG;AAElF,QAAO;EAAE;EAAe,qBADI,EAAc,EAAc;EACX;;AAG/C,SAAgB,EAAmB,GAAmB,GAAqC;AAIzF,QAHI,EAAoB,SAAS,KAAK,EAAU,WAAW,EAAoB,GACtE,EAAU,UAAU,EAAoB,OAAO,GAEjD;;AAGT,SAAgB,EACd,GACA,GACA,GACQ;CACR,IAAI,IAAa,GACb,IAAsB;AAE1B,MAAK,IAAI,IAAI,GAAG,IAAI,EAAU,QAAQ,IACpC,KAAI,KAAK,KAAK,EAAU,GAAG,EAAE;AAC3B,MAAI,IAAsB,EAAoB,QAAQ;AACpD;AACA;;AAGF,MADA,KACI,MAAe,EACjB,QAAO,IAAI;;AAKjB,QAAO,EAAU;;AAGnB,SAAgB,EACd,GACA,GACA,GAC+E;CAC/E,IAAM,EAAE,2BAAwB,EAAqB,EAAQ,EACvD,IAAY,EAAmB,EAAc,EAAW,EAAE,EAAoB,EAC9E,IAAY,EAAuB,EAAQ;AACjD,KAAI,EAAU,SAAS,EAAW,QAAO;CAMzC,IAAM,IAJ4B,EAChC,EAAc,EAAW,UAAU,GAAG,EAAe,CAAC,EACtD,EACD,CACoD,QAC/C,IAAY,EAAkB,GAAW,EAAQ;AAEvD,QAAO;EAAE;EAAW,YADD,EAAwB,GAAoB,GAAW,EAAoB;EAC9D;EAAqB"}
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
* Phone number utilities
|
|
3
3
|
* Provides formatting, validation, and default prefixes for phone number inputs
|
|
4
4
|
*/
|
|
5
|
-
export { extractDigits, formatWithPattern, getCursorPosition, countDigitPlaceholders, } from './formatters';
|
|
5
|
+
export { extractDigits, formatWithPattern, getCursorPosition, countDigitPlaceholders, getLiteralPrefixInfo, stripLiteralPrefix, calculateCursorPosition, formatPhoneDigits, } from './formatters';
|
|
6
6
|
export { DEFAULT_PHONE_PREFIXES, type PhonePrefix } from './defaultPrefixes';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { DEFAULT_PHONE_PREFIXES as
|
|
3
|
-
export {
|
|
1
|
+
import { calculateCursorPosition as e, countDigitPlaceholders as t, extractDigits as n, formatPhoneDigits as r, formatWithPattern as i, getCursorPosition as a, getLiteralPrefixInfo as o, stripLiteralPrefix as s } from "./formatters.js";
|
|
2
|
+
import { DEFAULT_PHONE_PREFIXES as c } from "./defaultPrefixes.js";
|
|
3
|
+
export { c as DEFAULT_PHONE_PREFIXES, e as calculateCursorPosition, t as countDigitPlaceholders, n as extractDigits, r as formatPhoneDigits, i as formatWithPattern, a as getCursorPosition, o as getLiteralPrefixInfo, s as stripLiteralPrefix };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useIsClient: () => boolean;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { useEffect as e, useState as t } from "react";
|
|
2
|
+
//#region lib/ui/hooks/useIsClient.ts
|
|
3
|
+
var n = () => {
|
|
4
|
+
let [n, r] = t(!1);
|
|
5
|
+
return e(() => {
|
|
6
|
+
r(!0);
|
|
7
|
+
}, []), n;
|
|
8
|
+
};
|
|
9
|
+
//#endregion
|
|
10
|
+
export { n as useIsClient };
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=useIsClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useIsClient.js","names":[],"sources":["../../../lib/ui/hooks/useIsClient.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nexport const useIsClient = () => {\n const [isClient, setIsClient] = useState(false);\n\n useEffect(() => {\n setIsClient(true);\n }, []);\n\n return isClient;\n};\n"],"mappings":";;AAEA,IAAa,UAAoB;CAC/B,IAAM,CAAC,GAAU,KAAe,EAAS,GAAM;AAM/C,QAJA,QAAgB;AACd,IAAY,GAAK;IAChB,EAAE,CAAC,EAEC"}
|
package/ui/hooks/useValue.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
export interface UseValueProps<Value = string, InitialValue = Value> {
|
|
2
|
-
name: string;
|
|
3
2
|
initialValue?: InitialValue;
|
|
4
3
|
defaultValue?: Value | string;
|
|
5
4
|
formatter?: (v: Value) => Value;
|
|
6
|
-
onChange?: (
|
|
5
|
+
onChange?: (event: Event, value: Value) => void;
|
|
7
6
|
}
|
|
8
|
-
export declare function useValue<Value = string, InitialValue = Value>({
|
|
7
|
+
export declare function useValue<Value = string, InitialValue = Value>({ initialValue, onChange, defaultValue, formatter, }: UseValueProps<Value, InitialValue>): {
|
|
9
8
|
value: Value;
|
|
10
|
-
setValue: (newValue: Value) => void;
|
|
9
|
+
setValue: (newValue: Value, event?: Event) => void;
|
|
11
10
|
resetValue: () => void;
|
|
12
11
|
};
|
package/ui/hooks/useValue.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { useEffect as e, useState as t } from "react";
|
|
2
2
|
//#region lib/ui/hooks/useValue.ts
|
|
3
|
-
function n({
|
|
4
|
-
let [
|
|
3
|
+
function n({ initialValue: n, onChange: r, defaultValue: i = "", formatter: a = (e) => e }) {
|
|
4
|
+
let [o, s] = t(a(n || i));
|
|
5
5
|
e(() => {
|
|
6
|
-
|
|
7
|
-
}, [
|
|
8
|
-
function
|
|
9
|
-
e =
|
|
6
|
+
s(a(n ?? i));
|
|
7
|
+
}, [n]);
|
|
8
|
+
function c(e, t) {
|
|
9
|
+
e = a(e), s(e), r && r(t ?? new Event("change"), e);
|
|
10
10
|
}
|
|
11
|
-
function
|
|
12
|
-
|
|
11
|
+
function l() {
|
|
12
|
+
s(i);
|
|
13
13
|
}
|
|
14
14
|
return {
|
|
15
|
-
value:
|
|
16
|
-
setValue:
|
|
17
|
-
resetValue:
|
|
15
|
+
value: o,
|
|
16
|
+
setValue: c,
|
|
17
|
+
resetValue: l
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
20
|
//#endregion
|
package/ui/hooks/useValue.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useValue.js","names":[],"sources":["../../../lib/ui/hooks/useValue.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nexport interface UseValueProps<Value = string, InitialValue = Value> {\n
|
|
1
|
+
{"version":3,"file":"useValue.js","names":[],"sources":["../../../lib/ui/hooks/useValue.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nexport interface UseValueProps<Value = string, InitialValue = Value> {\n initialValue?: InitialValue;\n defaultValue?: Value | string;\n formatter?: (v: Value) => Value;\n onChange?: (event: Event, value: Value) => void;\n}\n\nexport function useValue<Value = string, InitialValue = Value>({\n initialValue,\n onChange,\n defaultValue = '',\n formatter = (v: Value) => v as unknown as Value,\n}: UseValueProps<Value, InitialValue>) {\n const [value, setValue] = useState<Value>(formatter((initialValue || defaultValue) as Value));\n\n useEffect(() => {\n // Use ?? operator to fallback to defaultValue when initialValue is undefined/null\n // This ensures the component resets properly when controlled value becomes undefined\n setValue(formatter((initialValue ?? defaultValue) as Value));\n }, [initialValue]);\n\n function setNewValue(newValue: Value, event?: Event) {\n newValue = formatter(newValue);\n setValue(newValue);\n if (onChange) onChange(event ?? new Event('change'), newValue);\n }\n\n function resetValue() {\n setValue(defaultValue as Value);\n }\n\n return {\n value,\n setValue: setNewValue,\n resetValue,\n };\n}\n"],"mappings":";;AASA,SAAgB,EAA+C,EAC7D,iBACA,aACA,kBAAe,IACf,gBAAa,MAAa,KACW;CACrC,IAAM,CAAC,GAAO,KAAY,EAAgB,EAAW,KAAgB,EAAuB,CAAC;AAE7F,SAAgB;AAGd,IAAS,EAAW,KAAgB,EAAuB,CAAC;IAC3D,CAAC,EAAa,CAAC;CAElB,SAAS,EAAY,GAAiB,GAAe;AAGnD,EAFA,IAAW,EAAU,EAAS,EAC9B,EAAS,EAAS,EACd,KAAU,EAAS,KAAS,IAAI,MAAM,SAAS,EAAE,EAAS;;CAGhE,SAAS,IAAa;AACpB,IAAS,EAAsB;;AAGjC,QAAO;EACL;EACA,UAAU;EACV;EACD"}
|