@jbpark/ui-kit 3.3.0 → 3.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/dist/Button.d.mts +12 -0
  2. package/dist/Button.d.mts.map +1 -1
  3. package/dist/Button.mjs +5 -2
  4. package/dist/Button.mjs.map +1 -1
  5. package/dist/components/atoms/checkbox/checkbox.d.mts +7 -3
  6. package/dist/components/atoms/checkbox/checkbox.d.mts.map +1 -1
  7. package/dist/components/atoms/checkbox/checkbox.mjs +17 -9
  8. package/dist/components/atoms/checkbox/checkbox.mjs.map +1 -1
  9. package/dist/components/atoms/checkbox/group.d.mts +8 -9
  10. package/dist/components/atoms/checkbox/group.d.mts.map +1 -1
  11. package/dist/components/atoms/checkbox/group.mjs +11 -12
  12. package/dist/components/atoms/checkbox/group.mjs.map +1 -1
  13. package/dist/components/atoms/color-picker.d.mts +6 -2
  14. package/dist/components/atoms/color-picker.d.mts.map +1 -1
  15. package/dist/components/atoms/color-picker.mjs +18 -10
  16. package/dist/components/atoms/color-picker.mjs.map +1 -1
  17. package/dist/components/atoms/date-picker.d.mts +2 -0
  18. package/dist/components/atoms/date-picker.d.mts.map +1 -1
  19. package/dist/components/atoms/date-picker.mjs +15 -9
  20. package/dist/components/atoms/date-picker.mjs.map +1 -1
  21. package/dist/components/atoms/float-button/back-top.d.mts +1 -0
  22. package/dist/components/atoms/float-button/back-top.d.mts.map +1 -1
  23. package/dist/components/atoms/float-button/back-top.mjs +7 -4
  24. package/dist/components/atoms/float-button/back-top.mjs.map +1 -1
  25. package/dist/components/atoms/input/input.d.mts +2 -1
  26. package/dist/components/atoms/input/input.d.mts.map +1 -1
  27. package/dist/components/atoms/input/input.mjs +5 -2
  28. package/dist/components/atoms/input/input.mjs.map +1 -1
  29. package/dist/components/atoms/input/search.d.mts +2 -0
  30. package/dist/components/atoms/input/search.d.mts.map +1 -1
  31. package/dist/components/atoms/input/search.mjs +12 -10
  32. package/dist/components/atoms/input/search.mjs.map +1 -1
  33. package/dist/components/atoms/option-group.d.mts +15 -0
  34. package/dist/components/atoms/option-group.d.mts.map +1 -0
  35. package/dist/components/atoms/option-group.mjs +9 -0
  36. package/dist/components/atoms/option-group.mjs.map +1 -0
  37. package/dist/components/atoms/popover.d.mts +6 -0
  38. package/dist/components/atoms/popover.d.mts.map +1 -1
  39. package/dist/components/atoms/popover.mjs +75 -160
  40. package/dist/components/atoms/popover.mjs.map +1 -1
  41. package/dist/components/atoms/radio/group.d.mts +6 -9
  42. package/dist/components/atoms/radio/group.d.mts.map +1 -1
  43. package/dist/components/atoms/radio/group.mjs +26 -23
  44. package/dist/components/atoms/radio/group.mjs.map +1 -1
  45. package/dist/components/atoms/radio/radio.d.mts +7 -3
  46. package/dist/components/atoms/radio/radio.d.mts.map +1 -1
  47. package/dist/components/atoms/radio/radio.mjs +18 -11
  48. package/dist/components/atoms/radio/radio.mjs.map +1 -1
  49. package/dist/components/atoms/select.d.mts +1 -1
  50. package/dist/components/atoms/select.d.mts.map +1 -1
  51. package/dist/components/atoms/select.mjs.map +1 -1
  52. package/dist/components/atoms/skeleton/button.mjs +2 -2
  53. package/dist/components/atoms/skeleton/button.mjs.map +1 -1
  54. package/dist/components/atoms/skeleton/skeleton.mjs +2 -2
  55. package/dist/components/atoms/skeleton/skeleton.mjs.map +1 -1
  56. package/dist/components/atoms/spin.d.mts +1 -2
  57. package/dist/components/atoms/spin.d.mts.map +1 -1
  58. package/dist/components/atoms/spin.mjs +12 -10
  59. package/dist/components/atoms/spin.mjs.map +1 -1
  60. package/dist/components/atoms/switch.d.mts.map +1 -1
  61. package/dist/components/atoms/switch.mjs +6 -8
  62. package/dist/components/atoms/switch.mjs.map +1 -1
  63. package/dist/components/molecules/marquees/item.d.mts.map +1 -1
  64. package/dist/components/molecules/marquees/item.mjs +6 -11
  65. package/dist/components/molecules/marquees/item.mjs.map +1 -1
  66. package/dist/components/molecules/upload.d.mts.map +1 -1
  67. package/dist/components/molecules/upload.mjs +19 -27
  68. package/dist/components/molecules/upload.mjs.map +1 -1
  69. package/dist/components/organisms/list/list.mjs +3 -3
  70. package/dist/components/organisms/list/list.mjs.map +1 -1
  71. package/dist/components/organisms/toast.d.mts.map +1 -1
  72. package/dist/components/organisms/toast.mjs +2 -5
  73. package/dist/components/organisms/toast.mjs.map +1 -1
  74. package/dist/core/badge.d.mts +1 -1
  75. package/dist/core/button.d.mts +2 -2
  76. package/dist/core/radio-group.d.mts +5 -1
  77. package/dist/core/radio-group.d.mts.map +1 -1
  78. package/dist/core/radio-group.mjs +7 -1
  79. package/dist/core/radio-group.mjs.map +1 -1
  80. package/dist/style.css +8 -123
  81. package/package.json +2 -3
@@ -1 +1 @@
1
- {"version":3,"file":"input.mjs","names":["input"],"sources":["../../../../src/components/atoms/input/input.tsx"],"sourcesContent":["import { input } from '@repo/ui/core';\n\nconst { Input: Core } = input;\n\nconst Input = ({ ...props }: React.ComponentPropsWithoutRef<'input'>) => {\n return <Core {...props} />;\n};\n\nexport default Input;\n"],"mappings":";;;;AAEA,MAAM,EAAE,OAAO,SAASA;AAExB,MAAM,SAAS,EAAE,GAAG,YAAqD;AACvE,QAAO,oBAAC,QAAK,GAAI,QAAS"}
1
+ {"version":3,"file":"input.mjs","names":["input"],"sources":["../../../../src/components/atoms/input/input.tsx"],"sourcesContent":["import { input } from '@repo/ui/core';\n\nconst { Input: Core } = input;\n\nconst Input = ({ ref, ...props }: React.ComponentPropsWithRef<'input'>) => {\n return <Core ref={ref} {...props} />;\n};\n\nexport default Input;\n"],"mappings":";;;;AAEA,MAAM,EAAE,OAAO,SAASA;AAExB,MAAM,SAAS,EAAE,KAAK,GAAG,YAAkD;AACzE,QAAO,oBAAC;EAAU;EAAK,GAAI;GAAS"}
@@ -16,8 +16,10 @@ declare const Search: {
16
16
  className,
17
17
  defaultValue,
18
18
  value,
19
+ disabled,
19
20
  allowClear,
20
21
  onChange,
22
+ onKeyDown: _onKeyDown,
21
23
  onSearch: _onSearch,
22
24
  ...props
23
25
  }: Props): react_jsx_runtime0.JSX.Element;
@@ -1 +1 @@
1
- {"version":3,"file":"search.d.mts","names":[],"sources":["../../../../src/components/atoms/input/search.tsx"],"mappings":";;;UAaiB,KAAA,SAAc,KAAA,CAAM,qBAAA;EACnC,UAAA;EACA,QAAA,IACE,CAAA,EAAG,KAAA,CAAM,WAAA,CAAY,gBAAA;IAAsB,MAAA;MAAU,KAAA;IAAA;EAAA;EAEvD,QAAA,IAAY,KAAA;AAAA;AAAA,cAGR,MAAA;EAAA;;;;;;;;;KASH,KAAA,GAAK,kBAAA,CAAA,GAAA,CAAA,OAAA"}
1
+ {"version":3,"file":"search.d.mts","names":[],"sources":["../../../../src/components/atoms/input/search.tsx"],"mappings":";;;UAciB,KAAA,SAAc,KAAA,CAAM,qBAAA;EACnC,UAAA;EACA,QAAA,IACE,CAAA,EAAG,KAAA,CAAM,WAAA,CAAY,gBAAA;IAAsB,MAAA;MAAU,KAAA;IAAA;EAAA;EAEvD,QAAA,IAAY,KAAA;AAAA;AAAA,cAGR,MAAA;EAAA;;;;;;;;;;;KAWH,KAAA,GAAK,kBAAA,CAAA,GAAA,CAAA,OAAA"}
@@ -6,16 +6,13 @@ import Button from "../../../Button.mjs";
6
6
  import { CircleX, Search } from "lucide-react";
7
7
  import { useRef, useState } from "react";
8
8
  import { jsx, jsxs } from "react/jsx-runtime";
9
+ import { useMergedRef } from "@jbpark/use-hooks";
9
10
 
10
11
  //#region src/components/atoms/input/search.tsx
11
12
  const { Input: Core } = input_exports;
12
- const Search$1 = ({ ref, className, defaultValue, value, allowClear = true, onChange, onSearch: _onSearch, ...props }) => {
13
+ const Search$1 = ({ ref, className, defaultValue, value, disabled, allowClear = true, onChange, onKeyDown: _onKeyDown, onSearch: _onSearch, ...props }) => {
13
14
  const inputRef = useRef(null);
14
- const setRefs = (node) => {
15
- inputRef.current = node;
16
- if (typeof ref === "function") ref(node);
17
- else if (ref) ref.current = node;
18
- };
15
+ const mergedRef = useMergedRef(inputRef, ref);
19
16
  const [uncontrolledHasValue, setUncontrolledHasValue] = useState(!!defaultValue);
20
17
  const hasValue = value !== void 0 ? !!value : uncontrolledHasValue;
21
18
  const onClear = () => {
@@ -27,6 +24,7 @@ const Search$1 = ({ ref, className, defaultValue, value, allowClear = true, onCh
27
24
  onChange?.({ target: { value: "" } });
28
25
  };
29
26
  const onSearch = () => {
27
+ if (disabled) return;
30
28
  if (inputRef.current) _onSearch?.(inputRef.current.value);
31
29
  };
32
30
  return /* @__PURE__ */ jsxs("div", {
@@ -34,10 +32,12 @@ const Search$1 = ({ ref, className, defaultValue, value, allowClear = true, onCh
34
32
  children: [/* @__PURE__ */ jsxs("div", {
35
33
  className: cn("relative grow", "inline-flex items-center"),
36
34
  children: [/* @__PURE__ */ jsx(Core, {
37
- ref: setRefs,
35
+ ...props,
36
+ ref: mergedRef,
38
37
  inputMode: "search",
39
38
  type: "search",
40
39
  enterKeyHint: "search",
40
+ disabled,
41
41
  className: cn("rounded-r-none", "[&::-webkit-search-cancel-button]:hidden", "[&::-webkit-search-decoration]:hidden"),
42
42
  value,
43
43
  defaultValue,
@@ -46,18 +46,20 @@ const Search$1 = ({ ref, className, defaultValue, value, allowClear = true, onCh
46
46
  onChange?.(e);
47
47
  },
48
48
  onKeyDown: (e) => {
49
+ _onKeyDown?.(e);
49
50
  if (e.key === "Enter") onSearch();
50
- },
51
- ...props
51
+ }
52
52
  }), /* @__PURE__ */ jsx("button", {
53
53
  type: "button",
54
54
  "aria-label": "지우기",
55
- className: cn("absolute right-2", "shrink-0 cursor-pointer", (!allowClear || !hasValue) && "hidden"),
55
+ disabled,
56
+ className: cn("absolute right-2", "shrink-0 cursor-pointer", "disabled:cursor-not-allowed disabled:opacity-50", (!allowClear || !hasValue) && "hidden"),
56
57
  onClick: onClear,
57
58
  children: /* @__PURE__ */ jsx(CircleX, { className: "size-4" })
58
59
  })]
59
60
  }), /* @__PURE__ */ jsx(Button, {
60
61
  icon: /* @__PURE__ */ jsx(Search, {}),
62
+ disabled,
61
63
  className: cn("rounded-l-none", "size-9"),
62
64
  onClick: onSearch
63
65
  })]
@@ -1 +1 @@
1
- {"version":3,"file":"search.mjs","names":["input","Search","SearchOutlined"],"sources":["../../../../src/components/atoms/input/search.tsx"],"sourcesContent":["'use client';\n\nimport { useRef, useState } from 'react';\n\nimport { CircleX, Search as SearchOutlined } from 'lucide-react';\n\nimport { input } from '@repo/ui/core';\nimport { cn } from '@repo/ui/utils';\n\nimport Button from '../button';\n\nconst { Input: Core } = input;\n\nexport interface Props extends React.ComponentPropsWithRef<'input'> {\n allowClear?: boolean;\n onChange?: (\n e: React.ChangeEvent<HTMLInputElement> | { target: { value: string } },\n ) => void;\n onSearch?: (value: string) => void;\n}\n\nconst Search = ({\n ref,\n className,\n defaultValue,\n value,\n allowClear = true,\n onChange,\n onSearch: _onSearch,\n ...props\n}: Props) => {\n const inputRef = useRef<HTMLInputElement>(null);\n\n const setRefs = (node: HTMLInputElement | null) => {\n inputRef.current = node;\n\n if (typeof ref === 'function') {\n ref(node);\n } else if (ref) {\n ref.current = node;\n }\n };\n\n const [uncontrolledHasValue, setUncontrolledHasValue] =\n useState(!!defaultValue);\n const hasValue = value !== undefined ? !!value : uncontrolledHasValue;\n\n const onClear = () => {\n if (!inputRef.current) {\n return;\n }\n\n if (value === undefined) {\n inputRef.current.value = '';\n setUncontrolledHasValue(false);\n }\n\n const event = {\n target: { value: '' },\n } as React.ChangeEvent<HTMLInputElement>;\n onChange?.(event);\n };\n\n const onSearch = () => {\n if (inputRef.current) {\n _onSearch?.(inputRef.current.value);\n }\n };\n\n return (\n <div\n className={cn(\n 'flex items-center',\n 'rounded-md',\n className,\n //\n )}\n >\n <div\n className={cn(\n 'relative grow',\n 'inline-flex items-center',\n //\n )}\n >\n <Core\n ref={setRefs}\n inputMode=\"search\"\n type=\"search\"\n enterKeyHint=\"search\"\n className={cn(\n 'rounded-r-none',\n '[&::-webkit-search-cancel-button]:hidden',\n '[&::-webkit-search-decoration]:hidden',\n //\n )}\n value={value}\n defaultValue={defaultValue}\n onChange={e => {\n if (value === undefined) {\n setUncontrolledHasValue(!!e.target.value);\n }\n onChange?.(e);\n }}\n onKeyDown={e => {\n if (e.key === 'Enter') {\n onSearch();\n }\n }}\n {...props}\n />\n <button\n type=\"button\"\n aria-label=\"지우기\"\n className={cn(\n 'absolute right-2',\n 'shrink-0 cursor-pointer',\n (!allowClear || !hasValue) && 'hidden',\n )}\n onClick={onClear}\n >\n <CircleX className=\"size-4\" />\n </button>\n </div>\n <Button\n icon={<SearchOutlined />}\n className={cn(\n 'rounded-l-none',\n 'size-9',\n //\n )}\n onClick={onSearch}\n />\n </div>\n );\n};\n\nSearch.displayName = 'Search';\n\nexport default Search;\n"],"mappings":";;;;;;;;;;AAWA,MAAM,EAAE,OAAO,SAASA;AAUxB,MAAMC,YAAU,EACd,KACA,WACA,cACA,OACA,aAAa,MACb,UACA,UAAU,WACV,GAAG,YACQ;CACX,MAAM,WAAW,OAAyB,KAAK;CAE/C,MAAM,WAAW,SAAkC;AACjD,WAAS,UAAU;AAEnB,MAAI,OAAO,QAAQ,WACjB,KAAI,KAAK;WACA,IACT,KAAI,UAAU;;CAIlB,MAAM,CAAC,sBAAsB,2BAC3B,SAAS,CAAC,CAAC,aAAa;CAC1B,MAAM,WAAW,UAAU,SAAY,CAAC,CAAC,QAAQ;CAEjD,MAAM,gBAAgB;AACpB,MAAI,CAAC,SAAS,QACZ;AAGF,MAAI,UAAU,QAAW;AACvB,YAAS,QAAQ,QAAQ;AACzB,2BAAwB,MAAM;;AAMhC,aAHc,EACZ,QAAQ,EAAE,OAAO,IAAI,EACtB,CACgB;;CAGnB,MAAM,iBAAiB;AACrB,MAAI,SAAS,QACX,aAAY,SAAS,QAAQ,MAAM;;AAIvC,QACE,qBAAC;EACC,WAAW,GACT,qBACA,cACA,UAED;aAED,qBAAC;GACC,WAAW,GACT,iBACA,2BAED;cAED,oBAAC;IACC,KAAK;IACL,WAAU;IACV,MAAK;IACL,cAAa;IACb,WAAW,GACT,kBACA,4CACA,wCAED;IACM;IACO;IACd,WAAU,MAAK;AACb,SAAI,UAAU,OACZ,yBAAwB,CAAC,CAAC,EAAE,OAAO,MAAM;AAE3C,gBAAW,EAAE;;IAEf,YAAW,MAAK;AACd,SAAI,EAAE,QAAQ,QACZ,WAAU;;IAGd,GAAI;KACJ,EACF,oBAAC;IACC,MAAK;IACL,cAAW;IACX,WAAW,GACT,oBACA,4BACC,CAAC,cAAc,CAAC,aAAa,SAC/B;IACD,SAAS;cAET,oBAAC,WAAQ,WAAU,WAAW;KACvB;IACL,EACN,oBAAC;GACC,MAAM,oBAACC,WAAiB;GACxB,WAAW,GACT,kBACA,SAED;GACD,SAAS;IACT;GACE;;AAIV,SAAO,cAAc"}
1
+ {"version":3,"file":"search.mjs","names":["input","Search","SearchOutlined"],"sources":["../../../../src/components/atoms/input/search.tsx"],"sourcesContent":["'use client';\n\nimport { useRef, useState } from 'react';\n\nimport { useMergedRef } from '@jbpark/use-hooks';\nimport { CircleX, Search as SearchOutlined } from 'lucide-react';\n\nimport { input } from '@repo/ui/core';\nimport { cn } from '@repo/ui/utils';\n\nimport Button from '../button';\n\nconst { Input: Core } = input;\n\nexport interface Props extends React.ComponentPropsWithRef<'input'> {\n allowClear?: boolean;\n onChange?: (\n e: React.ChangeEvent<HTMLInputElement> | { target: { value: string } },\n ) => void;\n onSearch?: (value: string) => void;\n}\n\nconst Search = ({\n ref,\n className,\n defaultValue,\n value,\n disabled,\n allowClear = true,\n onChange,\n onKeyDown: _onKeyDown,\n onSearch: _onSearch,\n ...props\n}: Props) => {\n const inputRef = useRef<HTMLInputElement>(null);\n\n const mergedRef = useMergedRef(inputRef, ref);\n\n const [uncontrolledHasValue, setUncontrolledHasValue] =\n useState(!!defaultValue);\n const hasValue = value !== undefined ? !!value : uncontrolledHasValue;\n\n const onClear = () => {\n if (!inputRef.current) {\n return;\n }\n\n if (value === undefined) {\n inputRef.current.value = '';\n setUncontrolledHasValue(false);\n }\n\n onChange?.({ target: { value: '' } });\n };\n\n const onSearch = () => {\n if (disabled) {\n return;\n }\n if (inputRef.current) {\n _onSearch?.(inputRef.current.value);\n }\n };\n\n return (\n <div\n className={cn(\n 'flex items-center',\n 'rounded-md',\n className,\n //\n )}\n >\n <div\n className={cn(\n 'relative grow',\n 'inline-flex items-center',\n //\n )}\n >\n <Core\n {...props}\n ref={mergedRef}\n inputMode=\"search\"\n type=\"search\"\n enterKeyHint=\"search\"\n disabled={disabled}\n className={cn(\n 'rounded-r-none',\n '[&::-webkit-search-cancel-button]:hidden',\n '[&::-webkit-search-decoration]:hidden',\n //\n )}\n value={value}\n defaultValue={defaultValue}\n onChange={e => {\n if (value === undefined) {\n setUncontrolledHasValue(!!e.target.value);\n }\n onChange?.(e);\n }}\n onKeyDown={e => {\n _onKeyDown?.(e);\n if (e.key === 'Enter') {\n onSearch();\n }\n }}\n />\n <button\n type=\"button\"\n aria-label=\"지우기\"\n disabled={disabled}\n className={cn(\n 'absolute right-2',\n 'shrink-0 cursor-pointer',\n 'disabled:cursor-not-allowed disabled:opacity-50',\n (!allowClear || !hasValue) && 'hidden',\n )}\n onClick={onClear}\n >\n <CircleX className=\"size-4\" />\n </button>\n </div>\n <Button\n icon={<SearchOutlined />}\n disabled={disabled}\n className={cn(\n 'rounded-l-none',\n 'size-9',\n //\n )}\n onClick={onSearch}\n />\n </div>\n );\n};\n\nSearch.displayName = 'Search';\n\nexport default Search;\n"],"mappings":";;;;;;;;;;;AAYA,MAAM,EAAE,OAAO,SAASA;AAUxB,MAAMC,YAAU,EACd,KACA,WACA,cACA,OACA,UACA,aAAa,MACb,UACA,WAAW,YACX,UAAU,WACV,GAAG,YACQ;CACX,MAAM,WAAW,OAAyB,KAAK;CAE/C,MAAM,YAAY,aAAa,UAAU,IAAI;CAE7C,MAAM,CAAC,sBAAsB,2BAC3B,SAAS,CAAC,CAAC,aAAa;CAC1B,MAAM,WAAW,UAAU,SAAY,CAAC,CAAC,QAAQ;CAEjD,MAAM,gBAAgB;AACpB,MAAI,CAAC,SAAS,QACZ;AAGF,MAAI,UAAU,QAAW;AACvB,YAAS,QAAQ,QAAQ;AACzB,2BAAwB,MAAM;;AAGhC,aAAW,EAAE,QAAQ,EAAE,OAAO,IAAI,EAAE,CAAC;;CAGvC,MAAM,iBAAiB;AACrB,MAAI,SACF;AAEF,MAAI,SAAS,QACX,aAAY,SAAS,QAAQ,MAAM;;AAIvC,QACE,qBAAC;EACC,WAAW,GACT,qBACA,cACA,UAED;aAED,qBAAC;GACC,WAAW,GACT,iBACA,2BAED;cAED,oBAAC;IACC,GAAI;IACJ,KAAK;IACL,WAAU;IACV,MAAK;IACL,cAAa;IACH;IACV,WAAW,GACT,kBACA,4CACA,wCAED;IACM;IACO;IACd,WAAU,MAAK;AACb,SAAI,UAAU,OACZ,yBAAwB,CAAC,CAAC,EAAE,OAAO,MAAM;AAE3C,gBAAW,EAAE;;IAEf,YAAW,MAAK;AACd,kBAAa,EAAE;AACf,SAAI,EAAE,QAAQ,QACZ,WAAU;;KAGd,EACF,oBAAC;IACC,MAAK;IACL,cAAW;IACD;IACV,WAAW,GACT,oBACA,2BACA,oDACC,CAAC,cAAc,CAAC,aAAa,SAC/B;IACD,SAAS;cAET,oBAAC,WAAQ,WAAU,WAAW;KACvB;IACL,EACN,oBAAC;GACC,MAAM,oBAACC,WAAiB;GACd;GACV,WAAW,GACT,kBACA,SAED;GACD,SAAS;IACT;GACE;;AAIV,SAAO,cAAc"}
@@ -0,0 +1,15 @@
1
+ //#region src/components/atoms/option-group.d.ts
2
+ type OptionValue = string | number | boolean;
3
+ interface Option {
4
+ label: string;
5
+ value: OptionValue;
6
+ disabled?: boolean;
7
+ }
8
+ type Options = string[] | number[] | boolean[] | Option[];
9
+ interface OptionGroupClassNames {
10
+ wrapper?: string;
11
+ item?: string;
12
+ }
13
+ //#endregion
14
+ export { OptionGroupClassNames, OptionValue, Options };
15
+ //# sourceMappingURL=option-group.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"option-group.d.mts","names":[],"sources":["../../../src/components/atoms/option-group.ts"],"mappings":";KAAY,WAAA;AAAA,UAEK,MAAA;EACf,KAAA;EACA,KAAA,EAAO,WAAA;EACP,QAAA;AAAA;AAAA,KAGU,OAAA,qCAA4C,MAAA;AAAA,UAEvC,qBAAA;EACf,OAAA;EACA,IAAA;AAAA"}
@@ -0,0 +1,9 @@
1
+ //#region src/components/atoms/option-group.ts
2
+ const normalizeOptions = (options) => options.map((item) => typeof item === "object" ? item : {
3
+ label: `${item}`,
4
+ value: item
5
+ });
6
+
7
+ //#endregion
8
+ export { normalizeOptions };
9
+ //# sourceMappingURL=option-group.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"option-group.mjs","names":[],"sources":["../../../src/components/atoms/option-group.ts"],"sourcesContent":["export type OptionValue = string | number | boolean;\n\nexport interface Option {\n label: string;\n value: OptionValue;\n disabled?: boolean;\n}\n\nexport type Options = string[] | number[] | boolean[] | Option[];\n\nexport interface OptionGroupClassNames {\n wrapper?: string;\n item?: string;\n}\n\nexport const normalizeOptions = (options: Options): Option[] =>\n options.map(item =>\n typeof item === 'object'\n ? item\n : {\n label: `${item}`,\n value: item,\n },\n );\n"],"mappings":";AAeA,MAAa,oBAAoB,YAC/B,QAAQ,KAAI,SACV,OAAO,SAAS,WACZ,OACA;CACE,OAAO,GAAG;CACV,OAAO;CACR,CACN"}
@@ -6,6 +6,9 @@ interface Props extends Omit<React.ComponentPropsWithoutRef<'div'>, 'title' | 'c
6
6
  title?: React.ReactNode;
7
7
  placement?: Placement;
8
8
  content: React.ReactNode;
9
+ open?: boolean;
10
+ defaultOpen?: boolean;
11
+ onOpenChange?: (open: boolean) => void;
9
12
  }
10
13
  declare const Popover: ({
11
14
  title,
@@ -13,6 +16,9 @@ declare const Popover: ({
13
16
  className,
14
17
  content,
15
18
  children,
19
+ open: _open,
20
+ defaultOpen,
21
+ onOpenChange,
16
22
  ...props
17
23
  }: Props) => react_jsx_runtime0.JSX.Element;
18
24
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"popover.d.mts","names":[],"sources":["../../../src/components/atoms/popover.tsx"],"mappings":";;;KAOK,SAAA;AAAA,UAcK,KAAA,SAAc,IAAA,CACtB,KAAA,CAAM,wBAAA;EAGN,KAAA,GAAQ,KAAA,CAAM,SAAA;EACd,SAAA,GAAY,SAAA;EACZ,OAAA,EAAS,KAAA,CAAM,SAAA;AAAA;AAAA,cAkNX,OAAA;EAAW,KAAA;EAAA,SAAA;EAAA,SAAA;EAAA,OAAA;EAAA,QAAA;EAAA,GAAA;AAAA,GAOd,KAAA,KAAK,kBAAA,CAAA,GAAA,CAAA,OAAA"}
1
+ {"version":3,"file":"popover.d.mts","names":[],"sources":["../../../src/components/atoms/popover.tsx"],"mappings":";;;KASK,SAAA;AAAA,UAcY,KAAA,SAAc,IAAA,CAC7B,KAAA,CAAM,wBAAA;EAGN,KAAA,GAAQ,KAAA,CAAM,SAAA;EACd,SAAA,GAAY,SAAA;EACZ,OAAA,EAAS,KAAA,CAAM,SAAA;EACf,IAAA;EACA,WAAA;EACA,YAAA,IAAgB,IAAA;AAAA;AAAA,cA4GZ,OAAA;EAAW,KAAA;EAAA,SAAA;EAAA,SAAA;EAAA,OAAA;EAAA,QAAA;EAAA,IAAA,EAAA,KAAA;EAAA,WAAA;EAAA,YAAA;EAAA,GAAA;AAAA,GAUd,KAAA,KAAK,kBAAA,CAAA,GAAA,CAAA,OAAA"}
@@ -2,6 +2,7 @@ import { cn, renderConditional } from "../../utils.mjs";
2
2
  import { popover_exports } from "../../core/popover.mjs";
3
3
  import Typography from "../../Typography.mjs";
4
4
  import { jsx, jsxs } from "react/jsx-runtime";
5
+ import { useControllableState } from "@jbpark/use-hooks";
5
6
 
6
7
  //#region src/components/atoms/popover.tsx
7
8
  const { Popover: CorePopover, PopoverContent, PopoverTrigger } = popover_exports;
@@ -61,167 +62,81 @@ const vBorderShape = "before:border-l-[9px] before:border-r-[9px] before:border-
61
62
  const hBorderShape = "before:border-t-[9px] before:border-b-[9px] before:border-t-transparent before:border-b-transparent";
62
63
  const vFillShape = "after:border-l-8 after:border-r-8 after:border-l-transparent after:border-r-transparent";
63
64
  const hFillShape = "after:border-t-8 after:border-b-8 after:border-t-transparent after:border-b-transparent";
64
- const topBorder = "before:border-t-[9px] before:border-t-border";
65
- const bottomBorder = "before:border-b-[9px] before:border-b-border";
66
- const leftBorder = "before:border-l-[9px] before:border-l-border";
67
- const rightBorder = "before:border-r-[9px] before:border-r-border";
68
- const topFill = "after:border-t-8 after:border-t-popover";
69
- const bottomFill = "after:border-b-8 after:border-b-popover";
70
- const leftFill = "after:border-l-8 after:border-l-popover";
71
- const rightFill = "after:border-r-8 after:border-r-popover";
72
- const arrowStyles = {
73
- top: [
74
- "absolute left-1/2 -translate-x-1/2 top-full",
75
- beforeBase,
76
- "before:top-0 before:left-1/2 before:-translate-x-1/2",
77
- vBorderShape,
78
- topBorder,
79
- afterBase,
80
- "after:-top-px after:left-1/2 after:-translate-x-1/2",
81
- vFillShape,
82
- topFill
83
- ].join(" "),
84
- topLeft: [
85
- "absolute left-4 top-full",
86
- beforeBase,
87
- "before:top-0 before:left-0",
88
- vBorderShape,
89
- topBorder,
90
- afterBase,
91
- "after:-top-px after:left-px",
92
- vFillShape,
93
- topFill
94
- ].join(" "),
95
- topRight: [
96
- "absolute right-4 top-full",
97
- beforeBase,
98
- "before:top-0 before:right-0",
99
- vBorderShape,
100
- topBorder,
101
- afterBase,
102
- "after:-top-px after:right-px",
103
- vFillShape,
104
- topFill
105
- ].join(" "),
106
- bottom: [
107
- "absolute left-1/2 -translate-x-1/2 bottom-full",
108
- beforeBase,
109
- "before:bottom-0 before:left-1/2 before:-translate-x-1/2",
110
- vBorderShape,
111
- bottomBorder,
112
- afterBase,
113
- "after:-bottom-px after:left-1/2 after:-translate-x-1/2",
114
- vFillShape,
115
- bottomFill
116
- ].join(" "),
117
- bottomLeft: [
118
- "absolute left-4 bottom-full",
119
- beforeBase,
120
- "before:bottom-0 before:left-0",
121
- vBorderShape,
122
- bottomBorder,
123
- afterBase,
124
- "after:-bottom-px after:left-px",
125
- vFillShape,
126
- bottomFill
127
- ].join(" "),
128
- bottomRight: [
129
- "absolute right-4 bottom-full",
130
- beforeBase,
131
- "before:bottom-0 before:right-0",
132
- vBorderShape,
133
- bottomBorder,
134
- afterBase,
135
- "after:-bottom-px after:right-px",
136
- vFillShape,
137
- bottomFill
138
- ].join(" "),
139
- left: [
140
- "absolute top-1/2 -translate-y-1/2 left-full",
141
- beforeBase,
142
- "before:left-0 before:top-1/2 before:-translate-y-1/2",
143
- hBorderShape,
144
- leftBorder,
145
- afterBase,
146
- "after:-left-px after:top-1/2 after:-translate-y-1/2",
147
- hFillShape,
148
- leftFill
149
- ].join(" "),
150
- leftTop: [
151
- "absolute top-4 left-full",
152
- beforeBase,
153
- "before:left-0 before:top-0",
154
- hBorderShape,
155
- leftBorder,
156
- afterBase,
157
- "after:-left-px after:top-px",
158
- hFillShape,
159
- leftFill
160
- ].join(" "),
161
- leftBottom: [
162
- "absolute bottom-4 left-full",
163
- beforeBase,
164
- "before:left-0 before:bottom-0",
165
- hBorderShape,
166
- leftBorder,
167
- afterBase,
168
- "after:-left-px after:bottom-px",
169
- hFillShape,
170
- leftFill
171
- ].join(" "),
172
- right: [
173
- "absolute top-1/2 -translate-y-1/2 right-full",
174
- beforeBase,
175
- "before:right-0 before:top-1/2 before:-translate-y-1/2",
176
- hBorderShape,
177
- rightBorder,
178
- afterBase,
179
- "after:-right-px after:top-1/2 after:-translate-y-1/2",
180
- hFillShape,
181
- rightFill
182
- ].join(" "),
183
- rightTop: [
184
- "absolute top-4 right-full",
185
- beforeBase,
186
- "before:right-0 before:top-0",
187
- hBorderShape,
188
- rightBorder,
189
- afterBase,
190
- "after:-right-px after:top-px",
191
- hFillShape,
192
- rightFill
193
- ].join(" "),
194
- rightBottom: [
195
- "absolute bottom-4 right-full",
196
- beforeBase,
197
- "before:right-0 before:bottom-0",
198
- hBorderShape,
199
- rightBorder,
200
- afterBase,
201
- "after:-right-px after:bottom-px",
202
- hFillShape,
203
- rightFill
204
- ].join(" ")
65
+ const borderShapeBySide = {
66
+ top: vBorderShape,
67
+ bottom: vBorderShape,
68
+ left: hBorderShape,
69
+ right: hBorderShape
205
70
  };
206
- const Popover = ({ title, placement = "top", className, content, children, ...props }) => {
207
- return /* @__PURE__ */ jsxs(CorePopover, { children: [/* @__PURE__ */ jsx(PopoverTrigger, {
208
- asChild: true,
209
- children
210
- }), /* @__PURE__ */ jsxs(PopoverContent, {
211
- ...props,
212
- align: placementMap[placement].align,
213
- side: placementMap[placement].side,
214
- sideOffset: 16,
215
- className: cn("relative w-auto", className),
216
- children: [
217
- renderConditional(title, (v) => /* @__PURE__ */ jsx(Typography.Title, {
218
- level: 6,
219
- children: v
220
- })),
221
- content,
222
- /* @__PURE__ */ jsx("div", { className: cn(arrowStyles[placement]) })
223
- ]
224
- })] });
71
+ const fillShapeBySide = {
72
+ top: vFillShape,
73
+ bottom: vFillShape,
74
+ left: hFillShape,
75
+ right: hFillShape
76
+ };
77
+ const borderColorBySide = {
78
+ top: "before:border-t-[9px] before:border-t-border",
79
+ bottom: "before:border-b-[9px] before:border-b-border",
80
+ left: "before:border-l-[9px] before:border-l-border",
81
+ right: "before:border-r-[9px] before:border-r-border"
82
+ };
83
+ const fillColorBySide = {
84
+ top: "after:border-t-8 after:border-t-popover",
85
+ bottom: "after:border-b-8 after:border-b-popover",
86
+ left: "after:border-l-8 after:border-l-popover",
87
+ right: "after:border-r-8 after:border-r-popover"
88
+ };
89
+ const offsetAxisBySide = {
90
+ top: "x",
91
+ bottom: "x",
92
+ left: "y",
93
+ right: "y"
94
+ };
95
+ const startEdgeByAxis = {
96
+ x: "left",
97
+ y: "top"
98
+ };
99
+ const endEdgeByAxis = {
100
+ x: "right",
101
+ y: "bottom"
102
+ };
103
+ const getArrowClassName = (side, align) => {
104
+ const axis = offsetAxisBySide[side];
105
+ const alignEdge = align === "start" ? startEdgeByAxis[axis] : align === "end" ? endEdgeByAxis[axis] : null;
106
+ const positionAlign = alignEdge ? `${alignEdge}-4` : `${startEdgeByAxis[axis]}-1/2 -translate-${axis}-1/2`;
107
+ const beforeAlign = alignEdge ? `before:${alignEdge}-0` : `before:${startEdgeByAxis[axis]}-1/2 before:-translate-${axis}-1/2`;
108
+ const afterAlign = alignEdge ? `after:${alignEdge}-px` : `after:${startEdgeByAxis[axis]}-1/2 after:-translate-${axis}-1/2`;
109
+ return cn(`absolute ${positionAlign} ${side}-full`, beforeBase, `before:${side}-0`, beforeAlign, borderShapeBySide[side], borderColorBySide[side], afterBase, `after:-${side}-px`, afterAlign, fillShapeBySide[side], fillColorBySide[side]);
110
+ };
111
+ const Popover = ({ title, placement = "top", className, content, children, open: _open, defaultOpen, onOpenChange, ...props }) => {
112
+ const [open, setOpen] = useControllableState({
113
+ value: _open,
114
+ defaultValue: defaultOpen ?? false,
115
+ onChange: onOpenChange
116
+ });
117
+ const { side, align } = placementMap[placement];
118
+ return /* @__PURE__ */ jsxs(CorePopover, {
119
+ open,
120
+ onOpenChange: setOpen,
121
+ children: [/* @__PURE__ */ jsx(PopoverTrigger, {
122
+ asChild: true,
123
+ children
124
+ }), /* @__PURE__ */ jsxs(PopoverContent, {
125
+ ...props,
126
+ align,
127
+ side,
128
+ sideOffset: 16,
129
+ className: cn("relative w-auto", className),
130
+ children: [
131
+ renderConditional(title, (v) => /* @__PURE__ */ jsx(Typography.Title, {
132
+ level: 6,
133
+ children: v
134
+ })),
135
+ content,
136
+ /* @__PURE__ */ jsx("div", { className: getArrowClassName(side, align) })
137
+ ]
138
+ })]
139
+ });
225
140
  };
226
141
 
227
142
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"popover.mjs","names":["popover"],"sources":["../../../src/components/atoms/popover.tsx"],"sourcesContent":["import { popover } from '@repo/ui/core';\nimport { cn, renderConditional } from '@repo/ui/utils';\n\nimport Typography from './typography';\n\nconst { Popover: CorePopover, PopoverContent, PopoverTrigger } = popover;\n\ntype Placement =\n | 'top'\n | 'left'\n | 'right'\n | 'bottom'\n | 'topLeft'\n | 'topRight'\n | 'bottomLeft'\n | 'bottomRight'\n | 'leftTop'\n | 'leftBottom'\n | 'rightTop'\n | 'rightBottom';\n\ninterface Props extends Omit<\n React.ComponentPropsWithoutRef<'div'>,\n 'title' | 'content'\n> {\n title?: React.ReactNode;\n placement?: Placement;\n content: React.ReactNode;\n}\n\nconst placementMap = {\n top: {\n side: 'top',\n align: 'center',\n },\n left: {\n side: 'left',\n align: 'center',\n },\n right: {\n side: 'right',\n align: 'center',\n },\n bottom: {\n side: 'bottom',\n align: 'center',\n },\n topLeft: {\n side: 'top',\n align: 'start',\n },\n topRight: {\n side: 'top',\n align: 'end',\n },\n bottomLeft: {\n side: 'bottom',\n align: 'start',\n },\n bottomRight: {\n side: 'bottom',\n align: 'end',\n },\n leftTop: {\n side: 'left',\n align: 'start',\n },\n leftBottom: {\n side: 'left',\n align: 'end',\n },\n rightTop: {\n side: 'right',\n align: 'start',\n },\n rightBottom: {\n side: 'right',\n align: 'end',\n },\n} as const;\n\nconst beforeBase = 'before:content-[\"\"] before:absolute before:h-0 before:w-0';\nconst afterBase = 'after:content-[\"\"] after:absolute after:h-0 after:w-0';\n\nconst vBorderShape =\n 'before:border-l-[9px] before:border-r-[9px] before:border-l-transparent before:border-r-transparent';\nconst hBorderShape =\n 'before:border-t-[9px] before:border-b-[9px] before:border-t-transparent before:border-b-transparent';\nconst vFillShape =\n 'after:border-l-8 after:border-r-8 after:border-l-transparent after:border-r-transparent';\nconst hFillShape =\n 'after:border-t-8 after:border-b-8 after:border-t-transparent after:border-b-transparent';\n\nconst topBorder = 'before:border-t-[9px] before:border-t-border';\nconst bottomBorder = 'before:border-b-[9px] before:border-b-border';\nconst leftBorder = 'before:border-l-[9px] before:border-l-border';\nconst rightBorder = 'before:border-r-[9px] before:border-r-border';\nconst topFill = 'after:border-t-8 after:border-t-popover';\nconst bottomFill = 'after:border-b-8 after:border-b-popover';\nconst leftFill = 'after:border-l-8 after:border-l-popover';\nconst rightFill = 'after:border-r-8 after:border-r-popover';\n\nconst arrowStyles: Record<Placement, string> = {\n top: [\n 'absolute left-1/2 -translate-x-1/2 top-full',\n beforeBase,\n 'before:top-0 before:left-1/2 before:-translate-x-1/2',\n vBorderShape,\n topBorder,\n afterBase,\n 'after:-top-px after:left-1/2 after:-translate-x-1/2',\n vFillShape,\n topFill,\n ].join(' '),\n topLeft: [\n 'absolute left-4 top-full',\n beforeBase,\n 'before:top-0 before:left-0',\n vBorderShape,\n topBorder,\n afterBase,\n 'after:-top-px after:left-px',\n vFillShape,\n topFill,\n ].join(' '),\n topRight: [\n 'absolute right-4 top-full',\n beforeBase,\n 'before:top-0 before:right-0',\n vBorderShape,\n topBorder,\n afterBase,\n 'after:-top-px after:right-px',\n vFillShape,\n topFill,\n ].join(' '),\n bottom: [\n 'absolute left-1/2 -translate-x-1/2 bottom-full',\n beforeBase,\n 'before:bottom-0 before:left-1/2 before:-translate-x-1/2',\n vBorderShape,\n bottomBorder,\n afterBase,\n 'after:-bottom-px after:left-1/2 after:-translate-x-1/2',\n vFillShape,\n bottomFill,\n ].join(' '),\n bottomLeft: [\n 'absolute left-4 bottom-full',\n beforeBase,\n 'before:bottom-0 before:left-0',\n vBorderShape,\n bottomBorder,\n afterBase,\n 'after:-bottom-px after:left-px',\n vFillShape,\n bottomFill,\n ].join(' '),\n bottomRight: [\n 'absolute right-4 bottom-full',\n beforeBase,\n 'before:bottom-0 before:right-0',\n vBorderShape,\n bottomBorder,\n afterBase,\n 'after:-bottom-px after:right-px',\n vFillShape,\n bottomFill,\n ].join(' '),\n left: [\n 'absolute top-1/2 -translate-y-1/2 left-full',\n beforeBase,\n 'before:left-0 before:top-1/2 before:-translate-y-1/2',\n hBorderShape,\n leftBorder,\n afterBase,\n 'after:-left-px after:top-1/2 after:-translate-y-1/2',\n hFillShape,\n leftFill,\n ].join(' '),\n leftTop: [\n 'absolute top-4 left-full',\n beforeBase,\n 'before:left-0 before:top-0',\n hBorderShape,\n leftBorder,\n afterBase,\n 'after:-left-px after:top-px',\n hFillShape,\n leftFill,\n ].join(' '),\n leftBottom: [\n 'absolute bottom-4 left-full',\n beforeBase,\n 'before:left-0 before:bottom-0',\n hBorderShape,\n leftBorder,\n afterBase,\n 'after:-left-px after:bottom-px',\n hFillShape,\n leftFill,\n ].join(' '),\n right: [\n 'absolute top-1/2 -translate-y-1/2 right-full',\n beforeBase,\n 'before:right-0 before:top-1/2 before:-translate-y-1/2',\n hBorderShape,\n rightBorder,\n afterBase,\n 'after:-right-px after:top-1/2 after:-translate-y-1/2',\n hFillShape,\n rightFill,\n ].join(' '),\n rightTop: [\n 'absolute top-4 right-full',\n beforeBase,\n 'before:right-0 before:top-0',\n hBorderShape,\n rightBorder,\n afterBase,\n 'after:-right-px after:top-px',\n hFillShape,\n rightFill,\n ].join(' '),\n rightBottom: [\n 'absolute bottom-4 right-full',\n beforeBase,\n 'before:right-0 before:bottom-0',\n hBorderShape,\n rightBorder,\n afterBase,\n 'after:-right-px after:bottom-px',\n hFillShape,\n rightFill,\n ].join(' '),\n};\n\nconst Popover = ({\n title,\n placement = 'top',\n className,\n content,\n children,\n ...props\n}: Props) => {\n return (\n <CorePopover>\n <PopoverTrigger asChild>{children}</PopoverTrigger>\n <PopoverContent\n {...props}\n align={placementMap[placement].align}\n side={placementMap[placement].side}\n sideOffset={16}\n className={cn('relative w-auto', className)}\n >\n {renderConditional(title, v => (\n <Typography.Title level={6}>{v}</Typography.Title>\n ))}\n {content}\n <div className={cn(arrowStyles[placement])} />\n </PopoverContent>\n </CorePopover>\n );\n};\n\nexport default Popover;\n"],"mappings":";;;;;;AAKA,MAAM,EAAE,SAAS,aAAa,gBAAgB,mBAAmBA;AAyBjE,MAAM,eAAe;CACnB,KAAK;EACH,MAAM;EACN,OAAO;EACR;CACD,MAAM;EACJ,MAAM;EACN,OAAO;EACR;CACD,OAAO;EACL,MAAM;EACN,OAAO;EACR;CACD,QAAQ;EACN,MAAM;EACN,OAAO;EACR;CACD,SAAS;EACP,MAAM;EACN,OAAO;EACR;CACD,UAAU;EACR,MAAM;EACN,OAAO;EACR;CACD,YAAY;EACV,MAAM;EACN,OAAO;EACR;CACD,aAAa;EACX,MAAM;EACN,OAAO;EACR;CACD,SAAS;EACP,MAAM;EACN,OAAO;EACR;CACD,YAAY;EACV,MAAM;EACN,OAAO;EACR;CACD,UAAU;EACR,MAAM;EACN,OAAO;EACR;CACD,aAAa;EACX,MAAM;EACN,OAAO;EACR;CACF;AAED,MAAM,aAAa;AACnB,MAAM,YAAY;AAElB,MAAM,eACJ;AACF,MAAM,eACJ;AACF,MAAM,aACJ;AACF,MAAM,aACJ;AAEF,MAAM,YAAY;AAClB,MAAM,eAAe;AACrB,MAAM,aAAa;AACnB,MAAM,cAAc;AACpB,MAAM,UAAU;AAChB,MAAM,aAAa;AACnB,MAAM,WAAW;AACjB,MAAM,YAAY;AAElB,MAAM,cAAyC;CAC7C,KAAK;EACH;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC,KAAK,IAAI;CACX,SAAS;EACP;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC,KAAK,IAAI;CACX,UAAU;EACR;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC,KAAK,IAAI;CACX,QAAQ;EACN;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC,KAAK,IAAI;CACX,YAAY;EACV;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC,KAAK,IAAI;CACX,aAAa;EACX;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC,KAAK,IAAI;CACX,MAAM;EACJ;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC,KAAK,IAAI;CACX,SAAS;EACP;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC,KAAK,IAAI;CACX,YAAY;EACV;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC,KAAK,IAAI;CACX,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC,KAAK,IAAI;CACX,UAAU;EACR;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC,KAAK,IAAI;CACX,aAAa;EACX;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC,KAAK,IAAI;CACZ;AAED,MAAM,WAAW,EACf,OACA,YAAY,OACZ,WACA,SACA,UACA,GAAG,YACQ;AACX,QACE,qBAAC,0BACC,oBAAC;EAAe;EAAS;GAA0B,EACnD,qBAAC;EACC,GAAI;EACJ,OAAO,aAAa,WAAW;EAC/B,MAAM,aAAa,WAAW;EAC9B,YAAY;EACZ,WAAW,GAAG,mBAAmB,UAAU;;GAE1C,kBAAkB,QAAO,MACxB,oBAAC,WAAW;IAAM,OAAO;cAAI;KAAqB,CAClD;GACD;GACD,oBAAC,SAAI,WAAW,GAAG,YAAY,WAAW,GAAI;;GAC/B,IACL"}
1
+ {"version":3,"file":"popover.mjs","names":["popover"],"sources":["../../../src/components/atoms/popover.tsx"],"sourcesContent":["import { useControllableState } from '@jbpark/use-hooks';\n\nimport { popover } from '@repo/ui/core';\nimport { cn, renderConditional } from '@repo/ui/utils';\n\nimport Typography from './typography';\n\nconst { Popover: CorePopover, PopoverContent, PopoverTrigger } = popover;\n\ntype Placement =\n | 'top'\n | 'left'\n | 'right'\n | 'bottom'\n | 'topLeft'\n | 'topRight'\n | 'bottomLeft'\n | 'bottomRight'\n | 'leftTop'\n | 'leftBottom'\n | 'rightTop'\n | 'rightBottom';\n\nexport interface Props extends Omit<\n React.ComponentPropsWithoutRef<'div'>,\n 'title' | 'content'\n> {\n title?: React.ReactNode;\n placement?: Placement;\n content: React.ReactNode;\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n}\n\ntype Side = 'top' | 'bottom' | 'left' | 'right';\ntype Align = 'start' | 'center' | 'end';\n\nconst placementMap: Record<Placement, { side: Side; align: Align }> = {\n top: { side: 'top', align: 'center' },\n left: { side: 'left', align: 'center' },\n right: { side: 'right', align: 'center' },\n bottom: { side: 'bottom', align: 'center' },\n topLeft: { side: 'top', align: 'start' },\n topRight: { side: 'top', align: 'end' },\n bottomLeft: { side: 'bottom', align: 'start' },\n bottomRight: { side: 'bottom', align: 'end' },\n leftTop: { side: 'left', align: 'start' },\n leftBottom: { side: 'left', align: 'end' },\n rightTop: { side: 'right', align: 'start' },\n rightBottom: { side: 'right', align: 'end' },\n};\n\nconst beforeBase = 'before:content-[\"\"] before:absolute before:h-0 before:w-0';\nconst afterBase = 'after:content-[\"\"] after:absolute after:h-0 after:w-0';\n\nconst vBorderShape =\n 'before:border-l-[9px] before:border-r-[9px] before:border-l-transparent before:border-r-transparent';\nconst hBorderShape =\n 'before:border-t-[9px] before:border-b-[9px] before:border-t-transparent before:border-b-transparent';\nconst vFillShape =\n 'after:border-l-8 after:border-r-8 after:border-l-transparent after:border-r-transparent';\nconst hFillShape =\n 'after:border-t-8 after:border-b-8 after:border-t-transparent after:border-b-transparent';\n\n// Top/bottom placements draw a vertical-edge triangle (border-l/border-r) —\n// the arrow points up/down, so its left/right edges form the point. Left/\n// right placements draw the horizontal-edge equivalent.\nconst borderShapeBySide: Record<Side, string> = {\n top: vBorderShape,\n bottom: vBorderShape,\n left: hBorderShape,\n right: hBorderShape,\n};\nconst fillShapeBySide: Record<Side, string> = {\n top: vFillShape,\n bottom: vFillShape,\n left: hFillShape,\n right: hFillShape,\n};\nconst borderColorBySide: Record<Side, string> = {\n top: 'before:border-t-[9px] before:border-t-border',\n bottom: 'before:border-b-[9px] before:border-b-border',\n left: 'before:border-l-[9px] before:border-l-border',\n right: 'before:border-r-[9px] before:border-r-border',\n};\nconst fillColorBySide: Record<Side, string> = {\n top: 'after:border-t-8 after:border-t-popover',\n bottom: 'after:border-b-8 after:border-b-popover',\n left: 'after:border-l-8 after:border-l-popover',\n right: 'after:border-r-8 after:border-r-popover',\n};\n\n// `side` picks which edge of the content the arrow sits against; `align`\n// slides it along that edge. The offset axis (x for top/bottom, y for\n// left/right) is perpendicular to `side` — `align: 'center'` centers the\n// arrow with a translate, while `start`/`end` pin it 16px from that edge.\nconst offsetAxisBySide: Record<Side, 'x' | 'y'> = {\n top: 'x',\n bottom: 'x',\n left: 'y',\n right: 'y',\n};\nconst startEdgeByAxis = { x: 'left', y: 'top' } as const;\nconst endEdgeByAxis = { x: 'right', y: 'bottom' } as const;\n\nconst getArrowClassName = (side: Side, align: Align) => {\n const axis = offsetAxisBySide[side];\n const alignEdge =\n align === 'start'\n ? startEdgeByAxis[axis]\n : align === 'end'\n ? endEdgeByAxis[axis]\n : null;\n\n const positionAlign = alignEdge\n ? `${alignEdge}-4`\n : `${startEdgeByAxis[axis]}-1/2 -translate-${axis}-1/2`;\n const beforeAlign = alignEdge\n ? `before:${alignEdge}-0`\n : `before:${startEdgeByAxis[axis]}-1/2 before:-translate-${axis}-1/2`;\n const afterAlign = alignEdge\n ? `after:${alignEdge}-px`\n : `after:${startEdgeByAxis[axis]}-1/2 after:-translate-${axis}-1/2`;\n\n return cn(\n `absolute ${positionAlign} ${side}-full`,\n beforeBase,\n `before:${side}-0`,\n beforeAlign,\n borderShapeBySide[side],\n borderColorBySide[side],\n afterBase,\n `after:-${side}-px`,\n afterAlign,\n fillShapeBySide[side],\n fillColorBySide[side],\n );\n};\n\nconst Popover = ({\n title,\n placement = 'top',\n className,\n content,\n children,\n open: _open,\n defaultOpen,\n onOpenChange,\n ...props\n}: Props) => {\n const [open, setOpen] = useControllableState<boolean>({\n value: _open,\n defaultValue: defaultOpen ?? false,\n onChange: onOpenChange,\n });\n\n const { side, align } = placementMap[placement];\n\n return (\n <CorePopover open={open} onOpenChange={setOpen}>\n <PopoverTrigger asChild>{children}</PopoverTrigger>\n <PopoverContent\n {...props}\n align={align}\n side={side}\n sideOffset={16}\n className={cn('relative w-auto', className)}\n >\n {renderConditional(title, v => (\n <Typography.Title level={6}>{v}</Typography.Title>\n ))}\n {content}\n <div className={getArrowClassName(side, align)} />\n </PopoverContent>\n </CorePopover>\n );\n};\n\nexport default Popover;\n"],"mappings":";;;;;;;AAOA,MAAM,EAAE,SAAS,aAAa,gBAAgB,mBAAmBA;AA+BjE,MAAM,eAAgE;CACpE,KAAK;EAAE,MAAM;EAAO,OAAO;EAAU;CACrC,MAAM;EAAE,MAAM;EAAQ,OAAO;EAAU;CACvC,OAAO;EAAE,MAAM;EAAS,OAAO;EAAU;CACzC,QAAQ;EAAE,MAAM;EAAU,OAAO;EAAU;CAC3C,SAAS;EAAE,MAAM;EAAO,OAAO;EAAS;CACxC,UAAU;EAAE,MAAM;EAAO,OAAO;EAAO;CACvC,YAAY;EAAE,MAAM;EAAU,OAAO;EAAS;CAC9C,aAAa;EAAE,MAAM;EAAU,OAAO;EAAO;CAC7C,SAAS;EAAE,MAAM;EAAQ,OAAO;EAAS;CACzC,YAAY;EAAE,MAAM;EAAQ,OAAO;EAAO;CAC1C,UAAU;EAAE,MAAM;EAAS,OAAO;EAAS;CAC3C,aAAa;EAAE,MAAM;EAAS,OAAO;EAAO;CAC7C;AAED,MAAM,aAAa;AACnB,MAAM,YAAY;AAElB,MAAM,eACJ;AACF,MAAM,eACJ;AACF,MAAM,aACJ;AACF,MAAM,aACJ;AAKF,MAAM,oBAA0C;CAC9C,KAAK;CACL,QAAQ;CACR,MAAM;CACN,OAAO;CACR;AACD,MAAM,kBAAwC;CAC5C,KAAK;CACL,QAAQ;CACR,MAAM;CACN,OAAO;CACR;AACD,MAAM,oBAA0C;CAC9C,KAAK;CACL,QAAQ;CACR,MAAM;CACN,OAAO;CACR;AACD,MAAM,kBAAwC;CAC5C,KAAK;CACL,QAAQ;CACR,MAAM;CACN,OAAO;CACR;AAMD,MAAM,mBAA4C;CAChD,KAAK;CACL,QAAQ;CACR,MAAM;CACN,OAAO;CACR;AACD,MAAM,kBAAkB;CAAE,GAAG;CAAQ,GAAG;CAAO;AAC/C,MAAM,gBAAgB;CAAE,GAAG;CAAS,GAAG;CAAU;AAEjD,MAAM,qBAAqB,MAAY,UAAiB;CACtD,MAAM,OAAO,iBAAiB;CAC9B,MAAM,YACJ,UAAU,UACN,gBAAgB,QAChB,UAAU,QACR,cAAc,QACd;CAER,MAAM,gBAAgB,YAClB,GAAG,UAAU,MACb,GAAG,gBAAgB,MAAM,kBAAkB,KAAK;CACpD,MAAM,cAAc,YAChB,UAAU,UAAU,MACpB,UAAU,gBAAgB,MAAM,yBAAyB,KAAK;CAClE,MAAM,aAAa,YACf,SAAS,UAAU,OACnB,SAAS,gBAAgB,MAAM,wBAAwB,KAAK;AAEhE,QAAO,GACL,YAAY,cAAc,GAAG,KAAK,QAClC,YACA,UAAU,KAAK,KACf,aACA,kBAAkB,OAClB,kBAAkB,OAClB,WACA,UAAU,KAAK,MACf,YACA,gBAAgB,OAChB,gBAAgB,MACjB;;AAGH,MAAM,WAAW,EACf,OACA,YAAY,OACZ,WACA,SACA,UACA,MAAM,OACN,aACA,cACA,GAAG,YACQ;CACX,MAAM,CAAC,MAAM,WAAW,qBAA8B;EACpD,OAAO;EACP,cAAc,eAAe;EAC7B,UAAU;EACX,CAAC;CAEF,MAAM,EAAE,MAAM,UAAU,aAAa;AAErC,QACE,qBAAC;EAAkB;EAAM,cAAc;aACrC,oBAAC;GAAe;GAAS;IAA0B,EACnD,qBAAC;GACC,GAAI;GACG;GACD;GACN,YAAY;GACZ,WAAW,GAAG,mBAAmB,UAAU;;IAE1C,kBAAkB,QAAO,MACxB,oBAAC,WAAW;KAAM,OAAO;eAAI;MAAqB,CAClD;IACD;IACD,oBAAC,SAAI,WAAW,kBAAkB,MAAM,MAAM,GAAI;;IACnC;GACL"}
@@ -1,20 +1,16 @@
1
+ import { OptionGroupClassNames, OptionValue, Options } from "../option-group.mjs";
1
2
  import * as react_jsx_runtime0 from "react/jsx-runtime";
2
3
 
3
4
  //#region src/components/atoms/radio/group.d.ts
4
- type OptionValue = string | number | boolean;
5
- type Option = {
6
- label: string;
7
- value: OptionValue;
8
- disabled?: boolean;
9
- };
10
- type Options = string[] | number[] | boolean[] | Option[];
11
5
  interface Props extends Omit<React.ComponentPropsWithoutRef<'ul'>, 'onChange' | 'defaultValue' | 'value'> {
12
6
  options?: Options;
13
7
  orientation?: 'vertical' | 'horizontal';
14
8
  placement?: 'left' | 'right';
15
- classNames?: Record<string, string>;
9
+ classNames?: OptionGroupClassNames;
16
10
  defaultValue?: OptionValue;
17
11
  value?: OptionValue;
12
+ /** Native form field name — participates in `FormData` when set. */
13
+ name?: string;
18
14
  optionType?: 'default' | 'button';
19
15
  buttonStyle?: 'solid' | 'outlined';
20
16
  size?: 'small' | 'middle' | 'large';
@@ -27,6 +23,7 @@ declare const RadioGroup: ({
27
23
  className,
28
24
  classNames,
29
25
  options: _options,
26
+ name,
30
27
  optionType,
31
28
  buttonStyle,
32
29
  size,
@@ -37,5 +34,5 @@ declare const RadioGroup: ({
37
34
  ...props
38
35
  }: Props) => react_jsx_runtime0.JSX.Element;
39
36
  //#endregion
40
- export { OptionValue, RadioGroup };
37
+ export { RadioGroup };
41
38
  //# sourceMappingURL=group.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"group.d.mts","names":[],"sources":["../../../../src/components/atoms/radio/group.tsx"],"mappings":";;;KAaY,WAAA;AAAA,KAEP,MAAA;EACH,KAAA;EACA,KAAA,EAAO,WAAA;EACP,QAAA;AAAA;AAAA,KAGG,OAAA,qCAA4C,MAAA;AAAA,UAEhC,KAAA,SAAc,IAAA,CAC7B,KAAA,CAAM,wBAAA;EAGN,OAAA,GAAU,OAAA;EACV,WAAA;EACA,SAAA;EACA,UAAA,GAAa,MAAA;EACb,YAAA,GAAe,WAAA;EACf,KAAA,GAAQ,WAAA;EACR,UAAA;EACA,WAAA;EACA,IAAA;EACA,QAAA;EACA,QAAA,IAAY,KAAA,EAAO,WAAA;AAAA;AAAA,cAGf,UAAA;EAAc,WAAA;EAAA,SAAA;EAAA,SAAA;EAAA,UAAA;EAAA,OAAA,EAAA,QAAA;EAAA,UAAA;EAAA,WAAA;EAAA,IAAA;EAAA,QAAA;EAAA,YAAA;EAAA,KAAA,EAAA,MAAA;EAAA,QAAA,EAAA,SAAA;EAAA,GAAA;AAAA,GAcjB,KAAA,KAAK,kBAAA,CAAA,GAAA,CAAA,OAAA"}
1
+ {"version":3,"file":"group.d.mts","names":[],"sources":["../../../../src/components/atoms/radio/group.tsx"],"mappings":";;;;UAwBiB,KAAA,SAAc,IAAA,CAC7B,KAAA,CAAM,wBAAA;EAGN,OAAA,GAAU,OAAA;EACV,WAAA;EACA,SAAA;EACA,UAAA,GAAa,qBAAA;EACb,YAAA,GAAe,WAAA;EACf,KAAA,GAAQ,WAAA;EAFK;EAIb,IAAA;EACA,UAAA;EACA,WAAA;EACA,IAAA;EACA,QAAA;EACA,QAAA,IAAY,KAAA,EAAO,WAAA;AAAA;AAAA,cAGf,UAAA;EAAc,WAAA;EAAA,SAAA;EAAA,SAAA;EAAA,UAAA;EAAA,OAAA,EAAA,QAAA;EAAA,IAAA;EAAA,UAAA;EAAA,WAAA;EAAA,IAAA;EAAA,QAAA;EAAA,YAAA;EAAA,KAAA,EAAA,MAAA;EAAA,QAAA,EAAA,SAAA;EAAA,GAAA;AAAA,GAejB,KAAA,KAAK,kBAAA,CAAA,GAAA,CAAA,OAAA"}
@@ -3,33 +3,32 @@
3
3
  import { cn } from "../../../utils.mjs";
4
4
  import { radio_group_exports } from "../../../core/radio-group.mjs";
5
5
  import Button from "../../../Button.mjs";
6
+ import { normalizeOptions } from "../option-group.mjs";
6
7
  import { RadioGroupContext } from "./context.mjs";
7
8
  import Radio from "./radio.mjs";
8
- import { useId, useState } from "react";
9
+ import { useId } from "react";
9
10
  import { jsx } from "react/jsx-runtime";
11
+ import { useControllableState } from "@jbpark/use-hooks";
10
12
 
11
13
  //#region src/components/atoms/radio/group.tsx
12
- const { RadioGroup: Core } = radio_group_exports;
13
- const RadioGroup = ({ orientation = "horizontal", placement = "left", className, classNames = {}, options: _options = [], optionType = "default", buttonStyle = "solid", size, disabled, defaultValue, value: _value, onChange: _onChange = () => {}, ...props }) => {
14
- const [uncontrolledValue, setUncontrolledValue] = useState(defaultValue);
15
- const controlled = _value !== void 0;
16
- const value = controlled ? _value : uncontrolledValue;
17
- const options = _options.map((item) => typeof item === "object" ? item : {
18
- label: `${item}`,
19
- value: item
14
+ const { RadioGroup: Core, RadioGroupItem: Item } = radio_group_exports;
15
+ const RadioGroup = ({ orientation = "horizontal", placement = "left", className, classNames = {}, options: _options = [], name, optionType = "default", buttonStyle = "solid", size, disabled, defaultValue, value: _value, onChange: _onChange = () => {}, ...props }) => {
16
+ const [value, setValue] = useControllableState({
17
+ value: _value,
18
+ defaultValue,
19
+ onChange: _onChange
20
20
  });
21
+ const options = normalizeOptions(_options);
21
22
  const isButton = optionType === "button";
22
23
  const onChange = (checked, optionValue) => {
23
24
  if (!checked) return;
24
- if (!controlled) setUncontrolledValue(optionValue);
25
- _onChange(optionValue);
25
+ setValue(optionValue);
26
26
  };
27
27
  const baseId = useId();
28
28
  const getOptionId = (index) => `${baseId}-${index}`;
29
- const checkedIndex = options.findIndex((item) => item.value === value);
30
- const checkedId = checkedIndex === -1 ? "" : getOptionId(checkedIndex);
31
- const onValueChange = (optionId) => {
32
- const item = options.find((_, index) => getOptionId(index) === optionId);
29
+ const checkedItemValue = value === void 0 ? "" : String(value);
30
+ const onValueChange = (itemValue) => {
31
+ const item = options.find((option) => String(option.value) === itemValue);
33
32
  if (!item) return;
34
33
  onChange(true, item.value);
35
34
  };
@@ -40,13 +39,17 @@ const RadioGroup = ({ orientation = "horizontal", placement = "left", className,
40
39
  const checked = value === item.value;
41
40
  return /* @__PURE__ */ jsx("li", {
42
41
  className: cn("flex", classNames?.wrapper),
43
- children: isButton ? /* @__PURE__ */ jsx(Button, {
44
- variant: checked ? buttonStyle : "outlined",
45
- size,
46
- className: cn("rounded-none", index === 0 && "rounded-l-lg", index === options.length - 1 && "rounded-r-lg", checked && buttonStyle === "outlined" && "border-primary"),
42
+ children: isButton ? /* @__PURE__ */ jsx(Item, {
43
+ asChild: true,
44
+ value: String(item.value),
47
45
  disabled: disabled || item.disabled,
48
- onClick: () => onChange(true, item.value),
49
- children: item.label
46
+ children: /* @__PURE__ */ jsx(Button, {
47
+ variant: checked ? buttonStyle : "outlined",
48
+ size,
49
+ disabled: disabled || item.disabled,
50
+ className: cn("rounded-none border", checked && (buttonStyle === "outlined" ? "border-primary" : "border-transparent"), index === 0 && (orientation === "vertical" ? "rounded-t-lg" : "rounded-l-lg"), index === options.length - 1 && (orientation === "vertical" ? "rounded-b-lg" : "rounded-r-lg")),
51
+ children: item.label
52
+ })
50
53
  }) : /* @__PURE__ */ jsx(Radio, {
51
54
  id: getOptionId(index),
52
55
  placement,
@@ -60,12 +63,12 @@ const RadioGroup = ({ orientation = "horizontal", placement = "left", className,
60
63
  }, String(item.value));
61
64
  })
62
65
  });
63
- if (isButton) return list;
64
66
  return /* @__PURE__ */ jsx(RadioGroupContext.Provider, {
65
67
  value: true,
66
68
  children: /* @__PURE__ */ jsx(Core, {
67
69
  className: "block",
68
- value: checkedId,
70
+ name,
71
+ value: checkedItemValue,
69
72
  onValueChange,
70
73
  children: list
71
74
  })