@trsys-tech/matrix-library 0.5.1-alpha.0 → 0.5.1-beta.1

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 (42) hide show
  1. package/dist/combobox.es.js +1 -1
  2. package/dist/combobox.es.js.map +1 -1
  3. package/dist/components/duration/Duration.d.ts +61 -0
  4. package/dist/components/duration/Duration.d.ts.map +1 -0
  5. package/dist/components/form-duration/FormDuration.d.ts +21 -0
  6. package/dist/components/form-duration/FormDuration.d.ts.map +1 -0
  7. package/dist/components/form-multi-select/FormMultiSelect.d.ts +3 -3
  8. package/dist/components/form-multi-select/FormMultiSelect.d.ts.map +1 -1
  9. package/dist/components/multi-select/MultiSelect.d.ts +11 -7
  10. package/dist/components/multi-select/MultiSelect.d.ts.map +1 -1
  11. package/dist/desktopdatepicker.es.js +1 -1
  12. package/dist/desktopdatepicker.es.js.map +1 -1
  13. package/dist/desktopdaterangepicker.es.js +1 -1
  14. package/dist/desktopdaterangepicker.es.js.map +1 -1
  15. package/dist/desktoptimepicker.es.js +1 -1
  16. package/dist/desktoptimepicker.es.js.map +1 -1
  17. package/dist/duration.es.js +116 -0
  18. package/dist/duration.es.js.map +1 -0
  19. package/dist/formduration.es.js +40 -0
  20. package/dist/formduration.es.js.map +1 -0
  21. package/dist/formmultiselect.es.js +43 -45
  22. package/dist/formmultiselect.es.js.map +1 -1
  23. package/dist/index.d.ts +2 -0
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.es.js +155 -151
  26. package/dist/index.es.js.map +1 -1
  27. package/dist/mobiledatepicker.es.js +1 -1
  28. package/dist/mobiledatepicker.es.js.map +1 -1
  29. package/dist/mobiledaterangepicker.es.js +5 -5
  30. package/dist/mobiledaterangepicker.es.js.map +1 -1
  31. package/dist/mobiletimepicker.es.js +1 -1
  32. package/dist/mobiletimepicker.es.js.map +1 -1
  33. package/dist/multiselect.es.js +161 -163
  34. package/dist/multiselect.es.js.map +1 -1
  35. package/dist/select.es.js +8 -8
  36. package/dist/select.es.js.map +1 -1
  37. package/dist/styles.css +1 -1
  38. package/dist/textfield.es.js +1 -1
  39. package/dist/textfield.es.js.map +1 -1
  40. package/dist/timepickercontent.es.js +3 -3
  41. package/dist/timepickercontent.es.js.map +1 -1
  42. package/package.json +2 -2
@@ -4,7 +4,7 @@ import { tv as h } from "tailwind-variants";
4
4
  import { cn as n } from "./utils.es.js";
5
5
  const g = h({
6
6
  base: [
7
- "flex items-center w-full rounded-sm border border-input text-text bg-transparent p-0 text-xs font-medium shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground",
7
+ "flex items-center w-full rounded-sm border border-input text-text bg-transparent p-0 text-xs [&_input]:text-xs font-medium shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground",
8
8
  "placeholder:text-text-300 hover:border-primary-400 focus-within:border-primary-400 focus-within:outline-none focus-within:ring focus-within:ring-primary-100",
9
9
  "aria-disabled:text-text-300 aria-disabled:bg-gray-100 aria-disabled:border-gray-100"
10
10
  ],
@@ -1 +1 @@
1
- {"version":3,"file":"textfield.es.js","sources":["../src/components/text-field/TextField.tsx"],"sourcesContent":["\"use client\";\r\n\r\nimport * as React from \"react\";\r\nimport { tv, VariantProps } from \"tailwind-variants\";\r\n\r\nimport { cn } from \"../../lib/utils\";\r\n\r\nconst textFieldVariants = tv({\r\n base: [\r\n \"flex items-center w-full rounded-sm border border-input text-text bg-transparent p-0 text-xs font-medium shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground\",\r\n \"placeholder:text-text-300 hover:border-primary-400 focus-within:border-primary-400 focus-within:outline-none focus-within:ring focus-within:ring-primary-100\",\r\n \"aria-disabled:text-text-300 aria-disabled:bg-gray-100 aria-disabled:border-gray-100\",\r\n ],\r\n variants: {\r\n size: {\r\n sm: \"h-7\",\r\n md: \"h-8\",\r\n lg: \"h-11\",\r\n },\r\n },\r\n defaultVariants: {\r\n size: \"md\",\r\n },\r\n});\r\n\r\ninterface TextFieldProps extends React.HTMLAttributes<HTMLDivElement>, VariantProps<typeof textFieldVariants> {\r\n type?: React.HTMLInputTypeAttribute;\r\n disabled?: boolean;\r\n suffix?: React.ReactNode;\r\n endAdornment?: React.ReactNode;\r\n startAdornment?: React.ReactNode;\r\n onChange?: React.ChangeEventHandler<HTMLInputElement>;\r\n value?: string | number;\r\n defaultValue?: string | number;\r\n slotProps?: {\r\n inputProps?: React.InputHTMLAttributes<HTMLInputElement>;\r\n };\r\n}\r\n\r\nconst TextField = React.forwardRef<HTMLInputElement, TextFieldProps>(\r\n ({ className, slotProps, suffix, endAdornment, startAdornment, size, value, onChange, defaultValue, type, disabled, ...props }, ref) => {\r\n return (\r\n <div {...props} className={cn(textFieldVariants({ size, className }))} aria-disabled={disabled}>\r\n {startAdornment}\r\n <input\r\n type={type}\r\n ref={ref}\r\n onChange={onChange}\r\n value={value}\r\n defaultValue={defaultValue}\r\n disabled={disabled}\r\n {...(slotProps?.inputProps ?? {})}\r\n className={cn(\r\n \"focus:outline-none w-full h-full py-1 rounded-sm file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-text-300\",\r\n !startAdornment ? \"px-3\" : \"ps-1 pe-3\",\r\n slotProps?.inputProps?.className,\r\n )}\r\n />\r\n {typeof suffix === \"string\" || typeof suffix === \"number\" ? (\r\n <span className=\"inline-flex items-center px-2 text-xs font-medium text-primary bg-primary-50 m-0.5 rounded-sm\">{suffix}</span>\r\n ) : (\r\n suffix\r\n )}\r\n {endAdornment}\r\n </div>\r\n );\r\n },\r\n);\r\nTextField.displayName = \"TextField\";\r\n\r\nexport { TextField, type TextFieldProps };\r\n"],"names":["textFieldVariants","tv","TextField","React","className","slotProps","suffix","endAdornment","startAdornment","size","value","onChange","defaultValue","type","disabled","props","ref","jsxs","cn","jsx"],"mappings":";;;;AAOA,MAAMA,IAAoBC,EAAG;AAAA,EAC3B,MAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAAA,EAEF,UAAU;AAAA,IACR,MAAM;AAAA,MACJ,IAAI;AAAA,MACJ,IAAI;AAAA,MACJ,IAAI;AAAA,IAAA;AAAA,EACN;AAAA,EAEF,iBAAiB;AAAA,IACf,MAAM;AAAA,EAAA;AAEV,CAAC,GAgBKC,IAAYC,EAAM;AAAA,EACtB,CAAC,EAAE,WAAAC,GAAW,WAAAC,GAAW,QAAAC,GAAQ,cAAAC,GAAc,gBAAAC,GAAgB,MAAAC,GAAM,OAAAC,GAAO,UAAAC,GAAU,cAAAC,GAAc,MAAAC,GAAM,UAAAC,GAAU,GAAGC,EAAA,GAASC,MAE5H,gBAAAC,EAAC,OAAA,EAAK,GAAGF,GAAO,WAAWG,EAAGlB,EAAkB,EAAE,MAAAS,GAAM,WAAAL,EAAA,CAAW,CAAC,GAAG,iBAAeU,GACnF,UAAA;AAAA,IAAAN;AAAA,IACD,gBAAAW;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,MAAAN;AAAA,QACA,KAAAG;AAAA,QACA,UAAAL;AAAA,QACA,OAAAD;AAAA,QACA,cAAAE;AAAA,QACA,UAAAE;AAAA,QACC,GAAIT,GAAW,cAAc,CAAA;AAAA,QAC9B,WAAWa;AAAA,UACT;AAAA,UACCV,IAA0B,cAAT;AAAA,UAClBH,GAAW,YAAY;AAAA,QAAA;AAAA,MACzB;AAAA,IAAA;AAAA,IAED,OAAOC,KAAW,YAAY,OAAOA,KAAW,WAC/C,gBAAAa,EAAC,QAAA,EAAK,WAAU,iGAAiG,UAAAb,EAAA,CAAO,IAExHA;AAAA,IAEDC;AAAA,EAAA,GACH;AAGN;AACAL,EAAU,cAAc;"}
1
+ {"version":3,"file":"textfield.es.js","sources":["../src/components/text-field/TextField.tsx"],"sourcesContent":["\"use client\";\r\n\r\nimport * as React from \"react\";\r\nimport { tv, VariantProps } from \"tailwind-variants\";\r\n\r\nimport { cn } from \"../../lib/utils\";\r\n\r\nconst textFieldVariants = tv({\r\n base: [\r\n \"flex items-center w-full rounded-sm border border-input text-text bg-transparent p-0 text-xs [&_input]:text-xs font-medium shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground\",\r\n \"placeholder:text-text-300 hover:border-primary-400 focus-within:border-primary-400 focus-within:outline-none focus-within:ring focus-within:ring-primary-100\",\r\n \"aria-disabled:text-text-300 aria-disabled:bg-gray-100 aria-disabled:border-gray-100\",\r\n ],\r\n variants: {\r\n size: {\r\n sm: \"h-7\",\r\n md: \"h-8\",\r\n lg: \"h-11\",\r\n },\r\n },\r\n defaultVariants: {\r\n size: \"md\",\r\n },\r\n});\r\n\r\ninterface TextFieldProps extends React.HTMLAttributes<HTMLDivElement>, VariantProps<typeof textFieldVariants> {\r\n type?: React.HTMLInputTypeAttribute;\r\n disabled?: boolean;\r\n suffix?: React.ReactNode;\r\n endAdornment?: React.ReactNode;\r\n startAdornment?: React.ReactNode;\r\n onChange?: React.ChangeEventHandler<HTMLInputElement>;\r\n value?: string | number;\r\n defaultValue?: string | number;\r\n slotProps?: {\r\n inputProps?: React.InputHTMLAttributes<HTMLInputElement>;\r\n };\r\n}\r\n\r\nconst TextField = React.forwardRef<HTMLInputElement, TextFieldProps>(\r\n ({ className, slotProps, suffix, endAdornment, startAdornment, size, value, onChange, defaultValue, type, disabled, ...props }, ref) => {\r\n return (\r\n <div {...props} className={cn(textFieldVariants({ size, className }))} aria-disabled={disabled}>\r\n {startAdornment}\r\n <input\r\n type={type}\r\n ref={ref}\r\n onChange={onChange}\r\n value={value}\r\n defaultValue={defaultValue}\r\n disabled={disabled}\r\n {...(slotProps?.inputProps ?? {})}\r\n className={cn(\r\n \"focus:outline-none w-full h-full py-1 rounded-sm file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-text-300\",\r\n !startAdornment ? \"px-3\" : \"ps-1 pe-3\",\r\n slotProps?.inputProps?.className,\r\n )}\r\n />\r\n {typeof suffix === \"string\" || typeof suffix === \"number\" ? (\r\n <span className=\"inline-flex items-center px-2 text-xs font-medium text-primary bg-primary-50 m-0.5 rounded-sm\">{suffix}</span>\r\n ) : (\r\n suffix\r\n )}\r\n {endAdornment}\r\n </div>\r\n );\r\n },\r\n);\r\nTextField.displayName = \"TextField\";\r\n\r\nexport { TextField, type TextFieldProps };\r\n"],"names":["textFieldVariants","tv","TextField","React","className","slotProps","suffix","endAdornment","startAdornment","size","value","onChange","defaultValue","type","disabled","props","ref","jsxs","cn","jsx"],"mappings":";;;;AAOA,MAAMA,IAAoBC,EAAG;AAAA,EAC3B,MAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAAA,EAEF,UAAU;AAAA,IACR,MAAM;AAAA,MACJ,IAAI;AAAA,MACJ,IAAI;AAAA,MACJ,IAAI;AAAA,IAAA;AAAA,EACN;AAAA,EAEF,iBAAiB;AAAA,IACf,MAAM;AAAA,EAAA;AAEV,CAAC,GAgBKC,IAAYC,EAAM;AAAA,EACtB,CAAC,EAAE,WAAAC,GAAW,WAAAC,GAAW,QAAAC,GAAQ,cAAAC,GAAc,gBAAAC,GAAgB,MAAAC,GAAM,OAAAC,GAAO,UAAAC,GAAU,cAAAC,GAAc,MAAAC,GAAM,UAAAC,GAAU,GAAGC,EAAA,GAASC,MAE5H,gBAAAC,EAAC,OAAA,EAAK,GAAGF,GAAO,WAAWG,EAAGlB,EAAkB,EAAE,MAAAS,GAAM,WAAAL,EAAA,CAAW,CAAC,GAAG,iBAAeU,GACnF,UAAA;AAAA,IAAAN;AAAA,IACD,gBAAAW;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,MAAAN;AAAA,QACA,KAAAG;AAAA,QACA,UAAAL;AAAA,QACA,OAAAD;AAAA,QACA,cAAAE;AAAA,QACA,UAAAE;AAAA,QACC,GAAIT,GAAW,cAAc,CAAA;AAAA,QAC9B,WAAWa;AAAA,UACT;AAAA,UACCV,IAA0B,cAAT;AAAA,UAClBH,GAAW,YAAY;AAAA,QAAA;AAAA,MACzB;AAAA,IAAA;AAAA,IAED,OAAOC,KAAW,YAAY,OAAOA,KAAW,WAC/C,gBAAAa,EAAC,QAAA,EAAK,WAAU,iGAAiG,UAAAb,EAAA,CAAO,IAExHA;AAAA,IAEDC;AAAA,EAAA,GACH;AAGN;AACAL,EAAU,cAAc;"}
@@ -31,7 +31,7 @@ const w = () => ({ hour: (/* @__PURE__ */ new Date()).getHours() % 12, minute: (
31
31
  {
32
32
  style: { height: n, marginBottom: l },
33
33
  className: u(
34
- "w-full flex justify-center items-center rounded-full text-sm font-bold text-text-400",
34
+ "w-full flex justify-center items-center rounded-full text-xs font-bold text-text-400",
35
35
  t + 1 === r.hour && "bg-secondary"
36
36
  ),
37
37
  onClick: () => p(t + 1),
@@ -44,7 +44,7 @@ const w = () => ({ hour: (/* @__PURE__ */ new Date()).getHours() % 12, minute: (
44
44
  {
45
45
  style: { height: n, marginBottom: l },
46
46
  className: u(
47
- "w-full flex justify-center items-center rounded-full text-sm font-bold text-text-400",
47
+ "w-full flex justify-center items-center rounded-full text-xs font-bold text-text-400",
48
48
  t === r.minute && "bg-secondary"
49
49
  ),
50
50
  onClick: () => v(t),
@@ -57,7 +57,7 @@ const w = () => ({ hour: (/* @__PURE__ */ new Date()).getHours() % 12, minute: (
57
57
  {
58
58
  style: { height: n, marginBottom: l },
59
59
  className: u(
60
- "w-full flex justify-center items-center rounded-full text-sm font-bold text-text-400",
60
+ "w-full flex justify-center items-center rounded-full text-xs font-bold text-text-400",
61
61
  t === r.ampm && "bg-secondary"
62
62
  ),
63
63
  onClick: () => M(t),
@@ -1 +1 @@
1
- {"version":3,"file":"timepickercontent.es.js","sources":["../src/components/date-picker/TimePickerContent.tsx"],"sourcesContent":["import { HTMLAttributes, useEffect, useRef, useState } from \"react\";\r\n\r\nimport { cn } from \"../../lib/utils\";\r\n\r\ntype Time = { hour: number; minute: number; ampm: \"AM\" | \"PM\" };\r\n\r\ntype TimePickerContentProps = {\r\n time: Time | undefined;\r\n isOpen: boolean;\r\n onTimeChange: (time: Time | undefined) => void;\r\n slotsProps?: {\r\n content?: HTMLAttributes<HTMLDivElement>;\r\n };\r\n};\r\n\r\nconst getNow = (): Time => {\r\n return { hour: new Date().getHours() % 12, minute: new Date().getMinutes(), ampm: new Date().getHours() < 12 ? \"AM\" : \"PM\" };\r\n};\r\n\r\nconst TimePickerContent: React.FC<TimePickerContentProps> = ({ isOpen, time, onTimeChange, slotsProps }) => {\r\n const [selectedtime, setSelectedTime] = useState<Time>(time ?? getNow());\r\n const selectedTimeRef = useRef<Time>(selectedtime);\r\n\r\n const hourRef = useRef<HTMLDivElement>(null);\r\n const minuteRef = useRef<HTMLDivElement>(null);\r\n\r\n const itemHeight = 32; // Assuming each item height is 40px\r\n const marginBetweenItems = 8; // Assuming margin between each item is 8px\r\n\r\n // Function to scroll to a specific hour\r\n const scrollToHour = (index: number) => {\r\n hourRef?.current?.scrollTo({\r\n top: index * (itemHeight + marginBetweenItems),\r\n behavior: \"smooth\",\r\n });\r\n };\r\n\r\n // Function to scroll to a specific minute\r\n const scrollToMinute = (index: number) => {\r\n minuteRef?.current?.scrollTo({\r\n top: index * (itemHeight + marginBetweenItems),\r\n behavior: \"smooth\",\r\n });\r\n };\r\n\r\n const handleSethour = (hour: number) => {\r\n selectedTimeRef.current = { ...selectedtime, hour };\r\n setSelectedTime(selectedTimeRef.current);\r\n onTimeChange(selectedTimeRef.current);\r\n };\r\n\r\n const handleSetMinute = (minute: number) => {\r\n selectedTimeRef.current = { ...selectedtime, minute };\r\n setSelectedTime(selectedTimeRef.current);\r\n onTimeChange(selectedTimeRef.current);\r\n };\r\n\r\n const handleSetAMPM = (ampm: \"AM\" | \"PM\") => {\r\n selectedTimeRef.current = { ...selectedtime, ampm };\r\n setSelectedTime(selectedTimeRef.current);\r\n onTimeChange(selectedTimeRef.current);\r\n };\r\n\r\n useEffect(() => {\r\n if (isOpen) {\r\n setSelectedTime(time ?? getNow());\r\n }\r\n }, [isOpen, time]);\r\n\r\n useEffect(() => {\r\n // Center the selected hour/minute on mount\r\n if (isOpen) {\r\n setTimeout(() => {\r\n scrollToHour(selectedTimeRef.current.hour - 1);\r\n scrollToMinute(selectedTimeRef.current.minute);\r\n });\r\n }\r\n }, [isOpen]);\r\n\r\n return (\r\n <div {...(slotsProps?.content ?? {})} className={cn(\"py-2 px-0 h-52 w-full flex justify-center gap-1\", slotsProps?.content?.className)}>\r\n {/* Hour Selector */}\r\n <div className=\"w-24 px-2 h-full relative overflow-auto thin-scrollbar\" ref={hourRef}>\r\n {Array.from({ length: 12 }, (_, i) => i).map(hour => (\r\n <button\r\n style={{ height: itemHeight, marginBottom: marginBetweenItems }}\r\n className={cn(\r\n \"w-full flex justify-center items-center rounded-full text-sm font-bold text-text-400\",\r\n hour + 1 === selectedtime.hour && \"bg-secondary\",\r\n )}\r\n key={hour + 1}\r\n onClick={() => handleSethour(hour + 1)}\r\n >\r\n {(hour + 1).toString().padStart(2, \"0\")}\r\n </button>\r\n ))}\r\n </div>\r\n\r\n {/* Minute Selector */}\r\n <div className=\"h-full w-24 px-2 relative overflow-auto thin-scrollbar\" ref={minuteRef}>\r\n {Array.from({ length: 60 }, (_, i) => i).map(minute => (\r\n <button\r\n style={{ height: itemHeight, marginBottom: marginBetweenItems }}\r\n className={cn(\r\n \"w-full flex justify-center items-center rounded-full text-sm font-bold text-text-400\",\r\n minute === selectedtime.minute && \"bg-secondary\",\r\n )}\r\n key={minute}\r\n onClick={() => handleSetMinute(minute)}\r\n >\r\n {minute.toString().padStart(2, \"0\")}\r\n </button>\r\n ))}\r\n </div>\r\n\r\n {/* AM/PM Selector */}\r\n <div className=\"h-full w-24 px-2 relative overflow-auto thin-scrollbar\">\r\n {[\"AM\", \"PM\"].map(ampm => (\r\n <button\r\n style={{ height: itemHeight, marginBottom: marginBetweenItems }}\r\n className={cn(\r\n \"w-full flex justify-center items-center rounded-full text-sm font-bold text-text-400\",\r\n ampm === selectedtime.ampm && \"bg-secondary\",\r\n )}\r\n key={ampm}\r\n onClick={() => handleSetAMPM(ampm as \"AM\" | \"PM\")}\r\n >\r\n {ampm}\r\n </button>\r\n ))}\r\n </div>\r\n </div>\r\n );\r\n};\r\nexport { TimePickerContent, type TimePickerContentProps, type Time };\r\n"],"names":["getNow","TimePickerContent","isOpen","time","onTimeChange","slotsProps","selectedtime","setSelectedTime","useState","selectedTimeRef","useRef","hourRef","minuteRef","itemHeight","marginBetweenItems","scrollToHour","index","scrollToMinute","handleSethour","hour","handleSetMinute","minute","handleSetAMPM","ampm","useEffect","jsxs","cn","jsx","_","i"],"mappings":";;;AAeA,MAAMA,IAAS,OACN,EAAE,OAAM,oBAAI,KAAA,GAAO,aAAa,IAAI,SAAQ,oBAAI,KAAA,GAAO,WAAA,GAAc,OAAM,oBAAI,KAAA,GAAO,aAAa,KAAK,OAAO,KAAA,IAGlHC,IAAsD,CAAC,EAAE,QAAAC,GAAQ,MAAAC,GAAM,cAAAC,GAAc,YAAAC,QAAiB;AAC1G,QAAM,CAACC,GAAcC,CAAe,IAAIC,EAAeL,KAAQH,GAAQ,GACjES,IAAkBC,EAAaJ,CAAY,GAE3CK,IAAUD,EAAuB,IAAI,GACrCE,IAAYF,EAAuB,IAAI,GAEvCG,IAAa,IACbC,IAAqB,GAGrBC,IAAe,CAACC,MAAkB;AACtC,IAAAL,GAAS,SAAS,SAAS;AAAA,MACzB,KAAKK,KAASH,IAAaC;AAAA,MAC3B,UAAU;AAAA,IAAA,CACX;AAAA,EACH,GAGMG,IAAiB,CAACD,MAAkB;AACxC,IAAAJ,GAAW,SAAS,SAAS;AAAA,MAC3B,KAAKI,KAASH,IAAaC;AAAA,MAC3B,UAAU;AAAA,IAAA,CACX;AAAA,EACH,GAEMI,IAAgB,CAACC,MAAiB;AACtC,IAAAV,EAAgB,UAAU,EAAE,GAAGH,GAAc,MAAAa,EAAA,GAC7CZ,EAAgBE,EAAgB,OAAO,GACvCL,EAAaK,EAAgB,OAAO;AAAA,EACtC,GAEMW,IAAkB,CAACC,MAAmB;AAC1C,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P,GAC1E,gBAAM,KAAK,EAAE,QAAQ,GAAA,GAAM,CAACgB,GAAGC,MAAMA,CAAC,EAAE,IAAI,CAAAR,MAC3C,gBAAAM;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,OAAO,EAAE,QAAQd,GAAY,cAAcC,EAAA;AAAA,QAC3C,WAAWY;AAAA,UACT;AAAA,UACAL,MAAWf,EAAa,UAAU;AAAA,QAAA;AAAA,QAGpC,SAAS,MAAMc,EAAgBC,CAAM;AAAA,QAEpC,UAAAA,EAAO,SAAA,EAAW,SAAS,GAAG,GAAG;AAAA,MAAA;AAAA,MAH7BA;AAAA,IAAA,CAKR,GACH;AAAA,IAGA,gBAAAM,EAAC,SAAI,WAAU,0DACZ,WAAC,MAAM,IAAI,EAAE,IAAI,CAAAJ,MAChB,gBAAAI;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,OAAO,EAAE,QAAQd,GAAY,cAAcC,EAAA;AAAA,QAC3C,WAAWY;AAAA,UACT;AAAA,UACAH,MAASjB,EAAa,QAAQ;AAAA,QAAA;AAAA,QAGhC,SAAS,MAAMgB,EAAcC,CAAmB;AAAA,QAE/C,UAAAA;AAAA,MAAA;AAAA,MAHIA;AAAA,IAAA,CAKR,EAAA,CACH;AAAA,EAAA,GACF;AAEJ;"}
1
+ {"version":3,"file":"timepickercontent.es.js","sources":["../src/components/date-picker/TimePickerContent.tsx"],"sourcesContent":["import { HTMLAttributes, useEffect, useRef, useState } from \"react\";\r\n\r\nimport { cn } from \"../../lib/utils\";\r\n\r\ntype Time = { hour: number; minute: number; ampm: \"AM\" | \"PM\" };\r\n\r\ntype TimePickerContentProps = {\r\n time: Time | undefined;\r\n isOpen: boolean;\r\n onTimeChange: (time: Time | undefined) => void;\r\n slotsProps?: {\r\n content?: HTMLAttributes<HTMLDivElement>;\r\n };\r\n};\r\n\r\nconst getNow = (): Time => {\r\n return { hour: new Date().getHours() % 12, minute: new Date().getMinutes(), ampm: new Date().getHours() < 12 ? \"AM\" : \"PM\" };\r\n};\r\n\r\nconst TimePickerContent: React.FC<TimePickerContentProps> = ({ isOpen, time, onTimeChange, slotsProps }) => {\r\n const [selectedtime, setSelectedTime] = useState<Time>(time ?? getNow());\r\n const selectedTimeRef = useRef<Time>(selectedtime);\r\n\r\n const hourRef = useRef<HTMLDivElement>(null);\r\n const minuteRef = useRef<HTMLDivElement>(null);\r\n\r\n const itemHeight = 32; // Assuming each item height is 40px\r\n const marginBetweenItems = 8; // Assuming margin between each item is 8px\r\n\r\n // Function to scroll to a specific hour\r\n const scrollToHour = (index: number) => {\r\n hourRef?.current?.scrollTo({\r\n top: index * (itemHeight + marginBetweenItems),\r\n behavior: \"smooth\",\r\n });\r\n };\r\n\r\n // Function to scroll to a specific minute\r\n const scrollToMinute = (index: number) => {\r\n minuteRef?.current?.scrollTo({\r\n top: index * (itemHeight + marginBetweenItems),\r\n behavior: \"smooth\",\r\n });\r\n };\r\n\r\n const handleSethour = (hour: number) => {\r\n selectedTimeRef.current = { ...selectedtime, hour };\r\n setSelectedTime(selectedTimeRef.current);\r\n onTimeChange(selectedTimeRef.current);\r\n };\r\n\r\n const handleSetMinute = (minute: number) => {\r\n selectedTimeRef.current = { ...selectedtime, minute };\r\n setSelectedTime(selectedTimeRef.current);\r\n onTimeChange(selectedTimeRef.current);\r\n };\r\n\r\n const handleSetAMPM = (ampm: \"AM\" | \"PM\") => {\r\n selectedTimeRef.current = { ...selectedtime, ampm };\r\n setSelectedTime(selectedTimeRef.current);\r\n onTimeChange(selectedTimeRef.current);\r\n };\r\n\r\n useEffect(() => {\r\n if (isOpen) {\r\n setSelectedTime(time ?? getNow());\r\n }\r\n }, [isOpen, time]);\r\n\r\n useEffect(() => {\r\n // Center the selected hour/minute on mount\r\n if (isOpen) {\r\n setTimeout(() => {\r\n scrollToHour(selectedTimeRef.current.hour - 1);\r\n scrollToMinute(selectedTimeRef.current.minute);\r\n });\r\n }\r\n }, [isOpen]);\r\n\r\n return (\r\n <div {...(slotsProps?.content ?? {})} className={cn(\"py-2 px-0 h-52 w-full flex justify-center gap-1\", slotsProps?.content?.className)}>\r\n {/* Hour Selector */}\r\n <div className=\"w-24 px-2 h-full relative overflow-auto thin-scrollbar\" ref={hourRef}>\r\n {Array.from({ length: 12 }, (_, i) => i).map(hour => (\r\n <button\r\n style={{ height: itemHeight, marginBottom: marginBetweenItems }}\r\n className={cn(\r\n \"w-full flex justify-center items-center rounded-full text-xs font-bold text-text-400\",\r\n hour + 1 === selectedtime.hour && \"bg-secondary\",\r\n )}\r\n key={hour + 1}\r\n onClick={() => handleSethour(hour + 1)}\r\n >\r\n {(hour + 1).toString().padStart(2, \"0\")}\r\n </button>\r\n ))}\r\n </div>\r\n\r\n {/* Minute Selector */}\r\n <div className=\"h-full w-24 px-2 relative overflow-auto thin-scrollbar\" ref={minuteRef}>\r\n {Array.from({ length: 60 }, (_, i) => i).map(minute => (\r\n <button\r\n style={{ height: itemHeight, marginBottom: marginBetweenItems }}\r\n className={cn(\r\n \"w-full flex justify-center items-center rounded-full text-xs font-bold text-text-400\",\r\n minute === selectedtime.minute && \"bg-secondary\",\r\n )}\r\n key={minute}\r\n onClick={() => handleSetMinute(minute)}\r\n >\r\n {minute.toString().padStart(2, \"0\")}\r\n </button>\r\n ))}\r\n </div>\r\n\r\n {/* AM/PM Selector */}\r\n <div className=\"h-full w-24 px-2 relative overflow-auto thin-scrollbar\">\r\n {[\"AM\", \"PM\"].map(ampm => (\r\n <button\r\n style={{ height: itemHeight, marginBottom: marginBetweenItems }}\r\n className={cn(\r\n \"w-full flex justify-center items-center rounded-full text-xs font-bold text-text-400\",\r\n ampm === selectedtime.ampm && \"bg-secondary\",\r\n )}\r\n key={ampm}\r\n onClick={() => handleSetAMPM(ampm as \"AM\" | \"PM\")}\r\n >\r\n {ampm}\r\n </button>\r\n ))}\r\n </div>\r\n </div>\r\n );\r\n};\r\nexport { TimePickerContent, type TimePickerContentProps, type Time };\r\n"],"names":["getNow","TimePickerContent","isOpen","time","onTimeChange","slotsProps","selectedtime","setSelectedTime","useState","selectedTimeRef","useRef","hourRef","minuteRef","itemHeight","marginBetweenItems","scrollToHour","index","scrollToMinute","handleSethour","hour","handleSetMinute","minute","handleSetAMPM","ampm","useEffect","jsxs","cn","jsx","_","i"],"mappings":";;;AAeA,MAAMA,IAAS,OACN,EAAE,OAAM,oBAAI,KAAA,GAAO,aAAa,IAAI,SAAQ,oBAAI,KAAA,GAAO,WAAA,GAAc,OAAM,oBAAI,KAAA,GAAO,aAAa,KAAK,OAAO,KAAA,IAGlHC,IAAsD,CAAC,EAAE,QAAAC,GAAQ,MAAAC,GAAM,cAAAC,GAAc,YAAAC,QAAiB;AAC1G,QAAM,CAACC,GAAcC,CAAe,IAAIC,EAAeL,KAAQH,GAAQ,GACjES,IAAkBC,EAAaJ,CAAY,GAE3CK,IAAUD,EAAuB,IAAI,GACrCE,IAAYF,EAAuB,IAAI,GAEvCG,IAAa,IACbC,IAAqB,GAGrBC,IAAe,CAACC,MAAkB;AACtC,IAAAL,GAAS,SAAS,SAAS;AAAA,MACzB,KAAKK,KAASH,IAAaC;AAAA,MAC3B,UAAU;AAAA,IAAA,CACX;AAAA,EACH,GAGMG,IAAiB,CAACD,MAAkB;AACxC,IAAAJ,GAAW,SAAS,SAAS;AAAA,MAC3B,KAAKI,KAASH,IAAaC;AAAA,MAC3B,UAAU;AAAA,IAAA,CACX;AAAA,EACH,GAEMI,IAAgB,CAACC,MAAiB;AACtC,IAAAV,EAAgB,UAAU,EAAE,GAAGH,GAAc,MAAAa,EAAA,GAC7CZ,EAAgBE,EAAgB,OAAO,GACvCL,EAAaK,EAAgB,OAAO;AAAA,EACtC,GAEMW,IAAkB,CAACC,MAAmB;AAC1C,IAAAZ,EAAgB,UAAU,EAAE,GAAGH,GAAc,QAAAe,EAAA,GAC7Cd,EAAgBE,EAAgB,OAAO,GACvCL,EAAaK,EAAgB,OAAO;AAAA,EACtC,GAEMa,IAAgB,CAACC,MAAsB;AAC3C,IAAAd,EAAgB,UAAU,EAA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AAAA,QAC3C,WAAWY;AAAA,UACT;AAAA,UACAL,MAAWf,EAAa,UAAU;AAAA,QAAA;AAAA,QAGpC,SAAS,MAAMc,EAAgBC,CAAM;AAAA,QAEpC,UAAAA,EAAO,SAAA,EAAW,SAAS,GAAG,GAAG;AAAA,MAAA;AAAA,MAH7BA;AAAA,IAAA,CAKR,GACH;AAAA,IAGA,gBAAAM,EAAC,SAAI,WAAU,0DACZ,WAAC,MAAM,IAAI,EAAE,IAAI,CAAAJ,MAChB,gBAAAI;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,OAAO,EAAE,QAAQd,GAAY,cAAcC,EAAA;AAAA,QAC3C,WAAWY;AAAA,UACT;AAAA,UACAH,MAASjB,EAAa,QAAQ;AAAA,QAAA;AAAA,QAGhC,SAAS,MAAMgB,EAAcC,CAAmB;AAAA,QAE/C,UAAAA;AAAA,MAAA;AAAA,MAHIA;AAAA,IAAA,CAKR,EAAA,CACH;AAAA,EAAA,GACF;AAEJ;"}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@trsys-tech/matrix-library",
3
3
  "description": "MatrixUI Library",
4
4
  "private": false,
5
- "version": "0.5.1-alpha.0",
5
+ "version": "0.5.1-beta.1",
6
6
  "type": "module",
7
7
  "main": "dist/index.js",
8
8
  "module": "dist/index.es.js",
@@ -16,7 +16,7 @@
16
16
  },
17
17
  "./package.json": "./package.json",
18
18
  "./dist/*": "./dist/*",
19
- "./style.css": "./dist/style.css"
19
+ "./styles.css": "./dist/styles.css"
20
20
  },
21
21
  "files": [
22
22
  "dist"