@arkyn/components 3.0.8 → 3.0.9

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.
Files changed (86) hide show
  1. package/dist/components/calendar/calendarTableTd/index.d.ts.map +1 -1
  2. package/dist/components/currencyInput/index.d.ts +1 -1
  3. package/dist/components/datePicker/datePickerCalendarContainer/index.d.ts +1 -0
  4. package/dist/components/datePicker/datePickerCalendarContainer/index.d.ts.map +1 -1
  5. package/dist/components/datePicker/datePickerContainer/index.d.ts +5 -1
  6. package/dist/components/datePicker/datePickerContainer/index.d.ts.map +1 -1
  7. package/dist/components/datePicker/index.d.ts.map +1 -1
  8. package/dist/components/drawer/drawerContainer/index.d.ts.map +1 -1
  9. package/dist/components/imageUpload/index.d.ts +1 -1
  10. package/dist/components/input/index.d.ts +1 -1
  11. package/dist/components/modal/modalContainer/index.d.ts.map +1 -1
  12. package/dist/components/multiSelect/index.d.ts +1 -1
  13. package/dist/components/multiSelect/index.d.ts.map +1 -1
  14. package/dist/components/multiSelect/multiSelectContainer/index.d.ts +6 -1
  15. package/dist/components/multiSelect/multiSelectContainer/index.d.ts.map +1 -1
  16. package/dist/components/multiSelect/multiSelectOption/index.d.ts +2 -0
  17. package/dist/components/multiSelect/multiSelectOption/index.d.ts.map +1 -1
  18. package/dist/components/multiSelect/multiSelectOptionsContainer/index.d.ts +1 -0
  19. package/dist/components/multiSelect/multiSelectOptionsContainer/index.d.ts.map +1 -1
  20. package/dist/components/popover/index.d.ts.map +1 -1
  21. package/dist/components/richText/index.d.ts +1 -1
  22. package/dist/components/select/index.d.ts +1 -1
  23. package/dist/components/select/index.d.ts.map +1 -1
  24. package/dist/components/select/selectContainer/index.d.ts +6 -1
  25. package/dist/components/select/selectContainer/index.d.ts.map +1 -1
  26. package/dist/components/select/selectOption/index.d.ts +2 -0
  27. package/dist/components/select/selectOption/index.d.ts.map +1 -1
  28. package/dist/components/select/selectOptionsContainer/index.d.ts +1 -0
  29. package/dist/components/select/selectOptionsContainer/index.d.ts.map +1 -1
  30. package/dist/hooks/useEscapeKey.d.ts +24 -0
  31. package/dist/hooks/useEscapeKey.d.ts.map +1 -0
  32. package/dist/hooks/useFocusTrap.d.ts +28 -0
  33. package/dist/hooks/useFocusTrap.d.ts.map +1 -0
  34. package/dist/index.js +948 -736
  35. package/dist/index.js.map +1 -1
  36. package/dist/modules/components/calendar/calendarTableTd/index.js +7 -2
  37. package/dist/modules/components/calendar/calendarTableTd/index.js.map +1 -1
  38. package/dist/modules/components/calendar/calendarTableTd/styles.css +1 -1
  39. package/dist/modules/components/calendar/styles.css +2 -2
  40. package/dist/modules/components/currencyInput/index.js.map +1 -1
  41. package/dist/modules/components/datePicker/datePickerCalendarContainer/index.js +12 -9
  42. package/dist/modules/components/datePicker/datePickerCalendarContainer/index.js.map +1 -1
  43. package/dist/modules/components/datePicker/datePickerContainer/index.js +9 -2
  44. package/dist/modules/components/datePicker/datePickerContainer/index.js.map +1 -1
  45. package/dist/modules/components/datePicker/index.js +63 -44
  46. package/dist/modules/components/datePicker/index.js.map +1 -1
  47. package/dist/modules/components/datePicker/styles.css +4 -4
  48. package/dist/modules/components/drawer/drawerContainer/index.js +31 -23
  49. package/dist/modules/components/drawer/drawerContainer/index.js.map +1 -1
  50. package/dist/modules/components/facebookPixel/pixel.js +1 -1
  51. package/dist/modules/components/facebookPixel/pixel.js.map +1 -1
  52. package/dist/modules/components/imageUpload/index.js.map +1 -1
  53. package/dist/modules/components/input/index.js.map +1 -1
  54. package/dist/modules/components/modal/modalContainer/index.js +30 -22
  55. package/dist/modules/components/modal/modalContainer/index.js.map +1 -1
  56. package/dist/modules/components/multiSelect/index.js +119 -79
  57. package/dist/modules/components/multiSelect/index.js.map +1 -1
  58. package/dist/modules/components/multiSelect/multiSelectContainer/index.js +10 -2
  59. package/dist/modules/components/multiSelect/multiSelectContainer/index.js.map +1 -1
  60. package/dist/modules/components/multiSelect/multiSelectOption/index.js +7 -3
  61. package/dist/modules/components/multiSelect/multiSelectOption/index.js.map +1 -1
  62. package/dist/modules/components/multiSelect/multiSelectOption/styles.css +1 -1
  63. package/dist/modules/components/multiSelect/multiSelectOptionsContainer/index.js +18 -15
  64. package/dist/modules/components/multiSelect/multiSelectOptionsContainer/index.js.map +1 -1
  65. package/dist/modules/components/multiSelect/styles.css +1 -1
  66. package/dist/modules/components/popover/index.js +23 -17
  67. package/dist/modules/components/popover/index.js.map +1 -1
  68. package/dist/modules/components/richText/index.js.map +1 -1
  69. package/dist/modules/components/searchPlaces.js +1 -1
  70. package/dist/modules/components/searchPlaces.js.map +1 -1
  71. package/dist/modules/components/select/index.js +120 -80
  72. package/dist/modules/components/select/index.js.map +1 -1
  73. package/dist/modules/components/select/selectContainer/index.js +10 -2
  74. package/dist/modules/components/select/selectContainer/index.js.map +1 -1
  75. package/dist/modules/components/select/selectOption/index.js +5 -2
  76. package/dist/modules/components/select/selectOption/index.js.map +1 -1
  77. package/dist/modules/components/select/selectOption/styles.css +1 -1
  78. package/dist/modules/components/select/selectOptionsContainer/index.js +17 -15
  79. package/dist/modules/components/select/selectOptionsContainer/index.js.map +1 -1
  80. package/dist/modules/components/select/styles.css +1 -1
  81. package/dist/modules/hooks/useEscapeKey.js +18 -0
  82. package/dist/modules/hooks/useEscapeKey.js.map +1 -0
  83. package/dist/modules/hooks/useFocusTrap.js +44 -0
  84. package/dist/modules/hooks/useFocusTrap.js.map +1 -0
  85. package/dist/style.css +1 -1
  86. package/package.json +8 -8
@@ -1,39 +1,47 @@
1
1
  import { useScrollLock as e } from "../../../hooks/useScrollLock.js";
2
- import { DrawerProvider as t } from "../drawerContext.js";
2
+ import { useEscapeKey as t } from "../../../hooks/useEscapeKey.js";
3
+ import { useFocusTrap as n } from "../../../hooks/useFocusTrap.js";
4
+ import { DrawerProvider as r } from "../drawerContext.js";
3
5
  /* empty css */
4
- import { useEffect as n, useState as r } from "react";
5
- import { jsx as i, jsxs as a } from "react/jsx-runtime";
6
+ import { useEffect as i, useRef as a, useState as o } from "react";
7
+ import { jsx as s, jsxs as c } from "react/jsx-runtime";
6
8
  //#region src/components/drawer/drawerContainer/index.tsx
7
- function o(o) {
8
- let { isVisible: s, makeInvisible: c, orientation: l = "left", children: u, className: d, ...f } = o, [p, m] = r(s), [h, g] = r(!1);
9
- n(() => {
10
- s ? (m(!0), g(!1)) : p && g(!0);
11
- }, [s, p]), e(s);
12
- function _(e) {
13
- e.target === e.currentTarget && h && (g(!1), m(!1), c());
9
+ function l(l) {
10
+ let { isVisible: u, makeInvisible: d, orientation: f = "left", children: p, className: m, ...h } = l, [g, _] = o(u), [v, y] = o(!1), b = a(null);
11
+ i(() => {
12
+ u ? (_(!0), y(!1)) : g && y(!0);
13
+ }, [u, g]), e(u);
14
+ let x = g && !v;
15
+ t(x, () => y(!0)), n(x, b);
16
+ function S(e) {
17
+ e.target === e.currentTarget && v && (y(!1), _(!1), d());
14
18
  }
15
- return p ? /* @__PURE__ */ i(t, {
16
- makeInvisible: () => g(!0),
17
- children: /* @__PURE__ */ a("aside", {
19
+ return g ? /* @__PURE__ */ s(r, {
20
+ makeInvisible: () => y(!0),
21
+ children: /* @__PURE__ */ c("aside", {
18
22
  className: [
19
23
  "arkynDrawerContainer",
20
- l,
21
- h ? "exiting" : "",
22
- d
24
+ f,
25
+ v ? "exiting" : "",
26
+ m
23
27
  ].filter(Boolean).join(" "),
24
- ...f,
25
- children: [/* @__PURE__ */ i("div", {
28
+ ...h,
29
+ children: [/* @__PURE__ */ s("div", {
26
30
  className: "arkynDrawerContainerOverlay",
27
- onClick: () => g(!0),
28
- onAnimationEnd: _
29
- }), /* @__PURE__ */ i("div", {
31
+ onClick: () => y(!0),
32
+ onAnimationEnd: S
33
+ }), /* @__PURE__ */ s("div", {
34
+ ref: b,
35
+ role: "dialog",
36
+ "aria-modal": "true",
37
+ tabIndex: -1,
30
38
  className: "arkynDrawerContainerContent",
31
- children: u
39
+ children: p
32
40
  })]
33
41
  })
34
42
  }) : null;
35
43
  }
36
44
  //#endregion
37
- export { o as DrawerContainer };
45
+ export { l as DrawerContainer };
38
46
 
39
47
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../../../src/components/drawer/drawerContainer/index.tsx"],"sourcesContent":["import {\n\ttype AnimationEvent,\n\ttype HTMLAttributes,\n\tuseEffect,\n\tuseState,\n} from \"react\";\n\nimport { useScrollLock } from \"../../../hooks/useScrollLock\";\nimport { DrawerProvider } from \"../drawerContext\";\nimport \"./styles.css\";\n\ntype DrawerContainerProps = HTMLAttributes<HTMLElement> & {\n\t/** Controls whether the drawer is visible. */\n\tisVisible: boolean;\n\t/** Callback invoked when the overlay is clicked to close the drawer. */\n\tmakeInvisible: () => void;\n\t/** Side from which the drawer slides in. @default \"left\" */\n\torientation?: \"left\" | \"right\";\n};\n\n/**\n * DrawerContainer, animated slide-in panel rendered over an overlay backdrop.\n *\n * Locks body scroll while open. Closes when the overlay is clicked.\n * Provides context consumed by `DrawerHeader` (close button).\n *\n * @param props.isVisible - Whether the drawer is open. Required.\n * @param props.makeInvisible - Called when the overlay or close button is clicked. Required.\n * @param props.orientation - Slide direction. Default: `\"left\"`\n *\n * **...Other valid HTML `<aside>` properties**\n *\n * @returns DrawerContainer JSX element.\n *\n * @example\n * ```tsx\n * const [isOpen, setIsOpen] = useState(false);\n *\n * <DrawerContainer isVisible={isOpen} makeInvisible={() => setIsOpen(false)} orientation=\"right\">\n * <DrawerHeader><h2>Navigation</h2></DrawerHeader>\n * <nav>...</nav>\n * </DrawerContainer>\n * ```\n */\n\nfunction DrawerContainer(props: DrawerContainerProps) {\n\tconst {\n\t\tisVisible,\n\t\tmakeInvisible,\n\t\torientation = \"left\",\n\t\tchildren,\n\t\tclassName: baseClassName,\n\t\t...rest\n\t} = props;\n\n\tconst [mounted, setMounted] = useState(isVisible);\n\tconst [isExiting, setIsExiting] = useState(false);\n\n\tuseEffect(() => {\n\t\tif (isVisible) {\n\t\t\tsetMounted(true);\n\t\t\tsetIsExiting(false);\n\t\t} else if (mounted) {\n\t\t\tsetIsExiting(true);\n\t\t}\n\t}, [isVisible, mounted]);\n\n\tuseScrollLock(isVisible);\n\n\tfunction handleOverlayAnimationEnd(e: AnimationEvent<HTMLDivElement>) {\n\t\tif (e.target === e.currentTarget && isExiting) {\n\t\t\tsetIsExiting(false);\n\t\t\tsetMounted(false);\n\t\t\tmakeInvisible();\n\t\t}\n\t}\n\n\tif (!mounted) return null;\n\n\tconst className = [\n\t\t\"arkynDrawerContainer\",\n\t\torientation,\n\t\tisExiting ? \"exiting\" : \"\",\n\t\tbaseClassName,\n\t]\n\t\t.filter(Boolean)\n\t\t.join(\" \");\n\n\treturn (\n\t\t<DrawerProvider makeInvisible={() => setIsExiting(true)}>\n\t\t\t<aside className={className} {...rest}>\n\t\t\t\t<div\n\t\t\t\t\tclassName=\"arkynDrawerContainerOverlay\"\n\t\t\t\t\tonClick={() => setIsExiting(true)}\n\t\t\t\t\tonAnimationEnd={handleOverlayAnimationEnd}\n\t\t\t\t/>\n\t\t\t\t<div className=\"arkynDrawerContainerContent\">{children}</div>\n\t\t\t</aside>\n\t\t</DrawerProvider>\n\t);\n}\n\nexport { DrawerContainer };\n"],"mappings":";;;;;;AA6CA,SAAS,EAAgB,GAA6B;CACrD,IAAM,EACL,cACA,kBACA,iBAAc,QACd,aACA,WAAW,GACX,GAAG,MACA,GAEE,CAAC,GAAS,KAAc,EAAS,CAAS,GAC1C,CAAC,GAAW,KAAgB,EAAS,EAAK;CAWhD,AATA,QAAgB;EACf,AAAI,KACH,EAAW,EAAI,GACf,EAAa,EAAK,KACR,KACV,EAAa,EAAI;CAEnB,GAAG,CAAC,GAAW,CAAO,CAAC,GAEvB,EAAc,CAAS;CAEvB,SAAS,EAA0B,GAAmC;EACrE,AAAI,EAAE,WAAW,EAAE,iBAAiB,MACnC,EAAa,EAAK,GAClB,EAAW,EAAK,GAChB,EAAc;CAEhB;CAaA,OAXK,IAYJ,kBAAC,GAAD;EAAgB,qBAAqB,EAAa,EAAI;YACrD,kBAAC,SAAD;GAAkB,WAXF;IACjB;IACA;IACA,IAAY,YAAY;IACxB;GACD,CAAC,CACC,OAAO,OAAO,CAAC,CACf,KAAK,GAIa;GAAW,GAAI;aAAjC,CACC,kBAAC,OAAD;IACC,WAAU;IACV,eAAe,EAAa,EAAI;IAChC,gBAAgB;GAChB,CAAA,GACD,kBAAC,OAAD;IAAK,WAAU;IAA+B;GAAc,CAAA,CACtD;;CACQ,CAAA,IArBI;AAuBtB"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../../../src/components/drawer/drawerContainer/index.tsx"],"sourcesContent":["import {\n\ttype AnimationEvent,\n\ttype HTMLAttributes,\n\tuseEffect,\n\tuseRef,\n\tuseState,\n} from \"react\";\n\nimport { useEscapeKey } from \"../../../hooks/useEscapeKey\";\nimport { useFocusTrap } from \"../../../hooks/useFocusTrap\";\nimport { useScrollLock } from \"../../../hooks/useScrollLock\";\nimport { DrawerProvider } from \"../drawerContext\";\nimport \"./styles.css\";\n\ntype DrawerContainerProps = HTMLAttributes<HTMLElement> & {\n\t/** Controls whether the drawer is visible. */\n\tisVisible: boolean;\n\t/** Callback invoked when the overlay is clicked to close the drawer. */\n\tmakeInvisible: () => void;\n\t/** Side from which the drawer slides in. @default \"left\" */\n\torientation?: \"left\" | \"right\";\n};\n\n/**\n * DrawerContainer, animated slide-in panel rendered over an overlay backdrop.\n *\n * Locks body scroll while open. Closes when the overlay is clicked.\n * Provides context consumed by `DrawerHeader` (close button).\n *\n * @param props.isVisible - Whether the drawer is open. Required.\n * @param props.makeInvisible - Called when the overlay or close button is clicked. Required.\n * @param props.orientation - Slide direction. Default: `\"left\"`\n *\n * **...Other valid HTML `<aside>` properties**\n *\n * @returns DrawerContainer JSX element.\n *\n * @example\n * ```tsx\n * const [isOpen, setIsOpen] = useState(false);\n *\n * <DrawerContainer isVisible={isOpen} makeInvisible={() => setIsOpen(false)} orientation=\"right\">\n * <DrawerHeader><h2>Navigation</h2></DrawerHeader>\n * <nav>...</nav>\n * </DrawerContainer>\n * ```\n */\n\nfunction DrawerContainer(props: DrawerContainerProps) {\n\tconst {\n\t\tisVisible,\n\t\tmakeInvisible,\n\t\torientation = \"left\",\n\t\tchildren,\n\t\tclassName: baseClassName,\n\t\t...rest\n\t} = props;\n\n\tconst [mounted, setMounted] = useState(isVisible);\n\tconst [isExiting, setIsExiting] = useState(false);\n\tconst contentRef = useRef<HTMLDivElement>(null);\n\n\tuseEffect(() => {\n\t\tif (isVisible) {\n\t\t\tsetMounted(true);\n\t\t\tsetIsExiting(false);\n\t\t} else if (mounted) {\n\t\t\tsetIsExiting(true);\n\t\t}\n\t}, [isVisible, mounted]);\n\n\tuseScrollLock(isVisible);\n\n\tconst isDialogActive = mounted && !isExiting;\n\tuseEscapeKey(isDialogActive, () => setIsExiting(true));\n\tuseFocusTrap(isDialogActive, contentRef);\n\n\tfunction handleOverlayAnimationEnd(e: AnimationEvent<HTMLDivElement>) {\n\t\tif (e.target === e.currentTarget && isExiting) {\n\t\t\tsetIsExiting(false);\n\t\t\tsetMounted(false);\n\t\t\tmakeInvisible();\n\t\t}\n\t}\n\n\tif (!mounted) return null;\n\n\tconst className = [\n\t\t\"arkynDrawerContainer\",\n\t\torientation,\n\t\tisExiting ? \"exiting\" : \"\",\n\t\tbaseClassName,\n\t]\n\t\t.filter(Boolean)\n\t\t.join(\" \");\n\n\treturn (\n\t\t<DrawerProvider makeInvisible={() => setIsExiting(true)}>\n\t\t\t<aside className={className} {...rest}>\n\t\t\t\t<div\n\t\t\t\t\tclassName=\"arkynDrawerContainerOverlay\"\n\t\t\t\t\tonClick={() => setIsExiting(true)}\n\t\t\t\t\tonAnimationEnd={handleOverlayAnimationEnd}\n\t\t\t\t/>\n\t\t\t\t<div\n\t\t\t\t\tref={contentRef}\n\t\t\t\t\trole=\"dialog\"\n\t\t\t\t\taria-modal=\"true\"\n\t\t\t\t\ttabIndex={-1}\n\t\t\t\t\tclassName=\"arkynDrawerContainerContent\"\n\t\t\t\t>\n\t\t\t\t\t{children}\n\t\t\t\t</div>\n\t\t\t</aside>\n\t\t</DrawerProvider>\n\t);\n}\n\nexport { DrawerContainer };\n"],"mappings":";;;;;;;;AAgDA,SAAS,EAAgB,GAA6B;CACrD,IAAM,EACL,cACA,kBACA,iBAAc,QACd,aACA,WAAW,GACX,GAAG,MACA,GAEE,CAAC,GAAS,KAAc,EAAS,CAAS,GAC1C,CAAC,GAAW,KAAgB,EAAS,EAAK,GAC1C,IAAa,EAAuB,IAAI;CAW9C,AATA,QAAgB;EACf,AAAI,KACH,EAAW,EAAI,GACf,EAAa,EAAK,KACR,KACV,EAAa,EAAI;CAEnB,GAAG,CAAC,GAAW,CAAO,CAAC,GAEvB,EAAc,CAAS;CAEvB,IAAM,IAAiB,KAAW,CAAC;CAEnC,AADA,EAAa,SAAsB,EAAa,EAAI,CAAC,GACrD,EAAa,GAAgB,CAAU;CAEvC,SAAS,EAA0B,GAAmC;EACrE,AAAI,EAAE,WAAW,EAAE,iBAAiB,MACnC,EAAa,EAAK,GAClB,EAAW,EAAK,GAChB,EAAc;CAEhB;CAaA,OAXK,IAYJ,kBAAC,GAAD;EAAgB,qBAAqB,EAAa,EAAI;YACrD,kBAAC,SAAD;GAAkB,WAXF;IACjB;IACA;IACA,IAAY,YAAY;IACxB;GACD,CAAC,CACC,OAAO,OAAO,CAAC,CACf,KAAK,GAIa;GAAW,GAAI;aAAjC,CACC,kBAAC,OAAD;IACC,WAAU;IACV,eAAe,EAAa,EAAI;IAChC,gBAAgB;GAChB,CAAA,GACD,kBAAC,OAAD;IACC,KAAK;IACL,MAAK;IACL,cAAW;IACX,UAAU;IACV,WAAU;IAET;GACG,CAAA,CACC;;CACQ,CAAA,IA7BI;AA+BtB"}
@@ -4,7 +4,7 @@ var e = class {
4
4
  autoConfig;
5
5
  initialized;
6
6
  constructor(e, t) {
7
- this.pixelId = e, this.autoConfig = t?.autoConfig || !0, this.initialized = !1;
7
+ this.pixelId = e, this.autoConfig = t?.autoConfig ?? !0, this.initialized = !1;
8
8
  }
9
9
  loadFacebookPixel() {
10
10
  if (window.fbq) return;
@@ -1 +1 @@
1
- {"version":3,"file":"pixel.js","names":[],"sources":["../../../../src/components/facebookPixel/pixel.ts"],"sourcesContent":["import type { Fbq } from \"../../types/defineType\";\n\ntype Options = {\n\tautoConfig?: boolean;\n\tdebug?: boolean;\n};\n\nclass FacebookPixel {\n\tpixelId: string;\n\tautoConfig: boolean;\n\tinitialized: boolean;\n\n\tconstructor(pixelId: string, options?: Options) {\n\t\tthis.pixelId = pixelId;\n\t\tthis.autoConfig = options?.autoConfig || true;\n\t\tthis.initialized = false;\n\t}\n\n\tprivate loadFacebookPixel() {\n\t\t// Verifica se o objeto fbq já está definido no objeto window\n\t\tif (window.fbq) return;\n\n\t\t// Define a função fbq que será usada para enviar eventos ao Facebook Pixel\n\t\t// biome-ignore lint/suspicious/noExplicitAny: intentional\n\t\tconst fbq: Fbq = ((...args: any[]) => {\n\t\t\t// Se fbq.callMethod estiver definido, chama o método com os argumentos fornecidos\n\t\t\t// Caso contrário, adiciona os argumentos à fila de eventos\n\t\t\tfbq.callMethod ? fbq.callMethod.apply(fbq, args) : fbq.queue.push(args);\n\t\t}) as Fbq;\n\n\t\t// Se o objeto _fbq não estiver definido no objeto window, define-o como fbq\n\t\tif (!window._fbq) window._fbq = fbq;\n\n\t\t// Define propriedades e métodos adicionais para fbq\n\t\tfbq.push = fbq;\n\t\tfbq.loaded = true;\n\t\tfbq.version = \"2.0\";\n\t\tfbq.queue = [];\n\n\t\t// Cria um elemento script e define o atributo src como o URL do script do Facebook Pixel\n\t\tconst script = document.createElement(\"script\");\n\t\tscript.async = true;\n\t\tscript.src = \"https://connect.facebook.net/en_US/fbevents.js\";\n\n\t\t// Busca o primeiro elemento script no documento\n\t\tconst firstScript = document.getElementsByTagName(\"script\")[0];\n\n\t\t// Estoura uma exceção se não houver nenhum elemento script no documento\n\t\tif (!firstScript.parentNode) {\n\t\t\tthrow new Error(\"No script tag found in the document\");\n\t\t}\n\n\t\t// Insere o elemento script no início do documento\n\t\tfirstScript.parentNode.insertBefore(script, firstScript);\n\t\twindow.fbq = fbq;\n\t}\n\n\tinit(advancedMatching: object = {}) {\n\t\t// Verifica se o pixel já foi inicializado\n\t\tthis.initialized = typeof window !== \"undefined\" && !!window.fbq;\n\n\t\t// Carrega o Facebook Pixel\n\t\tthis.loadFacebookPixel();\n\n\t\t// Estoura uma exceção se o fbq não estiver definido\n\t\tif (!window.fbq) {\n\t\t\tthrow new Error(\"window.fbq is not defined\");\n\t\t}\n\n\t\t// Inicializa o pixel com o ID fornecido\n\t\tif (this.autoConfig === false) {\n\t\t\twindow.fbq(\"set\", \"autoConfig\", false, this.pixelId);\n\t\t} else {\n\t\t\twindow.fbq(\"init\", this.pixelId, advancedMatching);\n\t\t}\n\n\t\t// Marca o pixel como inicializado\n\t\tthis.initialized = true;\n\t}\n\n\tpageView() {\n\t\tif (!this.initialized) return;\n\t\tif (!window.fbq) return;\n\n\t\twindow.fbq(\"track\", \"PageView\");\n\t}\n\n\ttrack(title: string, data?: object) {\n\t\tif (!this.initialized) return;\n\t\tif (!window.fbq) return;\n\n\t\twindow.fbq(\"track\", title, data);\n\t}\n\n\ttrackSingle(pixel: string, title: string, data?: object) {\n\t\tif (!this.initialized) return;\n\t\tif (!window.fbq) return;\n\n\t\twindow.fbq(\"trackSingle\", pixel, title, data);\n\t}\n\n\ttrackCustom(event: string, data?: object) {\n\t\tif (!this.initialized) return;\n\t\tif (!window.fbq) return;\n\n\t\twindow.fbq(\"trackCustom\", event, data);\n\t}\n\n\ttrackSingleCustom(pixel: string, event: string, data?: object) {\n\t\tif (!this.initialized) return;\n\t\tif (!window.fbq) return;\n\n\t\twindow.fbq(\"trackSingle\", pixel, event, data);\n\t}\n\n\tgrantConsent() {\n\t\tif (!this.initialized) return;\n\t\tif (!window.fbq) return;\n\n\t\twindow.fbq(\"consent\", \"grant\");\n\t}\n\n\trevokeConsent() {\n\t\tif (!this.initialized) return;\n\t\tif (!window.fbq) return;\n\n\t\twindow.fbq(\"consent\", \"revoke\");\n\t}\n}\n\nexport { FacebookPixel };\n"],"mappings":";AAOA,IAAM,IAAN,MAAoB;CACnB;CACA;CACA;CAEA,YAAY,GAAiB,GAAmB;EAG/C,AAFA,KAAK,UAAU,GACf,KAAK,aAAa,GAAS,cAAc,IACzC,KAAK,cAAc;CACpB;CAEA,oBAA4B;EAE3B,IAAI,OAAO,KAAK;EAIhB,IAAM,MAAa,GAAG,MAAgB;GAGrC,EAAI,aAAa,EAAI,WAAW,MAAM,GAAK,CAAI,IAAI,EAAI,MAAM,KAAK,CAAI;EACvE;EASA,AANK,OAAO,SAAM,OAAO,OAAO,IAGhC,EAAI,OAAO,GACX,EAAI,SAAS,IACb,EAAI,UAAU,OACd,EAAI,QAAQ,CAAC;EAGb,IAAM,IAAS,SAAS,cAAc,QAAQ;EAE9C,AADA,EAAO,QAAQ,IACf,EAAO,MAAM;EAGb,IAAM,IAAc,SAAS,qBAAqB,QAAQ,CAAC,CAAC;EAG5D,IAAI,CAAC,EAAY,YAChB,MAAU,MAAM,qCAAqC;EAKtD,AADA,EAAY,WAAW,aAAa,GAAQ,CAAW,GACvD,OAAO,MAAM;CACd;CAEA,KAAK,IAA2B,CAAC,GAAG;EAQnC,IANA,KAAK,cAAc,OAAO,SAAW,OAAe,CAAC,CAAC,OAAO,KAG7D,KAAK,kBAAkB,GAGnB,CAAC,OAAO,KACX,MAAU,MAAM,2BAA2B;EAW5C,AAPI,KAAK,eAAe,KACvB,OAAO,IAAI,OAAO,cAAc,IAAO,KAAK,OAAO,IAEnD,OAAO,IAAI,QAAQ,KAAK,SAAS,CAAgB,GAIlD,KAAK,cAAc;CACpB;CAEA,WAAW;EACL,KAAK,eACL,OAAO,OAEZ,OAAO,IAAI,SAAS,UAAU;CAC/B;CAEA,MAAM,GAAe,GAAe;EAC9B,KAAK,eACL,OAAO,OAEZ,OAAO,IAAI,SAAS,GAAO,CAAI;CAChC;CAEA,YAAY,GAAe,GAAe,GAAe;EACnD,KAAK,eACL,OAAO,OAEZ,OAAO,IAAI,eAAe,GAAO,GAAO,CAAI;CAC7C;CAEA,YAAY,GAAe,GAAe;EACpC,KAAK,eACL,OAAO,OAEZ,OAAO,IAAI,eAAe,GAAO,CAAI;CACtC;CAEA,kBAAkB,GAAe,GAAe,GAAe;EACzD,KAAK,eACL,OAAO,OAEZ,OAAO,IAAI,eAAe,GAAO,GAAO,CAAI;CAC7C;CAEA,eAAe;EACT,KAAK,eACL,OAAO,OAEZ,OAAO,IAAI,WAAW,OAAO;CAC9B;CAEA,gBAAgB;EACV,KAAK,eACL,OAAO,OAEZ,OAAO,IAAI,WAAW,QAAQ;CAC/B;AACD"}
1
+ {"version":3,"file":"pixel.js","names":[],"sources":["../../../../src/components/facebookPixel/pixel.ts"],"sourcesContent":["import type { Fbq } from \"../../types/defineType\";\n\ntype Options = {\n\tautoConfig?: boolean;\n\tdebug?: boolean;\n};\n\nclass FacebookPixel {\n\tpixelId: string;\n\tautoConfig: boolean;\n\tinitialized: boolean;\n\n\tconstructor(pixelId: string, options?: Options) {\n\t\tthis.pixelId = pixelId;\n\t\tthis.autoConfig = options?.autoConfig ?? true;\n\t\tthis.initialized = false;\n\t}\n\n\tprivate loadFacebookPixel() {\n\t\t// Verifica se o objeto fbq já está definido no objeto window\n\t\tif (window.fbq) return;\n\n\t\t// Define a função fbq que será usada para enviar eventos ao Facebook Pixel\n\t\t// biome-ignore lint/suspicious/noExplicitAny: intentional\n\t\tconst fbq: Fbq = ((...args: any[]) => {\n\t\t\t// Se fbq.callMethod estiver definido, chama o método com os argumentos fornecidos\n\t\t\t// Caso contrário, adiciona os argumentos à fila de eventos\n\t\t\tfbq.callMethod ? fbq.callMethod.apply(fbq, args) : fbq.queue.push(args);\n\t\t}) as Fbq;\n\n\t\t// Se o objeto _fbq não estiver definido no objeto window, define-o como fbq\n\t\tif (!window._fbq) window._fbq = fbq;\n\n\t\t// Define propriedades e métodos adicionais para fbq\n\t\tfbq.push = fbq;\n\t\tfbq.loaded = true;\n\t\tfbq.version = \"2.0\";\n\t\tfbq.queue = [];\n\n\t\t// Cria um elemento script e define o atributo src como o URL do script do Facebook Pixel\n\t\tconst script = document.createElement(\"script\");\n\t\tscript.async = true;\n\t\tscript.src = \"https://connect.facebook.net/en_US/fbevents.js\";\n\n\t\t// Busca o primeiro elemento script no documento\n\t\tconst firstScript = document.getElementsByTagName(\"script\")[0];\n\n\t\t// Estoura uma exceção se não houver nenhum elemento script no documento\n\t\tif (!firstScript.parentNode) {\n\t\t\tthrow new Error(\"No script tag found in the document\");\n\t\t}\n\n\t\t// Insere o elemento script no início do documento\n\t\tfirstScript.parentNode.insertBefore(script, firstScript);\n\t\twindow.fbq = fbq;\n\t}\n\n\tinit(advancedMatching: object = {}) {\n\t\t// Verifica se o pixel já foi inicializado\n\t\tthis.initialized = typeof window !== \"undefined\" && !!window.fbq;\n\n\t\t// Carrega o Facebook Pixel\n\t\tthis.loadFacebookPixel();\n\n\t\t// Estoura uma exceção se o fbq não estiver definido\n\t\tif (!window.fbq) {\n\t\t\tthrow new Error(\"window.fbq is not defined\");\n\t\t}\n\n\t\t// Inicializa o pixel com o ID fornecido\n\t\tif (this.autoConfig === false) {\n\t\t\twindow.fbq(\"set\", \"autoConfig\", false, this.pixelId);\n\t\t} else {\n\t\t\twindow.fbq(\"init\", this.pixelId, advancedMatching);\n\t\t}\n\n\t\t// Marca o pixel como inicializado\n\t\tthis.initialized = true;\n\t}\n\n\tpageView() {\n\t\tif (!this.initialized) return;\n\t\tif (!window.fbq) return;\n\n\t\twindow.fbq(\"track\", \"PageView\");\n\t}\n\n\ttrack(title: string, data?: object) {\n\t\tif (!this.initialized) return;\n\t\tif (!window.fbq) return;\n\n\t\twindow.fbq(\"track\", title, data);\n\t}\n\n\ttrackSingle(pixel: string, title: string, data?: object) {\n\t\tif (!this.initialized) return;\n\t\tif (!window.fbq) return;\n\n\t\twindow.fbq(\"trackSingle\", pixel, title, data);\n\t}\n\n\ttrackCustom(event: string, data?: object) {\n\t\tif (!this.initialized) return;\n\t\tif (!window.fbq) return;\n\n\t\twindow.fbq(\"trackCustom\", event, data);\n\t}\n\n\ttrackSingleCustom(pixel: string, event: string, data?: object) {\n\t\tif (!this.initialized) return;\n\t\tif (!window.fbq) return;\n\n\t\twindow.fbq(\"trackSingle\", pixel, event, data);\n\t}\n\n\tgrantConsent() {\n\t\tif (!this.initialized) return;\n\t\tif (!window.fbq) return;\n\n\t\twindow.fbq(\"consent\", \"grant\");\n\t}\n\n\trevokeConsent() {\n\t\tif (!this.initialized) return;\n\t\tif (!window.fbq) return;\n\n\t\twindow.fbq(\"consent\", \"revoke\");\n\t}\n}\n\nexport { FacebookPixel };\n"],"mappings":";AAOA,IAAM,IAAN,MAAoB;CACnB;CACA;CACA;CAEA,YAAY,GAAiB,GAAmB;EAG/C,AAFA,KAAK,UAAU,GACf,KAAK,aAAa,GAAS,cAAc,IACzC,KAAK,cAAc;CACpB;CAEA,oBAA4B;EAE3B,IAAI,OAAO,KAAK;EAIhB,IAAM,MAAa,GAAG,MAAgB;GAGrC,EAAI,aAAa,EAAI,WAAW,MAAM,GAAK,CAAI,IAAI,EAAI,MAAM,KAAK,CAAI;EACvE;EASA,AANK,OAAO,SAAM,OAAO,OAAO,IAGhC,EAAI,OAAO,GACX,EAAI,SAAS,IACb,EAAI,UAAU,OACd,EAAI,QAAQ,CAAC;EAGb,IAAM,IAAS,SAAS,cAAc,QAAQ;EAE9C,AADA,EAAO,QAAQ,IACf,EAAO,MAAM;EAGb,IAAM,IAAc,SAAS,qBAAqB,QAAQ,CAAC,CAAC;EAG5D,IAAI,CAAC,EAAY,YAChB,MAAU,MAAM,qCAAqC;EAKtD,AADA,EAAY,WAAW,aAAa,GAAQ,CAAW,GACvD,OAAO,MAAM;CACd;CAEA,KAAK,IAA2B,CAAC,GAAG;EAQnC,IANA,KAAK,cAAc,OAAO,SAAW,OAAe,CAAC,CAAC,OAAO,KAG7D,KAAK,kBAAkB,GAGnB,CAAC,OAAO,KACX,MAAU,MAAM,2BAA2B;EAW5C,AAPI,KAAK,eAAe,KACvB,OAAO,IAAI,OAAO,cAAc,IAAO,KAAK,OAAO,IAEnD,OAAO,IAAI,QAAQ,KAAK,SAAS,CAAgB,GAIlD,KAAK,cAAc;CACpB;CAEA,WAAW;EACL,KAAK,eACL,OAAO,OAEZ,OAAO,IAAI,SAAS,UAAU;CAC/B;CAEA,MAAM,GAAe,GAAe;EAC9B,KAAK,eACL,OAAO,OAEZ,OAAO,IAAI,SAAS,GAAO,CAAI;CAChC;CAEA,YAAY,GAAe,GAAe,GAAe;EACnD,KAAK,eACL,OAAO,OAEZ,OAAO,IAAI,eAAe,GAAO,GAAO,CAAI;CAC7C;CAEA,YAAY,GAAe,GAAe;EACpC,KAAK,eACL,OAAO,OAEZ,OAAO,IAAI,eAAe,GAAO,CAAI;CACtC;CAEA,kBAAkB,GAAe,GAAe,GAAe;EACzD,KAAK,eACL,OAAO,OAEZ,OAAO,IAAI,eAAe,GAAO,GAAO,CAAI;CAC7C;CAEA,eAAe;EACT,KAAK,eACL,OAAO,OAEZ,OAAO,IAAI,WAAW,OAAO;CAC9B;CAEA,gBAAgB;EACV,KAAK,eACL,OAAO,OAEZ,OAAO,IAAI,WAAW,QAAQ;CAC/B;AACD"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../../src/components/imageUpload/index.tsx"],"sourcesContent":["import { useState } from \"react\";\n\nimport { useForm } from \"../../hooks/useForm\";\nimport { FieldTemplate } from \"../../services/fieldTemplate\";\n\nimport { HasFileContent } from \"./hasFileContent\";\nimport { NoFileContent } from \"./noFileContent\";\nimport \"./styles.css\";\n\ntype ImageUploadProps = {\n\t/** Field name for form submission (stores the uploaded image URL). Required. */\n\tname: string;\n\t/** Server endpoint URL that receives the `multipart/form-data` upload request. Required. */\n\taction: string;\n\t/** Pre-populated image URL displayed as a preview (e.g. an existing avatar). @default \"\" */\n\tdefaultValue?: string | null;\n\t/** Additional CSS class applied to the wrapper element. */\n\tclassName?: string;\n\t/** Disables file selection and upload. @default false */\n\tdisabled?: boolean;\n\t/** Optional label text displayed above the upload area. */\n\tlabel?: string;\n\t/** Displays an asterisk on the label to signal a required field. @default false */\n\tshowAsterisk?: boolean;\n\t/** Label for the file-picker button after an image is selected. @default \"Alterar imagem\" */\n\tchangeImageButtonText?: string;\n\t/** Label for the file-picker button before an image is selected. @default \"Selecionar imagem\" */\n\tselectImageButtonText?: string;\n\t/** Text displayed in the drag-and-drop zone. @default \"Ou arraste e solte a imagem aqui\" */\n\tdropImageText?: string;\n\t/** HTTP method for the upload request. @default \"POST\" */\n\tmethod?: string;\n\t/** Form-data field name used for the file. @default \"file\" */\n\tfileName?: string;\n\t/** Property name in the server response that contains the image URL. @default \"url\" */\n\tfileResponseName?: string;\n\t/** Accepted image MIME types or extensions (e.g. `\"image/jpeg,image/png\"`). @default \"image/*\" */\n\tacceptImage?: string;\n\t/** Callback fired after a successful upload. Receives the image URL returned by the server. */\n\tonChange?: (url: string) => void;\n\t/** When true, skips `FieldTemplate` wrapper (label and error text). @default false */\n\tunShowFieldTemplate?: boolean;\n\t/**\n\t * Layout direction forwarded to `FieldTemplate`.\n\t * @default \"horizontal\"\n\t */\n\torientation?: \"horizontal\" | \"vertical\" | \"horizontalReverse\";\n};\n\n/**\n * ImageUpload, drag-and-drop image uploader with server upload and image preview.\n *\n * Sends the file via `fetch` as `multipart/form-data` and stores the returned URL\n * in a hidden `<input>` for form submission.\n * Integrates with `useForm` to display validation errors by field name.\n *\n * @param props.name - Field name for form submission. Required.\n * @param props.action - Upload endpoint URL. Required.\n * @param props.defaultValue - Pre-populated image URL displayed as preview.\n * @param props.disabled - Disables file selection and upload. Default: false\n * @param props.label - Label text displayed above the upload area.\n * @param props.showAsterisk - Appends `*` to the label. Default: false\n * @param props.acceptImage - Accepted MIME types or extensions. Default: \"image/*\"\n * @param props.method - HTTP method. Default: \"POST\"\n * @param props.fileName - Form-data field name for the file. Default: \"file\"\n * @param props.fileResponseName - Server response property containing the URL. Default: \"url\"\n * @param props.onChange - Callback fired after a successful upload, receives the image URL.\n * @param props.orientation - Layout direction. Default: \"horizontal\"\n * @param props.unShowFieldTemplate - Skips wrapper, label, and error rendering. Default: false\n *\n * @returns ImageUpload JSX element wrapped in `FieldTemplate`.\n *\n * @example\n * ```tsx\n * // Basic\n * <ImageUpload name=\"avatar\" action=\"/api/upload/image\" />\n *\n * // Profile picture with existing image and label\n * <ImageUpload\n * name=\"profilePicture\"\n * action=\"/api/upload/avatar\"\n * label=\"Profile Picture\"\n * showAsterisk\n * defaultValue={user.avatarUrl}\n * selectImageButtonText=\"Choose photo\"\n * onChange={(url) => updateProfile({ avatarUrl: url })}\n * />\n *\n * // Restricted to JPEG/PNG\n * <ImageUpload\n * name=\"productImage\"\n * action=\"/api/upload/product\"\n * label=\"Product Image\"\n * acceptImage=\"image/jpeg,image/png\"\n * fileResponseName=\"imageUrl\"\n * />\n * ```\n */\n\nfunction ImageUpload(props: ImageUploadProps) {\n\tconst {\n\t\tname,\n\t\tdefaultValue = \"\",\n\t\tlabel,\n\t\tshowAsterisk = false,\n\t\taction,\n\t\tfileName = \"file\",\n\t\tclassName: wrapperClassName = \"\",\n\t\tmethod = \"POST\",\n\t\tacceptImage = \"image/*\",\n\t\tfileResponseName = \"url\",\n\t\tchangeImageButtonText = \"Alterar imagem\",\n\t\tselectImageButtonText = \"Selecionar imagem\",\n\t\tdropImageText = \"Ou arraste e solte a imagem aqui\",\n\t\tonChange,\n\t\tdisabled = false,\n\t\tunShowFieldTemplate = false,\n\t\torientation = \"vertical\",\n\t} = props;\n\n\tconst { fieldErrors } = useForm();\n\tconst fieldError = fieldErrors?.[name];\n\n\tconst [value, setValue] = useState(defaultValue);\n\tconst [error, setError] = useState(\"\");\n\tconst [file, setFile] = useState<File | null>(null);\n\tconst [filePath, setFilePath] = useState(defaultValue);\n\tconst [isLoading, setIsLoading] = useState(false);\n\n\tasync function handleUploadImage(file: File) {\n\t\tif (disabled) return;\n\n\t\tsetIsLoading(true);\n\t\tsetFile(file);\n\t\tsetError(\"\");\n\n\t\tconst formData = new FormData();\n\t\tformData.append(fileName, file);\n\n\t\tawait fetch(action, { method: method, body: formData })\n\t\t\t.then(async (response) => await response.json())\n\t\t\t.then((response) => {\n\t\t\t\tif (response?.error) setError(response.error);\n\t\t\t\telse setValue(response?.[fileResponseName]);\n\t\t\t\tonChange?.(response?.[fileResponseName]);\n\t\t\t})\n\t\t\t.catch((error) => {\n\t\t\t\tconsole.error(error);\n\t\t\t\tsetError(\"Erro ao enviar imagem\");\n\t\t\t})\n\t\t\t.finally(() => setIsLoading(false));\n\t}\n\n\tfunction handleSelectFile(file: File) {\n\t\tif (disabled) return;\n\n\t\tsetFilePath(URL.createObjectURL(file));\n\t\thandleUploadImage(file);\n\t}\n\n\tconst errorMessage = fieldError || error;\n\n\tconst hasErrorClassName = errorMessage ? \"hasError\" : \"noHasError\";\n\tconst hasImageClassName = filePath ? \"hasImage\" : \"noHasImage\";\n\tconst className = `arkynImageUpload ${hasErrorClassName} ${hasImageClassName}`;\n\n\treturn (\n\t\t<FieldTemplate\n\t\t\tname={name}\n\t\t\tlabel={label}\n\t\t\tshowAsterisk={showAsterisk}\n\t\t\tclassName={wrapperClassName}\n\t\t\terrorMessage={errorMessage}\n\t\t\tunShowFieldTemplate={unShowFieldTemplate}\n\t\t\torientation={orientation}\n\t\t>\n\t\t\t<div className={className}>\n\t\t\t\t<input type=\"hidden\" name={name} value={value || \"\"} />\n\n\t\t\t\t{!filePath && (\n\t\t\t\t\t<NoFileContent\n\t\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\t\tisLoading={isLoading}\n\t\t\t\t\t\tacceptImage={acceptImage}\n\t\t\t\t\t\tdropImageText={dropImageText}\n\t\t\t\t\t\thandleSelectFile={handleSelectFile}\n\t\t\t\t\t\tselectImageButtonText={selectImageButtonText}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\n\t\t\t\t{filePath && (\n\t\t\t\t\t<HasFileContent\n\t\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\t\tisLoading={isLoading}\n\t\t\t\t\t\tacceptImage={acceptImage}\n\t\t\t\t\t\tfilePath={filePath}\n\t\t\t\t\t\thandleSelectFile={handleSelectFile}\n\t\t\t\t\t\tchangeImageButtonText={changeImageButtonText}\n\t\t\t\t\t\treSendImage={\n\t\t\t\t\t\t\terrorMessage && file ? () => handleUploadImage(file) : undefined\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t</div>\n\t\t</FieldTemplate>\n\t);\n}\n\nexport { ImageUpload };\n"],"mappings":";;;;;;;;AAmGA,SAAS,EAAY,GAAyB;CAC7C,IAAM,EACL,SACA,kBAAe,IACf,UACA,kBAAe,IACf,WACA,cAAW,QACX,WAAW,IAAmB,IAC9B,YAAS,QACT,iBAAc,WACd,sBAAmB,OACnB,2BAAwB,kBACxB,2BAAwB,qBACxB,mBAAgB,oCAChB,aACA,cAAW,IACX,yBAAsB,IACtB,iBAAc,eACX,GAEE,EAAE,mBAAgB,EAAQ,GAC1B,IAAa,IAAc,IAE3B,CAAC,GAAO,KAAY,EAAS,CAAY,GACzC,CAAC,GAAO,KAAY,EAAS,EAAE,GAC/B,CAAC,GAAM,KAAW,EAAsB,IAAI,GAC5C,CAAC,GAAU,KAAe,EAAS,CAAY,GAC/C,CAAC,GAAW,KAAgB,EAAS,EAAK;CAEhD,eAAe,EAAkB,GAAY;EAC5C,IAAI,GAAU;EAId,AAFA,EAAa,EAAI,GACjB,EAAQ,CAAI,GACZ,EAAS,EAAE;EAEX,IAAM,IAAW,IAAI,SAAS;EAG9B,AAFA,EAAS,OAAO,GAAU,CAAI,GAE9B,MAAM,MAAM,GAAQ;GAAU;GAAQ,MAAM;EAAS,CAAC,CAAC,CACrD,KAAK,OAAO,MAAa,MAAM,EAAS,KAAK,CAAC,CAAC,CAC/C,MAAM,MAAa;GAGnB,AAFI,GAAU,QAAO,EAAS,EAAS,KAAK,IACvC,EAAS,IAAW,EAAiB,GAC1C,IAAW,IAAW,EAAiB;EACxC,CAAC,CAAC,CACD,OAAO,MAAU;GAEjB,AADA,QAAQ,MAAM,CAAK,GACnB,EAAS,uBAAuB;EACjC,CAAC,CAAC,CACD,cAAc,EAAa,EAAK,CAAC;CACpC;CAEA,SAAS,EAAiB,GAAY;EACjC,MAEJ,EAAY,IAAI,gBAAgB,CAAI,CAAC,GACrC,EAAkB,CAAI;CACvB;CAEA,IAAM,IAAe,KAAc;CAMnC,OACC,kBAAC,GAAD;EACO;EACC;EACO;EACd,WAAW;EACG;EACO;EACR;YAEb,kBAAC,OAAD;GAAgB,WAAA,oBAdQ,IAAe,aAAa,aAEE,GAD9B,IAAW,aAAa;aAahD;IACC,kBAAC,SAAD;KAAO,MAAK;KAAe;KAAM,OAAO,KAAS;IAAK,CAAA;IAErD,CAAC,KACD,kBAAC,GAAD;KACW;KACC;KACE;KACE;KACG;KACK;IACvB,CAAA;IAGD,KACA,kBAAC,GAAD;KACW;KACC;KACE;KACH;KACQ;KACK;KACvB,aACC,KAAgB,UAAa,EAAkB,CAAI,IAAI,KAAA;IAExD,CAAA;GAEE;;CACS,CAAA;AAEjB"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../../src/components/imageUpload/index.tsx"],"sourcesContent":["import { useState } from \"react\";\n\nimport { useForm } from \"../../hooks/useForm\";\nimport { FieldTemplate } from \"../../services/fieldTemplate\";\n\nimport { HasFileContent } from \"./hasFileContent\";\nimport { NoFileContent } from \"./noFileContent\";\nimport \"./styles.css\";\n\ntype ImageUploadProps = {\n\t/** Field name for form submission (stores the uploaded image URL). Required. */\n\tname: string;\n\t/** Server endpoint URL that receives the `multipart/form-data` upload request. Required. */\n\taction: string;\n\t/** Pre-populated image URL displayed as a preview (e.g. an existing avatar). @default \"\" */\n\tdefaultValue?: string | null;\n\t/** Additional CSS class applied to the wrapper element. */\n\tclassName?: string;\n\t/** Disables file selection and upload. @default false */\n\tdisabled?: boolean;\n\t/** Optional label text displayed above the upload area. */\n\tlabel?: string;\n\t/** Displays an asterisk on the label to signal a required field. @default false */\n\tshowAsterisk?: boolean;\n\t/** Label for the file-picker button after an image is selected. @default \"Alterar imagem\" */\n\tchangeImageButtonText?: string;\n\t/** Label for the file-picker button before an image is selected. @default \"Selecionar imagem\" */\n\tselectImageButtonText?: string;\n\t/** Text displayed in the drag-and-drop zone. @default \"Ou arraste e solte a imagem aqui\" */\n\tdropImageText?: string;\n\t/** HTTP method for the upload request. @default \"POST\" */\n\tmethod?: string;\n\t/** Form-data field name used for the file. @default \"file\" */\n\tfileName?: string;\n\t/** Property name in the server response that contains the image URL. @default \"url\" */\n\tfileResponseName?: string;\n\t/** Accepted image MIME types or extensions (e.g. `\"image/jpeg,image/png\"`). @default \"image/*\" */\n\tacceptImage?: string;\n\t/** Callback fired after a successful upload. Receives the image URL returned by the server. */\n\tonChange?: (url: string) => void;\n\t/** When true, skips `FieldTemplate` wrapper (label and error text). @default false */\n\tunShowFieldTemplate?: boolean;\n\t/**\n\t * Layout direction forwarded to `FieldTemplate`.\n\t * @default \"horizontal\"\n\t */\n\torientation?: \"horizontal\" | \"vertical\" | \"horizontalReverse\";\n};\n\n/**\n * ImageUpload, drag-and-drop image uploader with server upload and image preview.\n *\n * Sends the file via `fetch` as `multipart/form-data` and stores the returned URL\n * in a hidden `<input>` for form submission.\n * Integrates with `useForm` to display validation errors by field name.\n *\n * @param props.name - Field name for form submission. Required.\n * @param props.action - Upload endpoint URL. Required.\n * @param props.defaultValue - Pre-populated image URL displayed as preview.\n * @param props.disabled - Disables file selection and upload. Default: false\n * @param props.label - Label text displayed above the upload area.\n * @param props.showAsterisk - Appends `*` to the label. Default: false\n * @param props.acceptImage - Accepted MIME types or extensions. Default: \"image/*\"\n * @param props.method - HTTP method. Default: \"POST\"\n * @param props.fileName - Form-data field name for the file. Default: \"file\"\n * @param props.fileResponseName - Server response property containing the URL. Default: \"url\"\n * @param props.onChange - Callback fired after a successful upload, receives the image URL.\n * @param props.orientation - Layout direction. Default: \"vertical\"\n * @param props.unShowFieldTemplate - Skips wrapper, label, and error rendering. Default: false\n *\n * @returns ImageUpload JSX element wrapped in `FieldTemplate`.\n *\n * @example\n * ```tsx\n * // Basic\n * <ImageUpload name=\"avatar\" action=\"/api/upload/image\" />\n *\n * // Profile picture with existing image and label\n * <ImageUpload\n * name=\"profilePicture\"\n * action=\"/api/upload/avatar\"\n * label=\"Profile Picture\"\n * showAsterisk\n * defaultValue={user.avatarUrl}\n * selectImageButtonText=\"Choose photo\"\n * onChange={(url) => updateProfile({ avatarUrl: url })}\n * />\n *\n * // Restricted to JPEG/PNG\n * <ImageUpload\n * name=\"productImage\"\n * action=\"/api/upload/product\"\n * label=\"Product Image\"\n * acceptImage=\"image/jpeg,image/png\"\n * fileResponseName=\"imageUrl\"\n * />\n * ```\n */\n\nfunction ImageUpload(props: ImageUploadProps) {\n\tconst {\n\t\tname,\n\t\tdefaultValue = \"\",\n\t\tlabel,\n\t\tshowAsterisk = false,\n\t\taction,\n\t\tfileName = \"file\",\n\t\tclassName: wrapperClassName = \"\",\n\t\tmethod = \"POST\",\n\t\tacceptImage = \"image/*\",\n\t\tfileResponseName = \"url\",\n\t\tchangeImageButtonText = \"Alterar imagem\",\n\t\tselectImageButtonText = \"Selecionar imagem\",\n\t\tdropImageText = \"Ou arraste e solte a imagem aqui\",\n\t\tonChange,\n\t\tdisabled = false,\n\t\tunShowFieldTemplate = false,\n\t\torientation = \"vertical\",\n\t} = props;\n\n\tconst { fieldErrors } = useForm();\n\tconst fieldError = fieldErrors?.[name];\n\n\tconst [value, setValue] = useState(defaultValue);\n\tconst [error, setError] = useState(\"\");\n\tconst [file, setFile] = useState<File | null>(null);\n\tconst [filePath, setFilePath] = useState(defaultValue);\n\tconst [isLoading, setIsLoading] = useState(false);\n\n\tasync function handleUploadImage(file: File) {\n\t\tif (disabled) return;\n\n\t\tsetIsLoading(true);\n\t\tsetFile(file);\n\t\tsetError(\"\");\n\n\t\tconst formData = new FormData();\n\t\tformData.append(fileName, file);\n\n\t\tawait fetch(action, { method: method, body: formData })\n\t\t\t.then(async (response) => await response.json())\n\t\t\t.then((response) => {\n\t\t\t\tif (response?.error) setError(response.error);\n\t\t\t\telse setValue(response?.[fileResponseName]);\n\t\t\t\tonChange?.(response?.[fileResponseName]);\n\t\t\t})\n\t\t\t.catch((error) => {\n\t\t\t\tconsole.error(error);\n\t\t\t\tsetError(\"Erro ao enviar imagem\");\n\t\t\t})\n\t\t\t.finally(() => setIsLoading(false));\n\t}\n\n\tfunction handleSelectFile(file: File) {\n\t\tif (disabled) return;\n\n\t\tsetFilePath(URL.createObjectURL(file));\n\t\thandleUploadImage(file);\n\t}\n\n\tconst errorMessage = fieldError || error;\n\n\tconst hasErrorClassName = errorMessage ? \"hasError\" : \"noHasError\";\n\tconst hasImageClassName = filePath ? \"hasImage\" : \"noHasImage\";\n\tconst className = `arkynImageUpload ${hasErrorClassName} ${hasImageClassName}`;\n\n\treturn (\n\t\t<FieldTemplate\n\t\t\tname={name}\n\t\t\tlabel={label}\n\t\t\tshowAsterisk={showAsterisk}\n\t\t\tclassName={wrapperClassName}\n\t\t\terrorMessage={errorMessage}\n\t\t\tunShowFieldTemplate={unShowFieldTemplate}\n\t\t\torientation={orientation}\n\t\t>\n\t\t\t<div className={className}>\n\t\t\t\t<input type=\"hidden\" name={name} value={value || \"\"} />\n\n\t\t\t\t{!filePath && (\n\t\t\t\t\t<NoFileContent\n\t\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\t\tisLoading={isLoading}\n\t\t\t\t\t\tacceptImage={acceptImage}\n\t\t\t\t\t\tdropImageText={dropImageText}\n\t\t\t\t\t\thandleSelectFile={handleSelectFile}\n\t\t\t\t\t\tselectImageButtonText={selectImageButtonText}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\n\t\t\t\t{filePath && (\n\t\t\t\t\t<HasFileContent\n\t\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\t\tisLoading={isLoading}\n\t\t\t\t\t\tacceptImage={acceptImage}\n\t\t\t\t\t\tfilePath={filePath}\n\t\t\t\t\t\thandleSelectFile={handleSelectFile}\n\t\t\t\t\t\tchangeImageButtonText={changeImageButtonText}\n\t\t\t\t\t\treSendImage={\n\t\t\t\t\t\t\terrorMessage && file ? () => handleUploadImage(file) : undefined\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t</div>\n\t\t</FieldTemplate>\n\t);\n}\n\nexport { ImageUpload };\n"],"mappings":";;;;;;;;AAmGA,SAAS,EAAY,GAAyB;CAC7C,IAAM,EACL,SACA,kBAAe,IACf,UACA,kBAAe,IACf,WACA,cAAW,QACX,WAAW,IAAmB,IAC9B,YAAS,QACT,iBAAc,WACd,sBAAmB,OACnB,2BAAwB,kBACxB,2BAAwB,qBACxB,mBAAgB,oCAChB,aACA,cAAW,IACX,yBAAsB,IACtB,iBAAc,eACX,GAEE,EAAE,mBAAgB,EAAQ,GAC1B,IAAa,IAAc,IAE3B,CAAC,GAAO,KAAY,EAAS,CAAY,GACzC,CAAC,GAAO,KAAY,EAAS,EAAE,GAC/B,CAAC,GAAM,KAAW,EAAsB,IAAI,GAC5C,CAAC,GAAU,KAAe,EAAS,CAAY,GAC/C,CAAC,GAAW,KAAgB,EAAS,EAAK;CAEhD,eAAe,EAAkB,GAAY;EAC5C,IAAI,GAAU;EAId,AAFA,EAAa,EAAI,GACjB,EAAQ,CAAI,GACZ,EAAS,EAAE;EAEX,IAAM,IAAW,IAAI,SAAS;EAG9B,AAFA,EAAS,OAAO,GAAU,CAAI,GAE9B,MAAM,MAAM,GAAQ;GAAU;GAAQ,MAAM;EAAS,CAAC,CAAC,CACrD,KAAK,OAAO,MAAa,MAAM,EAAS,KAAK,CAAC,CAAC,CAC/C,MAAM,MAAa;GAGnB,AAFI,GAAU,QAAO,EAAS,EAAS,KAAK,IACvC,EAAS,IAAW,EAAiB,GAC1C,IAAW,IAAW,EAAiB;EACxC,CAAC,CAAC,CACD,OAAO,MAAU;GAEjB,AADA,QAAQ,MAAM,CAAK,GACnB,EAAS,uBAAuB;EACjC,CAAC,CAAC,CACD,cAAc,EAAa,EAAK,CAAC;CACpC;CAEA,SAAS,EAAiB,GAAY;EACjC,MAEJ,EAAY,IAAI,gBAAgB,CAAI,CAAC,GACrC,EAAkB,CAAI;CACvB;CAEA,IAAM,IAAe,KAAc;CAMnC,OACC,kBAAC,GAAD;EACO;EACC;EACO;EACd,WAAW;EACG;EACO;EACR;YAEb,kBAAC,OAAD;GAAgB,WAAA,oBAdQ,IAAe,aAAa,aAEE,GAD9B,IAAW,aAAa;aAahD;IACC,kBAAC,SAAD;KAAO,MAAK;KAAe;KAAM,OAAO,KAAS;IAAK,CAAA;IAErD,CAAC,KACD,kBAAC,GAAD;KACW;KACC;KACE;KACE;KACG;KACK;IACvB,CAAA;IAGD,KACA,kBAAC,GAAD;KACW;KACC;KACE;KACH;KACQ;KACK;KACvB,aACC,KAAgB,UAAa,EAAkB,CAAI,IAAI,KAAA;IAExD,CAAA;GAEE;;CACS,CAAA;AAEjB"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../../src/components/input/index.tsx"],"sourcesContent":["import { Loader2, type LucideIcon } from \"lucide-react\";\nimport {\n\ttype FocusEvent,\n\ttype InputHTMLAttributes,\n\tuseId,\n\tuseRef,\n\tuseState,\n} from \"react\";\n\nimport { useForm } from \"../../hooks/useForm\";\nimport { FieldTemplate } from \"../../services/fieldTemplate\";\nimport { IconRenderer } from \"../../services/iconRenderer\";\n\nimport \"./style.css\";\n\ntype InputProps = Omit<\n\tInputHTMLAttributes<HTMLInputElement>,\n\t\"size\" | \"prefix\" | \"name\" | \"value\" | \"defaultValue\"\n> & {\n\t/** Field name for form submission. Required. */\n\tname: string;\n\t/** Optional label text displayed above the input. */\n\tlabel?: string;\n\t/** Validation error message displayed below the input. */\n\terrorMessage?: string;\n\t/** Shows a spinner and disables the input during async operations. @default false */\n\tisLoading?: boolean;\n\t/** When true, skips `FieldTemplate` wrapper (label and error text). @default false */\n\tunShowFieldTemplate?: boolean;\n\t/**\n\t * Input size.\n\t * @default \"md\"\n\t */\n\tsize?: \"md\" | \"lg\";\n\t/**\n\t * Visual style variant.\n\t * - `solid`: filled background.\n\t * - `outline`: bordered, transparent background.\n\t * - `underline`: bottom border only.\n\t * @default \"solid\"\n\t */\n\tvariant?: \"solid\" | \"outline\" | \"underline\";\n\t/** Text or icon rendered at the far left, outside the input area (e.g. `\"https://\"`). */\n\tprefix?: string | LucideIcon;\n\t/** Text or icon rendered at the far right, outside the input area (e.g. `\".com\"`). */\n\tsuffix?: string | LucideIcon;\n\t/** Displays an asterisk on the label to signal a required field. */\n\tshowAsterisk?: boolean;\n\t/**\n\t * Layout direction forwarded to `FieldTemplate`.\n\t * @default \"horizontal\"\n\t */\n\torientation?: \"horizontal\" | \"vertical\" | \"horizontalReverse\";\n\t/** Lucide icon rendered inside the input on the left. */\n\tleftIcon?: LucideIcon;\n\t/** Lucide icon rendered inside the input on the right. */\n\trightIcon?: LucideIcon;\n\t/** Controlled value. */\n\tvalue?: string;\n\t/** Uncontrolled default value. */\n\tdefaultValue?: string;\n};\n\n/**\n * Input, text input field with label, validation, icons, prefix/suffix, and loading state.\n *\n * Integrates with `useForm` to display validation errors by field name.\n *\n * @param props.name - Field name for form submission. Required.\n * @param props.label - Label text displayed above the input.\n * @param props.errorMessage - Validation error message.\n * @param props.isLoading - Shows a spinner and disables the input. Default: false\n * @param props.size - Input size (`md` | `lg`). Default: \"md\"\n * @param props.variant - Visual style variant. Default: \"solid\"\n * @param props.prefix - Text or icon at the far left (outside the input).\n * @param props.suffix - Text or icon at the far right (outside the input).\n * @param props.leftIcon - Lucide icon inside the input on the left.\n * @param props.rightIcon - Lucide icon inside the input on the right.\n * @param props.showAsterisk - Appends `*` to the label.\n * @param props.orientation - Layout direction (`horizontal` | `vertical` | `horizontalReverse`). Default: \"horizontal\"\n * @param props.unShowFieldTemplate - Skips wrapper, label, and error rendering. Default: false\n *\n * **...Other valid HTML properties for `<input>`**\n *\n * @returns Input JSX element wrapped in `FieldTemplate`.\n *\n * @example\n * ```tsx\n * // Basic\n * <Input name=\"username\" placeholder=\"Enter username\" />\n *\n * // With label and validation\n * <Input\n * name=\"email\"\n * label=\"Email Address\"\n * type=\"email\"\n * showAsterisk\n * errorMessage=\"Please enter a valid email\"\n * />\n *\n * // With icons and loading state\n * <Input name=\"search\" label=\"Search\" leftIcon={SearchIcon} isLoading />\n *\n * // With prefix/suffix\n * <Input name=\"website\" label=\"Website\" prefix=\"https://\" suffix=\".com\" variant=\"outline\" />\n * ```\n */\n\nfunction Input(props: InputProps) {\n\tconst {\n\t\tname,\n\t\tdisabled,\n\t\ttitle,\n\t\tstyle,\n\t\tvariant = \"solid\",\n\t\tlabel,\n\t\tclassName: wrapperClassName = \"\",\n\t\tprefix,\n\t\tsuffix,\n\t\tisLoading = false,\n\t\tleftIcon,\n\t\treadOnly,\n\t\tonFocus,\n\t\tonBlur,\n\t\tunShowFieldTemplate = false,\n\t\terrorMessage: baseErrorMessage,\n\t\tshowAsterisk,\n\t\trightIcon,\n\t\ttype = \"text\",\n\t\tsize = \"md\",\n\t\tid,\n\t\tvalue,\n\t\tplaceholder,\n\t\torientation,\n\t\t...rest\n\t} = props;\n\n\tconst { fieldErrors } = useForm();\n\tconst [isFocused, setIsFocused] = useState(false);\n\tconst inputRef = useRef<HTMLInputElement>(null);\n\tconst generatedId = useId();\n\tconst inputId = id || generatedId;\n\n\tconst errorMessage = baseErrorMessage || fieldErrors?.[name];\n\tconst isError = !!errorMessage;\n\tconst isDisabled = disabled || isLoading;\n\n\tconst iconSizes = { md: 20, lg: 20 };\n\tconst iconSize = iconSizes[size];\n\n\tconst loadingPosition = rightIcon ? \"right\" : \"left\";\n\n\tconst showLeftSpinner = loadingPosition === \"left\" && isLoading;\n\tconst showRightSpinner = loadingPosition === \"right\" && isLoading;\n\n\tfunction handleSectionClick() {\n\t\tif (isDisabled || !inputRef?.current) return;\n\t\tsetIsFocused(true);\n\t\tinputRef.current.focus();\n\t}\n\n\tfunction handleFocus(e: FocusEvent<HTMLInputElement>) {\n\t\tsetIsFocused(true);\n\t\tif (onFocus) onFocus(e);\n\t}\n\n\tfunction handleBlur(e: FocusEvent<HTMLInputElement>) {\n\t\tsetIsFocused(false);\n\t\tif (onBlur) onBlur(e);\n\t}\n\n\tif (type === \"hidden\") {\n\t\treturn (\n\t\t\t<input\n\t\t\t\tstyle={{ display: \"none\" }}\n\t\t\t\treadOnly\n\t\t\t\ttype=\"text\"\n\t\t\t\tref={inputRef}\n\t\t\t\t{...rest}\n\t\t\t/>\n\t\t);\n\t}\n\n\tconst hasPrefix = prefix ? \"hasPrefix\" : \"\";\n\tconst hasSuffix = suffix ? \"hasSuffix\" : \"\";\n\tconst errored = isError ? \"errored\" : \"\";\n\tconst opacity = isDisabled || readOnly || isLoading ? \"opacity\" : \"\";\n\tconst focused = isFocused ? \"focused\" : \"\";\n\tconst disabledClass = disabled ? \"disabled\" : \"\";\n\n\tconst className = `arkynInput ${hasPrefix} ${disabledClass} ${hasSuffix} ${variant} ${size} ${opacity} ${errored} ${focused}`;\n\n\treturn (\n\t\t<FieldTemplate\n\t\t\tname={name}\n\t\t\tlabel={label}\n\t\t\tshowAsterisk={showAsterisk}\n\t\t\tclassName={wrapperClassName}\n\t\t\terrorMessage={errorMessage}\n\t\t\tunShowFieldTemplate={unShowFieldTemplate}\n\t\t\torientation={orientation}\n\t\t>\n\t\t\t<section\n\t\t\t\ttitle={title}\n\t\t\t\tstyle={style}\n\t\t\t\tonClick={handleSectionClick}\n\t\t\t\tclassName={className}\n\t\t\t>\n\t\t\t\t<IconRenderer iconSize={iconSize} icon={prefix} className=\"prefix\" />\n\n\t\t\t\t<IconRenderer\n\t\t\t\t\tshow={showLeftSpinner}\n\t\t\t\t\ticonSize={iconSize}\n\t\t\t\t\tclassName=\"spinner\"\n\t\t\t\t\ticon={Loader2}\n\t\t\t\t/>\n\n\t\t\t\t<IconRenderer show={!isLoading} icon={leftIcon} iconSize={iconSize} />\n\n\t\t\t\t<input\n\t\t\t\t\tdisabled={isDisabled}\n\t\t\t\t\treadOnly={readOnly}\n\t\t\t\t\tref={inputRef}\n\t\t\t\t\tonFocus={handleFocus}\n\t\t\t\t\tonBlur={handleBlur}\n\t\t\t\t\ttype={type}\n\t\t\t\t\tid={inputId}\n\t\t\t\t\tname={name}\n\t\t\t\t\tplaceholder={isDisabled ? value || placeholder : placeholder}\n\t\t\t\t\tvalue={isDisabled ? undefined : value}\n\t\t\t\t\t{...rest}\n\t\t\t\t/>\n\n\t\t\t\t<IconRenderer show={!isLoading} icon={rightIcon} iconSize={iconSize} />\n\n\t\t\t\t<IconRenderer\n\t\t\t\t\tshow={showRightSpinner}\n\t\t\t\t\ticonSize={iconSize}\n\t\t\t\t\tclassName=\"spinner\"\n\t\t\t\t\ticon={Loader2}\n\t\t\t\t/>\n\n\t\t\t\t<IconRenderer iconSize={iconSize} icon={suffix} className=\"suffix\" />\n\t\t\t</section>\n\t\t</FieldTemplate>\n\t);\n}\n\nexport { Input, type InputProps };\n"],"mappings":";;;;;;;;AA4GA,SAAS,EAAM,GAAmB;CACjC,IAAM,EACL,SACA,aACA,UACA,UACA,aAAU,SACV,UACA,WAAW,IAAmB,IAC9B,WACA,WACA,eAAY,IACZ,aACA,aACA,YACA,WACA,yBAAsB,IACtB,cAAc,GACd,iBACA,cACA,UAAO,QACP,UAAO,MACP,OACA,UACA,gBACA,gBACA,GAAG,MACA,GAEE,EAAE,mBAAgB,EAAQ,GAC1B,CAAC,GAAW,KAAgB,EAAS,EAAK,GAC1C,IAAW,EAAyB,IAAI,GACxC,IAAc,EAAM,GACpB,IAAU,KAAM,GAEhB,IAAe,KAAoB,IAAc,IACjD,IAAU,CAAC,CAAC,GACZ,IAAa,KAAY,GAGzB,IAAW;EADG,IAAI;EAAI,IAAI;CACf,EAAU,IAErB,IAAkB,IAAY,UAAU,QAExC,IAAkB,MAAoB,UAAU,GAChD,IAAmB,MAAoB,WAAW;CAExD,SAAS,IAAqB;EACzB,KAAc,CAAC,GAAU,YAC7B,EAAa,EAAI,GACjB,EAAS,QAAQ,MAAM;CACxB;CAEA,SAAS,EAAY,GAAiC;EAErD,AADA,EAAa,EAAI,GACb,KAAS,EAAQ,CAAC;CACvB;CAEA,SAAS,EAAW,GAAiC;EAEpD,AADA,EAAa,EAAK,GACd,KAAQ,EAAO,CAAC;CACrB;CAuBA,OArBI,MAAS,WAEX,kBAAC,SAAD;EACC,OAAO,EAAE,SAAS,OAAO;EACzB,UAAA;EACA,MAAK;EACL,KAAK;EACL,GAAI;CACJ,CAAA,IAcF,kBAAC,GAAD;EACO;EACC;EACO;EACd,WAAW;EACG;EACO;EACR;YAEb,kBAAC,WAAD;GACQ;GACA;GACP,SAAS;GACE,WAAA,cAvBI,IAAS,cAAc,GAOC,GAFpB,IAAW,aAAa,GAEa,GANzC,IAAS,cAAc,GAM+B,GAAG,EAAQ,GAAG,EAAK,GAJ3E,KAAc,KAAY,IAAY,YAAY,GAIoC,GALtF,IAAU,YAAY,GAK2E,GAHjG,IAAY,YAAY;aAetC;IAMC,kBAAC,GAAD;KAAwB;KAAU,MAAM;KAAQ,WAAU;IAAU,CAAA;IAEpE,kBAAC,GAAD;KACC,MAAM;KACI;KACV,WAAU;KACV,MAAM;IACN,CAAA;IAED,kBAAC,GAAD;KAAc,MAAM,CAAC;KAAW,MAAM;KAAoB;IAAW,CAAA;IAErE,kBAAC,SAAD;KACC,UAAU;KACA;KACV,KAAK;KACL,SAAS;KACT,QAAQ;KACF;KACN,IAAI;KACE;KACN,aAAa,KAAa,KAAuB;KACjD,OAAO,IAAa,KAAA,IAAY;KAChC,GAAI;IACJ,CAAA;IAED,kBAAC,GAAD;KAAc,MAAM,CAAC;KAAW,MAAM;KAAqB;IAAW,CAAA;IAEtE,kBAAC,GAAD;KACC,MAAM;KACI;KACV,WAAU;KACV,MAAM;IACN,CAAA;IAED,kBAAC,GAAD;KAAwB;KAAU,MAAM;KAAQ,WAAU;IAAU,CAAA;GAC5D;;CACK,CAAA;AAEjB"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../../src/components/input/index.tsx"],"sourcesContent":["import { Loader2, type LucideIcon } from \"lucide-react\";\nimport {\n\ttype FocusEvent,\n\ttype InputHTMLAttributes,\n\tuseId,\n\tuseRef,\n\tuseState,\n} from \"react\";\n\nimport { useForm } from \"../../hooks/useForm\";\nimport { FieldTemplate } from \"../../services/fieldTemplate\";\nimport { IconRenderer } from \"../../services/iconRenderer\";\n\nimport \"./style.css\";\n\ntype InputProps = Omit<\n\tInputHTMLAttributes<HTMLInputElement>,\n\t\"size\" | \"prefix\" | \"name\" | \"value\" | \"defaultValue\"\n> & {\n\t/** Field name for form submission. Required. */\n\tname: string;\n\t/** Optional label text displayed above the input. */\n\tlabel?: string;\n\t/** Validation error message displayed below the input. */\n\terrorMessage?: string;\n\t/** Shows a spinner and disables the input during async operations. @default false */\n\tisLoading?: boolean;\n\t/** When true, skips `FieldTemplate` wrapper (label and error text). @default false */\n\tunShowFieldTemplate?: boolean;\n\t/**\n\t * Input size.\n\t * @default \"md\"\n\t */\n\tsize?: \"md\" | \"lg\";\n\t/**\n\t * Visual style variant.\n\t * - `solid`: filled background.\n\t * - `outline`: bordered, transparent background.\n\t * - `underline`: bottom border only.\n\t * @default \"solid\"\n\t */\n\tvariant?: \"solid\" | \"outline\" | \"underline\";\n\t/** Text or icon rendered at the far left, outside the input area (e.g. `\"https://\"`). */\n\tprefix?: string | LucideIcon;\n\t/** Text or icon rendered at the far right, outside the input area (e.g. `\".com\"`). */\n\tsuffix?: string | LucideIcon;\n\t/** Displays an asterisk on the label to signal a required field. */\n\tshowAsterisk?: boolean;\n\t/**\n\t * Layout direction forwarded to `FieldTemplate`.\n\t * @default \"horizontal\"\n\t */\n\torientation?: \"horizontal\" | \"vertical\" | \"horizontalReverse\";\n\t/** Lucide icon rendered inside the input on the left. */\n\tleftIcon?: LucideIcon;\n\t/** Lucide icon rendered inside the input on the right. */\n\trightIcon?: LucideIcon;\n\t/** Controlled value. */\n\tvalue?: string;\n\t/** Uncontrolled default value. */\n\tdefaultValue?: string;\n};\n\n/**\n * Input, text input field with label, validation, icons, prefix/suffix, and loading state.\n *\n * Integrates with `useForm` to display validation errors by field name.\n *\n * @param props.name - Field name for form submission. Required.\n * @param props.label - Label text displayed above the input.\n * @param props.errorMessage - Validation error message.\n * @param props.isLoading - Shows a spinner and disables the input. Default: false\n * @param props.size - Input size (`md` | `lg`). Default: \"md\"\n * @param props.variant - Visual style variant. Default: \"solid\"\n * @param props.prefix - Text or icon at the far left (outside the input).\n * @param props.suffix - Text or icon at the far right (outside the input).\n * @param props.leftIcon - Lucide icon inside the input on the left.\n * @param props.rightIcon - Lucide icon inside the input on the right.\n * @param props.showAsterisk - Appends `*` to the label.\n * @param props.orientation - Layout direction (`horizontal` | `vertical` | `horizontalReverse`). Default: \"vertical\"\n * @param props.unShowFieldTemplate - Skips wrapper, label, and error rendering. Default: false\n *\n * **...Other valid HTML properties for `<input>`**\n *\n * @returns Input JSX element wrapped in `FieldTemplate`.\n *\n * @example\n * ```tsx\n * // Basic\n * <Input name=\"username\" placeholder=\"Enter username\" />\n *\n * // With label and validation\n * <Input\n * name=\"email\"\n * label=\"Email Address\"\n * type=\"email\"\n * showAsterisk\n * errorMessage=\"Please enter a valid email\"\n * />\n *\n * // With icons and loading state\n * <Input name=\"search\" label=\"Search\" leftIcon={SearchIcon} isLoading />\n *\n * // With prefix/suffix\n * <Input name=\"website\" label=\"Website\" prefix=\"https://\" suffix=\".com\" variant=\"outline\" />\n * ```\n */\n\nfunction Input(props: InputProps) {\n\tconst {\n\t\tname,\n\t\tdisabled,\n\t\ttitle,\n\t\tstyle,\n\t\tvariant = \"solid\",\n\t\tlabel,\n\t\tclassName: wrapperClassName = \"\",\n\t\tprefix,\n\t\tsuffix,\n\t\tisLoading = false,\n\t\tleftIcon,\n\t\treadOnly,\n\t\tonFocus,\n\t\tonBlur,\n\t\tunShowFieldTemplate = false,\n\t\terrorMessage: baseErrorMessage,\n\t\tshowAsterisk,\n\t\trightIcon,\n\t\ttype = \"text\",\n\t\tsize = \"md\",\n\t\tid,\n\t\tvalue,\n\t\tplaceholder,\n\t\torientation,\n\t\t...rest\n\t} = props;\n\n\tconst { fieldErrors } = useForm();\n\tconst [isFocused, setIsFocused] = useState(false);\n\tconst inputRef = useRef<HTMLInputElement>(null);\n\tconst generatedId = useId();\n\tconst inputId = id || generatedId;\n\n\tconst errorMessage = baseErrorMessage || fieldErrors?.[name];\n\tconst isError = !!errorMessage;\n\tconst isDisabled = disabled || isLoading;\n\n\tconst iconSizes = { md: 20, lg: 20 };\n\tconst iconSize = iconSizes[size];\n\n\tconst loadingPosition = rightIcon ? \"right\" : \"left\";\n\n\tconst showLeftSpinner = loadingPosition === \"left\" && isLoading;\n\tconst showRightSpinner = loadingPosition === \"right\" && isLoading;\n\n\tfunction handleSectionClick() {\n\t\tif (isDisabled || !inputRef?.current) return;\n\t\tsetIsFocused(true);\n\t\tinputRef.current.focus();\n\t}\n\n\tfunction handleFocus(e: FocusEvent<HTMLInputElement>) {\n\t\tsetIsFocused(true);\n\t\tif (onFocus) onFocus(e);\n\t}\n\n\tfunction handleBlur(e: FocusEvent<HTMLInputElement>) {\n\t\tsetIsFocused(false);\n\t\tif (onBlur) onBlur(e);\n\t}\n\n\tif (type === \"hidden\") {\n\t\treturn (\n\t\t\t<input\n\t\t\t\tstyle={{ display: \"none\" }}\n\t\t\t\treadOnly\n\t\t\t\ttype=\"text\"\n\t\t\t\tref={inputRef}\n\t\t\t\t{...rest}\n\t\t\t/>\n\t\t);\n\t}\n\n\tconst hasPrefix = prefix ? \"hasPrefix\" : \"\";\n\tconst hasSuffix = suffix ? \"hasSuffix\" : \"\";\n\tconst errored = isError ? \"errored\" : \"\";\n\tconst opacity = isDisabled || readOnly || isLoading ? \"opacity\" : \"\";\n\tconst focused = isFocused ? \"focused\" : \"\";\n\tconst disabledClass = disabled ? \"disabled\" : \"\";\n\n\tconst className = `arkynInput ${hasPrefix} ${disabledClass} ${hasSuffix} ${variant} ${size} ${opacity} ${errored} ${focused}`;\n\n\treturn (\n\t\t<FieldTemplate\n\t\t\tname={name}\n\t\t\tlabel={label}\n\t\t\tshowAsterisk={showAsterisk}\n\t\t\tclassName={wrapperClassName}\n\t\t\terrorMessage={errorMessage}\n\t\t\tunShowFieldTemplate={unShowFieldTemplate}\n\t\t\torientation={orientation}\n\t\t>\n\t\t\t<section\n\t\t\t\ttitle={title}\n\t\t\t\tstyle={style}\n\t\t\t\tonClick={handleSectionClick}\n\t\t\t\tclassName={className}\n\t\t\t>\n\t\t\t\t<IconRenderer iconSize={iconSize} icon={prefix} className=\"prefix\" />\n\n\t\t\t\t<IconRenderer\n\t\t\t\t\tshow={showLeftSpinner}\n\t\t\t\t\ticonSize={iconSize}\n\t\t\t\t\tclassName=\"spinner\"\n\t\t\t\t\ticon={Loader2}\n\t\t\t\t/>\n\n\t\t\t\t<IconRenderer show={!isLoading} icon={leftIcon} iconSize={iconSize} />\n\n\t\t\t\t<input\n\t\t\t\t\tdisabled={isDisabled}\n\t\t\t\t\treadOnly={readOnly}\n\t\t\t\t\tref={inputRef}\n\t\t\t\t\tonFocus={handleFocus}\n\t\t\t\t\tonBlur={handleBlur}\n\t\t\t\t\ttype={type}\n\t\t\t\t\tid={inputId}\n\t\t\t\t\tname={name}\n\t\t\t\t\tplaceholder={isDisabled ? value || placeholder : placeholder}\n\t\t\t\t\tvalue={isDisabled ? undefined : value}\n\t\t\t\t\t{...rest}\n\t\t\t\t/>\n\n\t\t\t\t<IconRenderer show={!isLoading} icon={rightIcon} iconSize={iconSize} />\n\n\t\t\t\t<IconRenderer\n\t\t\t\t\tshow={showRightSpinner}\n\t\t\t\t\ticonSize={iconSize}\n\t\t\t\t\tclassName=\"spinner\"\n\t\t\t\t\ticon={Loader2}\n\t\t\t\t/>\n\n\t\t\t\t<IconRenderer iconSize={iconSize} icon={suffix} className=\"suffix\" />\n\t\t\t</section>\n\t\t</FieldTemplate>\n\t);\n}\n\nexport { Input, type InputProps };\n"],"mappings":";;;;;;;;AA4GA,SAAS,EAAM,GAAmB;CACjC,IAAM,EACL,SACA,aACA,UACA,UACA,aAAU,SACV,UACA,WAAW,IAAmB,IAC9B,WACA,WACA,eAAY,IACZ,aACA,aACA,YACA,WACA,yBAAsB,IACtB,cAAc,GACd,iBACA,cACA,UAAO,QACP,UAAO,MACP,OACA,UACA,gBACA,gBACA,GAAG,MACA,GAEE,EAAE,mBAAgB,EAAQ,GAC1B,CAAC,GAAW,KAAgB,EAAS,EAAK,GAC1C,IAAW,EAAyB,IAAI,GACxC,IAAc,EAAM,GACpB,IAAU,KAAM,GAEhB,IAAe,KAAoB,IAAc,IACjD,IAAU,CAAC,CAAC,GACZ,IAAa,KAAY,GAGzB,IAAW;EADG,IAAI;EAAI,IAAI;CACf,EAAU,IAErB,IAAkB,IAAY,UAAU,QAExC,IAAkB,MAAoB,UAAU,GAChD,IAAmB,MAAoB,WAAW;CAExD,SAAS,IAAqB;EACzB,KAAc,CAAC,GAAU,YAC7B,EAAa,EAAI,GACjB,EAAS,QAAQ,MAAM;CACxB;CAEA,SAAS,EAAY,GAAiC;EAErD,AADA,EAAa,EAAI,GACb,KAAS,EAAQ,CAAC;CACvB;CAEA,SAAS,EAAW,GAAiC;EAEpD,AADA,EAAa,EAAK,GACd,KAAQ,EAAO,CAAC;CACrB;CAuBA,OArBI,MAAS,WAEX,kBAAC,SAAD;EACC,OAAO,EAAE,SAAS,OAAO;EACzB,UAAA;EACA,MAAK;EACL,KAAK;EACL,GAAI;CACJ,CAAA,IAcF,kBAAC,GAAD;EACO;EACC;EACO;EACd,WAAW;EACG;EACO;EACR;YAEb,kBAAC,WAAD;GACQ;GACA;GACP,SAAS;GACE,WAAA,cAvBI,IAAS,cAAc,GAOC,GAFpB,IAAW,aAAa,GAEa,GANzC,IAAS,cAAc,GAM+B,GAAG,EAAQ,GAAG,EAAK,GAJ3E,KAAc,KAAY,IAAY,YAAY,GAIoC,GALtF,IAAU,YAAY,GAK2E,GAHjG,IAAY,YAAY;aAetC;IAMC,kBAAC,GAAD;KAAwB;KAAU,MAAM;KAAQ,WAAU;IAAU,CAAA;IAEpE,kBAAC,GAAD;KACC,MAAM;KACI;KACV,WAAU;KACV,MAAM;IACN,CAAA;IAED,kBAAC,GAAD;KAAc,MAAM,CAAC;KAAW,MAAM;KAAoB;IAAW,CAAA;IAErE,kBAAC,SAAD;KACC,UAAU;KACA;KACV,KAAK;KACL,SAAS;KACT,QAAQ;KACF;KACN,IAAI;KACE;KACN,aAAa,KAAa,KAAuB;KACjD,OAAO,IAAa,KAAA,IAAY;KAChC,GAAI;IACJ,CAAA;IAED,kBAAC,GAAD;KAAc,MAAM,CAAC;KAAW,MAAM;KAAqB;IAAW,CAAA;IAEtE,kBAAC,GAAD;KACC,MAAM;KACI;KACV,WAAU;KACV,MAAM;IACN,CAAA;IAED,kBAAC,GAAD;KAAwB;KAAU,MAAM;KAAQ,WAAU;IAAU,CAAA;GAC5D;;CACK,CAAA;AAEjB"}
@@ -1,38 +1,46 @@
1
1
  import { useScrollLock as e } from "../../../hooks/useScrollLock.js";
2
- import { ModalProvider as t } from "../modalContext.js";
2
+ import { useEscapeKey as t } from "../../../hooks/useEscapeKey.js";
3
+ import { useFocusTrap as n } from "../../../hooks/useFocusTrap.js";
4
+ import { ModalProvider as r } from "../modalContext.js";
3
5
  /* empty css */
4
- import { useEffect as n, useState as r } from "react";
5
- import { jsx as i, jsxs as a } from "react/jsx-runtime";
6
+ import { useEffect as i, useRef as a, useState as o } from "react";
7
+ import { jsx as s, jsxs as c } from "react/jsx-runtime";
6
8
  //#region src/components/modal/modalContainer/index.tsx
7
- function o(o) {
8
- let { isVisible: s, makeInvisible: c, children: l, className: u = "", ...d } = o, [f, p] = r(s), [m, h] = r(!1);
9
- n(() => {
10
- s ? (p(!0), h(!1)) : f && h(!0);
11
- }, [s, f]), e(s);
12
- function g(e) {
13
- e.target === e.currentTarget && m && (h(!1), p(!1), c());
9
+ function l(l) {
10
+ let { isVisible: u, makeInvisible: d, children: f, className: p = "", ...m } = l, [h, g] = o(u), [_, v] = o(!1), y = a(null);
11
+ i(() => {
12
+ u ? (g(!0), v(!1)) : h && v(!0);
13
+ }, [u, h]), e(u);
14
+ let b = h && !_;
15
+ t(b, () => v(!0)), n(b, y);
16
+ function x(e) {
17
+ e.target === e.currentTarget && _ && (v(!1), g(!1), d());
14
18
  }
15
- return f ? /* @__PURE__ */ i(t, {
16
- makeInvisible: () => h(!0),
17
- children: /* @__PURE__ */ a("aside", {
19
+ return h ? /* @__PURE__ */ s(r, {
20
+ makeInvisible: () => v(!0),
21
+ children: /* @__PURE__ */ c("aside", {
18
22
  className: [
19
23
  "arkynModalContainer",
20
- m ? "exiting" : "",
21
- u
24
+ _ ? "exiting" : "",
25
+ p
22
26
  ].filter(Boolean).join(" ").trim(),
23
- ...d,
24
- children: [/* @__PURE__ */ i("div", {
27
+ ...m,
28
+ children: [/* @__PURE__ */ s("div", {
25
29
  className: "arkynModalContainerOverlay",
26
- onClick: () => h(!0),
27
- onAnimationEnd: g
28
- }), /* @__PURE__ */ i("div", {
30
+ onClick: () => v(!0),
31
+ onAnimationEnd: x
32
+ }), /* @__PURE__ */ s("div", {
33
+ ref: y,
34
+ role: "dialog",
35
+ "aria-modal": "true",
36
+ tabIndex: -1,
29
37
  className: "arkynModalContainerContent",
30
- children: l
38
+ children: f
31
39
  })]
32
40
  })
33
41
  }) : null;
34
42
  }
35
43
  //#endregion
36
- export { o as ModalContainer };
44
+ export { l as ModalContainer };
37
45
 
38
46
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../../../src/components/modal/modalContainer/index.tsx"],"sourcesContent":["import {\n\ttype AnimationEvent,\n\ttype HTMLAttributes,\n\tuseEffect,\n\tuseState,\n} from \"react\";\n\nimport { useScrollLock } from \"../../../hooks/useScrollLock\";\nimport { ModalProvider } from \"../modalContext\";\nimport \"./styles.css\";\n\ntype ModalContainerProps = HTMLAttributes<HTMLElement> & {\n\t/** Controls whether the modal is visible. */\n\tisVisible: boolean;\n\t/** Callback invoked when the backdrop overlay is clicked. */\n\tmakeInvisible: () => void;\n};\n\n/**\n * ModalContainer, animated centered modal rendered over a backdrop overlay.\n *\n * Locks body scroll while open. Closes when the overlay is clicked.\n * Provides context consumed by `ModalHeader` (close button).\n *\n * @param props.isVisible - Whether the modal is open. Required.\n * @param props.makeInvisible - Called when the overlay is clicked. Required.\n *\n * **...Other valid HTML `<aside>` properties**\n *\n * @returns ModalContainer JSX element.\n *\n * @example\n * ```tsx\n * const [isOpen, setIsOpen] = useState(false);\n *\n * <ModalContainer isVisible={isOpen} makeInvisible={() => setIsOpen(false)}>\n * <ModalHeader><h2>Confirm deletion</h2></ModalHeader>\n * <main><p>This action cannot be undone.</p></main>\n * <ModalFooter>\n * <Button onClick={() => setIsOpen(false)}>Cancel</Button>\n * <Button scheme=\"danger\" onClick={handleDelete}>Delete</Button>\n * </ModalFooter>\n * </ModalContainer>\n * ```\n */\n\nfunction ModalContainer(args: ModalContainerProps) {\n\tconst {\n\t\tisVisible,\n\t\tmakeInvisible,\n\t\tchildren,\n\t\tclassName: baseClassName = \"\",\n\t\t...rest\n\t} = args;\n\n\tconst [mounted, setMounted] = useState(isVisible);\n\tconst [isExiting, setIsExiting] = useState(false);\n\n\tuseEffect(() => {\n\t\tif (isVisible) {\n\t\t\tsetMounted(true);\n\t\t\tsetIsExiting(false);\n\t\t} else if (mounted) {\n\t\t\tsetIsExiting(true);\n\t\t}\n\t}, [isVisible, mounted]);\n\n\tuseScrollLock(isVisible);\n\n\tfunction handleOverlayAnimationEnd(e: AnimationEvent<HTMLDivElement>) {\n\t\tif (e.target === e.currentTarget && isExiting) {\n\t\t\tsetIsExiting(false);\n\t\t\tsetMounted(false);\n\t\t\tmakeInvisible();\n\t\t}\n\t}\n\n\tif (!mounted) return null;\n\n\tconst className = [\n\t\t\"arkynModalContainer\",\n\t\tisExiting ? \"exiting\" : \"\",\n\t\tbaseClassName,\n\t]\n\t\t.filter(Boolean)\n\t\t.join(\" \");\n\n\treturn (\n\t\t<ModalProvider makeInvisible={() => setIsExiting(true)}>\n\t\t\t<aside className={className.trim()} {...rest}>\n\t\t\t\t<div\n\t\t\t\t\tclassName=\"arkynModalContainerOverlay\"\n\t\t\t\t\tonClick={() => setIsExiting(true)}\n\t\t\t\t\tonAnimationEnd={handleOverlayAnimationEnd}\n\t\t\t\t/>\n\t\t\t\t<div className=\"arkynModalContainerContent\">{children}</div>\n\t\t\t</aside>\n\t\t</ModalProvider>\n\t);\n}\n\nexport { ModalContainer };\n"],"mappings":";;;;;;AA8CA,SAAS,EAAe,GAA2B;CAClD,IAAM,EACL,cACA,kBACA,aACA,WAAW,IAAgB,IAC3B,GAAG,MACA,GAEE,CAAC,GAAS,KAAc,EAAS,CAAS,GAC1C,CAAC,GAAW,KAAgB,EAAS,EAAK;CAWhD,AATA,QAAgB;EACf,AAAI,KACH,EAAW,EAAI,GACf,EAAa,EAAK,KACR,KACV,EAAa,EAAI;CAEnB,GAAG,CAAC,GAAW,CAAO,CAAC,GAEvB,EAAc,CAAS;CAEvB,SAAS,EAA0B,GAAmC;EACrE,AAAI,EAAE,WAAW,EAAE,iBAAiB,MACnC,EAAa,EAAK,GAClB,EAAW,EAAK,GAChB,EAAc;CAEhB;CAYA,OAVK,IAWJ,kBAAC,GAAD;EAAe,qBAAqB,EAAa,EAAI;YACpD,kBAAC,SAAD;GAAO,WAVS;IACjB;IACA,IAAY,YAAY;IACxB;GACD,CAAC,CACC,OAAO,OAAO,CAAC,CACf,KAAK,GAIa,CAAA,CAAU,KAAK;GAAG,GAAI;aAAxC,CACC,kBAAC,OAAD;IACC,WAAU;IACV,eAAe,EAAa,EAAI;IAChC,gBAAgB;GAChB,CAAA,GACD,kBAAC,OAAD;IAAK,WAAU;IAA8B;GAAc,CAAA,CACrD;;CACO,CAAA,IApBK;AAsBtB"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../../../src/components/modal/modalContainer/index.tsx"],"sourcesContent":["import {\n\ttype AnimationEvent,\n\ttype HTMLAttributes,\n\tuseEffect,\n\tuseRef,\n\tuseState,\n} from \"react\";\n\nimport { useEscapeKey } from \"../../../hooks/useEscapeKey\";\nimport { useFocusTrap } from \"../../../hooks/useFocusTrap\";\nimport { useScrollLock } from \"../../../hooks/useScrollLock\";\nimport { ModalProvider } from \"../modalContext\";\nimport \"./styles.css\";\n\ntype ModalContainerProps = HTMLAttributes<HTMLElement> & {\n\t/** Controls whether the modal is visible. */\n\tisVisible: boolean;\n\t/** Callback invoked when the backdrop overlay is clicked. */\n\tmakeInvisible: () => void;\n};\n\n/**\n * ModalContainer, animated centered modal rendered over a backdrop overlay.\n *\n * Locks body scroll while open. Closes when the overlay is clicked.\n * Provides context consumed by `ModalHeader` (close button).\n *\n * @param props.isVisible - Whether the modal is open. Required.\n * @param props.makeInvisible - Called when the overlay is clicked. Required.\n *\n * **...Other valid HTML `<aside>` properties**\n *\n * @returns ModalContainer JSX element.\n *\n * @example\n * ```tsx\n * const [isOpen, setIsOpen] = useState(false);\n *\n * <ModalContainer isVisible={isOpen} makeInvisible={() => setIsOpen(false)}>\n * <ModalHeader><h2>Confirm deletion</h2></ModalHeader>\n * <main><p>This action cannot be undone.</p></main>\n * <ModalFooter>\n * <Button onClick={() => setIsOpen(false)}>Cancel</Button>\n * <Button scheme=\"danger\" onClick={handleDelete}>Delete</Button>\n * </ModalFooter>\n * </ModalContainer>\n * ```\n */\n\nfunction ModalContainer(args: ModalContainerProps) {\n\tconst {\n\t\tisVisible,\n\t\tmakeInvisible,\n\t\tchildren,\n\t\tclassName: baseClassName = \"\",\n\t\t...rest\n\t} = args;\n\n\tconst [mounted, setMounted] = useState(isVisible);\n\tconst [isExiting, setIsExiting] = useState(false);\n\tconst contentRef = useRef<HTMLDivElement>(null);\n\n\tuseEffect(() => {\n\t\tif (isVisible) {\n\t\t\tsetMounted(true);\n\t\t\tsetIsExiting(false);\n\t\t} else if (mounted) {\n\t\t\tsetIsExiting(true);\n\t\t}\n\t}, [isVisible, mounted]);\n\n\tuseScrollLock(isVisible);\n\n\tconst isDialogActive = mounted && !isExiting;\n\tuseEscapeKey(isDialogActive, () => setIsExiting(true));\n\tuseFocusTrap(isDialogActive, contentRef);\n\n\tfunction handleOverlayAnimationEnd(e: AnimationEvent<HTMLDivElement>) {\n\t\tif (e.target === e.currentTarget && isExiting) {\n\t\t\tsetIsExiting(false);\n\t\t\tsetMounted(false);\n\t\t\tmakeInvisible();\n\t\t}\n\t}\n\n\tif (!mounted) return null;\n\n\tconst className = [\n\t\t\"arkynModalContainer\",\n\t\tisExiting ? \"exiting\" : \"\",\n\t\tbaseClassName,\n\t]\n\t\t.filter(Boolean)\n\t\t.join(\" \");\n\n\treturn (\n\t\t<ModalProvider makeInvisible={() => setIsExiting(true)}>\n\t\t\t<aside className={className.trim()} {...rest}>\n\t\t\t\t<div\n\t\t\t\t\tclassName=\"arkynModalContainerOverlay\"\n\t\t\t\t\tonClick={() => setIsExiting(true)}\n\t\t\t\t\tonAnimationEnd={handleOverlayAnimationEnd}\n\t\t\t\t/>\n\t\t\t\t<div\n\t\t\t\t\tref={contentRef}\n\t\t\t\t\trole=\"dialog\"\n\t\t\t\t\taria-modal=\"true\"\n\t\t\t\t\ttabIndex={-1}\n\t\t\t\t\tclassName=\"arkynModalContainerContent\"\n\t\t\t\t>\n\t\t\t\t\t{children}\n\t\t\t\t</div>\n\t\t\t</aside>\n\t\t</ModalProvider>\n\t);\n}\n\nexport { ModalContainer };\n"],"mappings":";;;;;;;;AAiDA,SAAS,EAAe,GAA2B;CAClD,IAAM,EACL,cACA,kBACA,aACA,WAAW,IAAgB,IAC3B,GAAG,MACA,GAEE,CAAC,GAAS,KAAc,EAAS,CAAS,GAC1C,CAAC,GAAW,KAAgB,EAAS,EAAK,GAC1C,IAAa,EAAuB,IAAI;CAW9C,AATA,QAAgB;EACf,AAAI,KACH,EAAW,EAAI,GACf,EAAa,EAAK,KACR,KACV,EAAa,EAAI;CAEnB,GAAG,CAAC,GAAW,CAAO,CAAC,GAEvB,EAAc,CAAS;CAEvB,IAAM,IAAiB,KAAW,CAAC;CAEnC,AADA,EAAa,SAAsB,EAAa,EAAI,CAAC,GACrD,EAAa,GAAgB,CAAU;CAEvC,SAAS,EAA0B,GAAmC;EACrE,AAAI,EAAE,WAAW,EAAE,iBAAiB,MACnC,EAAa,EAAK,GAClB,EAAW,EAAK,GAChB,EAAc;CAEhB;CAYA,OAVK,IAWJ,kBAAC,GAAD;EAAe,qBAAqB,EAAa,EAAI;YACpD,kBAAC,SAAD;GAAO,WAVS;IACjB;IACA,IAAY,YAAY;IACxB;GACD,CAAC,CACC,OAAO,OAAO,CAAC,CACf,KAAK,GAIa,CAAA,CAAU,KAAK;GAAG,GAAI;aAAxC,CACC,kBAAC,OAAD;IACC,WAAU;IACV,eAAe,EAAa,EAAI;IAChC,gBAAgB;GAChB,CAAA,GACD,kBAAC,OAAD;IACC,KAAK;IACL,MAAK;IACL,cAAW;IACX,UAAU;IACV,WAAU;IAET;GACG,CAAA,CACC;;CACO,CAAA,IA5BK;AA8BtB"}
@@ -1,118 +1,158 @@
1
1
  import { useForm as e } from "../../hooks/useForm.js";
2
2
  import { IconRenderer as t } from "../../services/iconRenderer.js";
3
3
  import { FieldTemplate as n } from "../../services/fieldTemplate.js";
4
- import { MultiSelectChevron as r } from "./multiSelectChevron/index.js";
5
- import { MultiSelectContainer as i } from "./multiSelectContainer/index.js";
6
- import { MultiSelectContent as a } from "./multiSelectContent/index.js";
7
- import { MultiSelectMark as o } from "./multiSelectMark/index.js";
8
- import { MultiSelectOption as s } from "./multiSelectOption/index.js";
9
- import { MultiSelectOptionsContainer as ee } from "./multiSelectOptionsContainer/index.js";
10
- import { MultiSelectOverlay as te } from "./multiSelectOverlay/index.js";
11
- import { MultiSelectSpinner as c } from "./multiSelectSpinner/index.js";
12
- import { useId as l, useRef as u, useState as d } from "react";
13
- import { jsx as f, jsxs as p } from "react/jsx-runtime";
4
+ import { MultiSelectChevron as ee } from "./multiSelectChevron/index.js";
5
+ import { MultiSelectContainer as te } from "./multiSelectContainer/index.js";
6
+ import { MultiSelectContent as ne } from "./multiSelectContent/index.js";
7
+ import { MultiSelectMark as re } from "./multiSelectMark/index.js";
8
+ import { MultiSelectOption as ie } from "./multiSelectOption/index.js";
9
+ import { MultiSelectOptionsContainer as r } from "./multiSelectOptionsContainer/index.js";
10
+ import { MultiSelectOverlay as i } from "./multiSelectOverlay/index.js";
11
+ import { MultiSelectSpinner as a } from "./multiSelectSpinner/index.js";
12
+ import { useId as o, useRef as s, useState as c } from "react";
13
+ import { jsx as l, jsxs as u } from "react/jsx-runtime";
14
14
  //#region src/components/multiSelect/index.tsx
15
- function m(m) {
16
- let { name: h, options: g, className: _ = "", placeholder: v = "Selecione...", closeOnSelect: y = !1, defaultValue: b = [], errorMessage: ne, isLoading: x = !1, readOnly: S = !1, isSearchable: re = !1, id: ie, label: ae, showAsterisk: oe, leftIcon: C, onSearch: w, onChange: T, onBlur: E, notFoundText: D = "Sem opções disponíveis", onFocus: O, disabled: k = !1, prefix: A, size: j = "md", value: M, variant: N = "solid", unShowFieldTemplate: P = !1, orientation: F = "vertical" } = m, { fieldErrors: I } = e(), L = u(null), R = l(), se = ie || R, z = ne || I?.[h], B = !!z, V = k || x || S, H = {
15
+ function d(d) {
16
+ let { name: f, options: p, className: m = "", placeholder: h = "Selecione...", closeOnSelect: g = !1, defaultValue: _ = [], errorMessage: v, isLoading: y = !1, readOnly: b = !1, isSearchable: ae = !1, id: oe, label: se, showAsterisk: ce, leftIcon: x, onSearch: S, onChange: C, onBlur: le, notFoundText: ue = "Sem opções disponíveis", onFocus: de, disabled: fe = !1, prefix: w, size: T = "md", value: pe, variant: E = "solid", unShowFieldTemplate: D = !1, orientation: O = "vertical" } = d, { fieldErrors: k } = e(), A = s(null), j = s(null), M = o(), N = oe || M, P = `${N}-listbox`, F = v || k?.[f], I = !!F, L = fe || y || b, R = {
17
17
  md: 20,
18
18
  lg: 20
19
- }[j], [U, W] = d(""), [G, K] = d(!1), [q, J] = d(b), Y = M || q;
20
- function X(e) {
21
- return Y.includes(e);
19
+ }[T], [z, B] = c(""), [V, H] = c(!1), [U, W] = c(_), [G, K] = c(-1), q = pe || U;
20
+ function J(e) {
21
+ return q.includes(e);
22
22
  }
23
- function ce(e) {
24
- return g.find((t) => t.value === e)?.label || "";
23
+ function me(e) {
24
+ return p.find((t) => t.value === e)?.label || "";
25
25
  }
26
- function le() {
27
- V || !L?.current || G || (K(!0), L.current.focus(), O?.());
26
+ function Y(e) {
27
+ return `${P}-option-${e.replace(/[^a-zA-Z0-9_-]/g, "-")}`;
28
+ }
29
+ function X() {
30
+ L || !A?.current || V || (H(!0), K(-1), A.current.focus(), de?.());
28
31
  }
29
32
  function Z() {
30
- K(!1), E && L.current && L.current.blur();
33
+ H(!1), K(-1), le && A.current && A.current.blur();
31
34
  }
32
- function ue(e) {
33
- W(e), w && w(e);
35
+ function he(e) {
36
+ B(e), K(-1), S && S(e);
34
37
  }
35
38
  function Q(e) {
36
- X(e) ? (J(q.filter((t) => t !== e)), T && T(q.filter((t) => t !== e))) : (J([...q, e]), T && T([...q, e])), y && Z();
39
+ J(e) ? (W(U.filter((t) => t !== e)), C && C(U.filter((t) => t !== e))) : (W([...U, e]), C && C([...U, e])), g && Z();
40
+ }
41
+ let $ = p.filter((e) => !!(d.onSearch || !d.isSearchable || e.label.toLowerCase().includes(z.toLowerCase())));
42
+ function ge(e) {
43
+ if (L) return;
44
+ if (!V) {
45
+ (e.key === "Enter" || e.key === " " || e.key === "ArrowDown") && (e.preventDefault(), X(), e.key === "ArrowDown" && K(0));
46
+ return;
47
+ }
48
+ let t = e.target?.tagName === "INPUT", n = e.target?.tagName === "BUTTON";
49
+ switch (e.key) {
50
+ case "Escape":
51
+ e.preventDefault(), Z(), j.current?.focus();
52
+ break;
53
+ case "ArrowDown":
54
+ e.preventDefault(), K((e) => $.length === 0 ? -1 : e < 0 || e + 1 >= $.length ? 0 : e + 1);
55
+ break;
56
+ case "ArrowUp":
57
+ e.preventDefault(), K((e) => $.length === 0 ? -1 : e < 0 || e - 1 < 0 ? $.length - 1 : e - 1);
58
+ break;
59
+ case " ":
60
+ if (t || n) return;
61
+ e.preventDefault(), G >= 0 && G < $.length && Q($[G].value);
62
+ break;
63
+ case "Enter":
64
+ if (n) return;
65
+ e.preventDefault(), G >= 0 && G < $.length && Q($[G].value);
66
+ break;
67
+ default: break;
68
+ }
37
69
  }
38
- let $ = g.filter((e) => !!(m.onSearch || !m.isSearchable || e.label.toLowerCase().includes(U.toLowerCase())));
39
- return /* @__PURE__ */ f(n, {
40
- name: h,
41
- label: ae,
42
- showAsterisk: oe,
43
- className: _,
44
- errorMessage: z,
45
- unShowFieldTemplate: P,
46
- orientation: F,
47
- children: /* @__PURE__ */ p(i, {
48
- handleContainerFocus: le,
49
- disabled: V,
50
- isError: B,
51
- isFocused: G,
52
- isLoading: x,
53
- readOnly: S,
54
- size: j,
55
- variant: N,
56
- prefixExists: !!A,
57
- id: se,
70
+ let _e = G >= 0 && G < $.length ? Y($[G].value) : void 0;
71
+ return /* @__PURE__ */ l(n, {
72
+ name: f,
73
+ label: se,
74
+ showAsterisk: ce,
75
+ className: m,
76
+ errorMessage: F,
77
+ unShowFieldTemplate: D,
78
+ orientation: O,
79
+ children: /* @__PURE__ */ u(te, {
80
+ handleContainerFocus: X,
81
+ disabled: L,
82
+ isError: I,
83
+ isFocused: V,
84
+ isLoading: y,
85
+ readOnly: b,
86
+ size: T,
87
+ variant: E,
88
+ prefixExists: !!w,
89
+ id: N,
90
+ containerRef: j,
91
+ onContainerKeyDown: ge,
92
+ tabIndex: L ? -1 : 0,
93
+ ariaControls: P,
94
+ ariaActiveDescendant: _e,
58
95
  children: [
59
- /* @__PURE__ */ f("input", {
60
- ref: L,
61
- name: h,
62
- value: JSON.stringify(Y),
96
+ /* @__PURE__ */ l("input", {
97
+ ref: A,
98
+ name: f,
99
+ value: JSON.stringify(q),
63
100
  type: "hidden"
64
101
  }),
65
- /* @__PURE__ */ f(t, {
66
- iconSize: H,
67
- icon: A,
102
+ /* @__PURE__ */ l(t, {
103
+ iconSize: R,
104
+ icon: w,
68
105
  className: "prefix"
69
106
  }),
70
- C && /* @__PURE__ */ f(C, {
71
- size: H,
107
+ x && /* @__PURE__ */ l(x, {
108
+ size: R,
72
109
  strokeWidth: 2.5
73
110
  }),
74
- /* @__PURE__ */ p(a, {
75
- size: j,
76
- children: [Y.map((e) => /* @__PURE__ */ f(o, {
77
- label: ce(e),
111
+ /* @__PURE__ */ u(ne, {
112
+ size: T,
113
+ children: [q.map((e) => /* @__PURE__ */ l(re, {
114
+ label: me(e),
78
115
  value: e,
79
116
  handleChangeValue: Q,
80
- disabled: V
81
- }, e)), Y.length <= 0 && /* @__PURE__ */ f("p", { children: v })]
117
+ disabled: L
118
+ }, e)), q.length <= 0 && /* @__PURE__ */ l("p", { children: h })]
82
119
  }),
83
- /* @__PURE__ */ p(ee, {
84
- isFocused: G,
85
- isSearchable: re,
86
- search: U,
87
- onSearch: ue,
88
- children: [$.map(({ label: e, value: t }) => /* @__PURE__ */ f(s, {
120
+ /* @__PURE__ */ u(r, {
121
+ id: P,
122
+ isFocused: V,
123
+ isSearchable: ae,
124
+ search: z,
125
+ onSearch: he,
126
+ children: [$.map(({ label: e, value: t }, n) => /* @__PURE__ */ l(ie, {
127
+ id: Y(t),
89
128
  label: e,
90
129
  value: t,
91
- size: j,
130
+ size: T,
131
+ isHighlighted: n === G,
92
132
  handleChangeValue: Q,
93
- optionHasSelected: X
94
- }, t)), $.length <= 0 && /* @__PURE__ */ f("p", { children: D })]
133
+ optionHasSelected: J
134
+ }, t)), $.length <= 0 && /* @__PURE__ */ l("p", { children: ue })]
95
135
  }),
96
- /* @__PURE__ */ f(r, {
97
- disabled: V,
98
- isFocused: G,
99
- readOnly: S,
100
- iconSize: H,
101
- isLoading: x
136
+ /* @__PURE__ */ l(ee, {
137
+ disabled: L,
138
+ isFocused: V,
139
+ readOnly: b,
140
+ iconSize: R,
141
+ isLoading: y
102
142
  }),
103
- /* @__PURE__ */ f(c, {
104
- iconSize: H,
105
- isLoading: x
143
+ /* @__PURE__ */ l(a, {
144
+ iconSize: R,
145
+ isLoading: y
106
146
  }),
107
- /* @__PURE__ */ f(te, {
147
+ /* @__PURE__ */ l(i, {
108
148
  handleBlur: Z,
109
- isFocused: G
149
+ isFocused: V
110
150
  })
111
151
  ]
112
152
  })
113
153
  });
114
154
  }
115
155
  //#endregion
116
- export { m as MultiSelect };
156
+ export { d as MultiSelect };
117
157
 
118
158
  //# sourceMappingURL=index.js.map