torch-glare 1.1.6 → 1.1.7

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.
@@ -29,7 +29,7 @@ export function getDependenciesAndInstallNestedComponents(componentPath, install
29
29
  else if (moduleName &&
30
30
  moduleName.startsWith("../hooks") &&
31
31
  !installedDependencies.has(moduleName)) {
32
- addHook(moduleName.slice(9) + ".tsx");
32
+ addHook(moduleName.slice(9) + ".ts");
33
33
  }
34
34
  // install required nested components
35
35
  else if (moduleName &&
@@ -1 +1 @@
1
- {"version":3,"file":"getDependenciesAndInstallNestedComponents.js","sourceRoot":"","sources":["../../../cli/src/shared/getDependenciesAndInstallNestedComponents.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAEzC;;;;;GAKG;AAEH,MAAM,UAAU,yCAAyC,CACrD,aAAqB,EACrB,qBAAkC;IAElC,MAAM,gBAAgB,GAAG,EAAE,CAAC,YAAY,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;IACjE,MAAM,WAAW,GAAG,yCAAyC,CAAC;IAC9D,MAAM,qBAAqB,GAAG,IAAI,GAAG,EAAU,CAAC;IAEhD,IAAI,KAAK,CAAC;IACV,OAAO,CAAC,KAAK,GAAG,WAAW,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;QAC3D,MAAM,UAAU,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QAE5B,sCAAsC;QACtC,IAAI,UAAU,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;YACtF,qBAAqB,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QAC1C,CAAC;QAED,oCAAoC;aAC/B,IACD,UAAU;YACV,UAAU,CAAC,UAAU,CAAC,UAAU,CAAC;YACjC,CAAC,qBAAqB,CAAC,GAAG,CAAC,UAAU,CAAC,EACxC,CAAC;YACC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC;QACzC,CAAC;QAED,oCAAoC;aAC/B,IACD,UAAU;YACV,UAAU,CAAC,UAAU,CAAC,UAAU,CAAC;YACjC,CAAC,qBAAqB,CAAC,GAAG,CAAC,UAAU,CAAC,EACxC,CAAC;YACC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC;QAC1C,CAAC;QACD,qCAAqC;aAChC,IACD,UAAU;YACV,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC;gBACxB,CAAC,UAAU,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC;YAC5C,CAAC,qBAAqB,CAAC,GAAG,CAAC,UAAU,CAAC,EACxC,CAAC;YACC,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC;QACtC,CAAC;QACD,0CAA0C;aACrC,IACD,UAAU;YACV,UAAU,CAAC,UAAU,CAAC,eAAe,CAAC;YACtC,CAAC,qBAAqB,CAAC,GAAG,CAAC,UAAU,CAAC,EACxC,CAAC;YACC,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC;QACvC,CAAC;IACL,CAAC;IAED,OAAO,qBAAqB,CAAC;AACjC,CAAC"}
1
+ {"version":3,"file":"getDependenciesAndInstallNestedComponents.js","sourceRoot":"","sources":["../../../cli/src/shared/getDependenciesAndInstallNestedComponents.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,EAAE,OAAO,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AAU;YACV,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC;gBACxB,CAAC,UAAU,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC;YAC5C,CAAC,qBAAqB,CAAC,GAAG,CAAC,UAAU,CAAC,EACxC,CAAC;YACC,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC;QACtC,CAAC;QACD,0CAA0C;aACrC,IACD,UAAU;YACV,UAAU,CAAC,UAAU,CAAC,eAAe,CAAC;YACtC,CAAC,qBAAqB,CAAC,GAAG,CAAC,UAAU,CAAC,EACxC,CAAC;YACC,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC;QACvC,CAAC;IACL,CAAC;IAED,OAAO,qBAAqB,CAAC;AACjC,CAAC"}
@@ -6,14 +6,14 @@ import React, {
6
6
  useEffect,
7
7
  cloneElement,
8
8
  isValidElement,
9
+ useRef,
10
+ Ref,
9
11
  } from "react";
10
12
  import { Popover, PopoverContent, PopoverTrigger } from "./Popover";
11
13
  import { Calendar } from "./Calendar";
12
- import { Input, Trilling } from "./Input";
13
14
  import { ActionButton } from "./ActionButton";
14
- import { Group } from "./Input";
15
15
  import { DateRange } from "react-day-picker";
16
- import Picker, { PickerValue } from "torch-react-mobile-picker";
16
+ import Picker from "torch-react-mobile-picker";
17
17
 
18
18
  import {
19
19
  applyTimeToDateValue,
@@ -59,7 +59,9 @@ export const DatePicker = forwardRef(
59
59
  ) => {
60
60
  const initialDate =
61
61
  mode == "multiple"
62
- ? [value]
62
+ ? Array.isArray(value)
63
+ ? value
64
+ : [value]
63
65
  : mode == "range"
64
66
  ? { from: value, to: value }
65
67
  : value;
@@ -72,6 +74,7 @@ export const DatePicker = forwardRef(
72
74
  time: date instanceof Date && date.getHours() < 12 ? "AM" : "PM",
73
75
  });
74
76
  const [isOpen, setIsOpen] = useState(false);
77
+ const triggerRef = useRef<HTMLButtonElement>(null);
75
78
 
76
79
  // Call the onChange function when the date or picker value changes
77
80
  useEffect(() => {
@@ -103,7 +106,7 @@ export const DatePicker = forwardRef(
103
106
 
104
107
  return (
105
108
  <Popover onOpenChange={setIsOpen}>
106
- <PopoverTrigger asChild>
109
+ <PopoverTrigger ref={triggerRef} asChild>
107
110
  {/* Clone the children element and pass the formatted value to the input element */}
108
111
  {isValidElement(children) ? (
109
112
  cloneElement(children as React.ReactElement<HTMLInputElement>, {
@@ -119,7 +122,9 @@ export const DatePicker = forwardRef(
119
122
  readOnly
120
123
  type="input"
121
124
  childrenSide={
122
- <ActionButton type="button" size={"M"}>
125
+ <ActionButton type="button" size={"M"} onClick={() => {
126
+ triggerRef.current?.click();
127
+ }}>
123
128
  <i className="ri-calendar-event-fill"></i>
124
129
  </ActionButton>
125
130
  }
@@ -45,13 +45,14 @@ export const Icon = ({ children, className }: IconProps) => {
45
45
  };
46
46
 
47
47
 
48
- interface TrillingProps {
48
+ interface TrillingProps extends HTMLAttributes<HTMLDivElement> {
49
49
  children: React.ReactNode;
50
50
  className?: string;
51
51
  }
52
- export const Trilling = ({ children, className }: TrillingProps) => {
52
+ export const Trilling = ({ children, className, ...props }: TrillingProps) => {
53
53
  return (
54
54
  <div
55
+ {...props}
55
56
  className={cn(
56
57
  "flex items-center justify-center h-full gap-1 py-1",
57
58
  className
@@ -96,7 +97,7 @@ export const Input = forwardRef<HTMLInputElement, InputProps>(
96
97
  autoComplete="off"
97
98
  className={cn(
98
99
  // Base styles
99
- "typography-body-large-regular focus:pe-[30px]",
100
+ "typography-body-large-regular",
100
101
  "text-content-presentation-action-light-primary",
101
102
  "bg-transparent",
102
103
  "h-full",
@@ -48,6 +48,7 @@ export const InputField = forwardRef<HTMLInputElement, Props>(
48
48
  const [isPopoverOpen, setIsPopoverOpen] = useState(false);
49
49
  const [PopoverWidth, setPopoverWidth] = useState(0);
50
50
  const inputRef = useRef<HTMLInputElement>(null);
51
+ const triggerRef = useRef<HTMLButtonElement>(null);
51
52
 
52
53
  useEffect(() => {
53
54
  if (!forwardedRef) return;
@@ -56,14 +57,14 @@ export const InputField = forwardRef<HTMLInputElement, Props>(
56
57
  }, [forwardedRef]);
57
58
  // TODO: make the user input visible when input is focused
58
59
  return (
59
- <Popover open={isPopoverOpen}>
60
+ <Popover onOpenChange={setIsPopoverOpen}>
60
61
  <Tooltip
61
62
  theme={theme}
62
63
  toolTipSide={toolTipSide}
63
64
  open={errorMessage !== undefined}
64
65
  text={errorMessage}
65
66
  >
66
- <PopoverTrigger asChild>
67
+ <PopoverTrigger ref={triggerRef} asChild>
67
68
  <Group
68
69
  error={errorMessage !== undefined}
69
70
  onTable={onTable}
@@ -113,6 +114,9 @@ export const InputField = forwardRef<HTMLInputElement, Props>(
113
114
  variant={variant}
114
115
  onOpenAutoFocus={(e: any) => e.preventDefault()}
115
116
  style={{ width: PopoverWidth }}
117
+ onClick={(e) => {
118
+ triggerRef.current?.click();
119
+ }}
116
120
  >
117
121
  {popoverChildren}
118
122
  </PopoverContent>
@@ -1,4 +1,4 @@
1
- import React, { AnchorHTMLAttributes, HTMLAttributes, SVGProps } from "react";
1
+ import React, { HTMLAttributes, SVGProps } from "react";
2
2
  import { cva } from "class-variance-authority";
3
3
  import { cn } from "../utils/cn";
4
4
  import { Themes } from "../utils/types";
@@ -1,6 +1,6 @@
1
1
  import { forwardRef, ReactNode } from "react";
2
2
  import { cn } from "../utils/cn";
3
- import { Radio, RadioGroup } from "./Radio";
3
+ import { Radio } from "./Radio";
4
4
  import { Card, CardContent, CardDescription, CardHeader } from "./Card";
5
5
 
6
6
 
@@ -1,10 +1,10 @@
1
- import { cloneElement, ComponentProps, forwardRef, isValidElement, useState, useEffect } from 'react';
1
+ import { cloneElement, ComponentProps, forwardRef, isValidElement, useState, useEffect, useRef } from 'react';
2
2
  import { getDaysInMonth } from 'date-fns';
3
3
  import Picker from 'torch-react-mobile-picker';
4
4
  import { Popover, PopoverContent, PopoverTrigger } from './Popover';
5
5
  import { InputField } from './InputField';
6
6
  import { ActionButton } from './ActionButton';
7
- import { formatDateValueToString } from '@/utils/dateFormat';
7
+ import { formatDateValueToString } from '../utils/dateFormat';
8
8
 
9
9
  function getDayArray(year: number, month: number): string[] {
10
10
  const dayCount = getDaysInMonth(new Date(year, month - 1));
@@ -15,9 +15,10 @@ interface SlideDatePickerProps extends Omit<ComponentProps<typeof InputField>, '
15
15
  onChange?: (e: any) => void;
16
16
  theme?: "dark" | "light" | "default";
17
17
  dateFormat?: string;
18
+ value?: any;
18
19
  }
19
20
 
20
- type SlideVlaues = {
21
+ type SlideValues = {
21
22
  year: string,
22
23
  month: string,
23
24
  day: string,
@@ -32,22 +33,25 @@ export const SlideDatePicker = forwardRef<HTMLInputElement, SlideDatePickerProps
32
33
  onChange,
33
34
  dateFormat = "yyyy/MM/dd",
34
35
  children,
36
+ value = new Date(),
35
37
  ...props
36
38
  }, forwardedRef) => {
37
39
 
38
- const today = new Date();
40
+ const today = value
39
41
  const defaultPickerValue = {
40
42
  year: String(today.getFullYear()),
41
- month: String(today.getMonth() + 1).padStart(2, '0'),
42
- day: String(today.getDate()).padStart(2, '0'),
43
- hour: "00",
44
- minute: "00",
45
- time: "AM"
43
+ month: String(today.getMonth() + 1),
44
+ day: String(today.getDate()),
45
+ hour: String(today.getHours()),
46
+ minute: String(today.getMinutes()),
47
+ time: today.getHours() < 12 ? "AM" : "PM"
46
48
  };
47
49
 
48
- const [pickerValue, setPickerValue] = useState<SlideVlaues>(defaultPickerValue);
49
- const [date, setDate] = useState<Date>(new Date());
50
+ const [pickerValue, setPickerValue] = useState<SlideValues>(defaultPickerValue);
51
+ const [date, setDate] = useState<Date>(value);
50
52
  const [isOpen, setIsOpen] = useState(false);
53
+ const triggerRef = useRef<HTMLButtonElement>(null);
54
+
51
55
  const currentYear = new Date().getFullYear();
52
56
  const years = Array.from({ length: 200 }, (_, i) => `${currentYear - 100 + i}`);
53
57
  const months = Array.from({ length: 12 }, (_, i) => String(i + 1).padStart(2, ''));
@@ -57,7 +61,7 @@ export const SlideDatePicker = forwardRef<HTMLInputElement, SlideDatePickerProps
57
61
  "July", "August", "September", "October", "November", "December",
58
62
  ];
59
63
 
60
- const handlePickerChange = (newValue: SlideVlaues, key: string) => {
64
+ const handlePickerChange = (newValue: SlideValues, key: string) => {
61
65
  let { year, month, day, hour, minute, time } = newValue;
62
66
 
63
67
  if (key === 'year' || key === 'month') {
@@ -118,7 +122,7 @@ export const SlideDatePicker = forwardRef<HTMLInputElement, SlideDatePickerProps
118
122
 
119
123
  return (
120
124
  <Popover onOpenChange={setIsOpen}>
121
- <PopoverTrigger asChild data-theme={theme} className='w-full flex-1' >
125
+ <PopoverTrigger ref={triggerRef} asChild data-theme={theme} className='w-full flex-1' >
122
126
  {
123
127
  isValidElement(children) ?
124
128
  cloneElement(children as React.ReactElement<HTMLInputElement>, {
@@ -131,12 +135,14 @@ export const SlideDatePicker = forwardRef<HTMLInputElement, SlideDatePickerProps
131
135
  <InputField
132
136
  readOnly
133
137
  type="input"
138
+ {...props}
134
139
  childrenSide={
135
- <ActionButton type='button' size={"M"}>
140
+ <ActionButton type='button' size={"M"} onClick={() => {
141
+ triggerRef.current?.click();
142
+ }}>
136
143
  <i className="ri-calendar-event-fill"></i>
137
144
  </ActionButton>
138
145
  }
139
- {...props}
140
146
  value={formattedValue}
141
147
  ref={forwardedRef}
142
148
  />
@@ -2,7 +2,6 @@ import * as React from "react";
2
2
  import { cn } from "../utils/cn";
3
3
  import { Label } from "./Label";
4
4
  import { cva, VariantProps } from "class-variance-authority";
5
- import { Input } from "./Input";
6
5
 
7
6
  // Define the styles for the textarea using cva
8
7
  const textareaStyles = cva(
@@ -0,0 +1,87 @@
1
+ import React from 'react'
2
+ import { Toaster as ToasterComponent, toast } from 'react-hot-toast'
3
+
4
+
5
+ const Toaster = ({
6
+ position = 'top-left',
7
+ reverseOrder = false,
8
+ gutter = 8,
9
+ containerClassName = '',
10
+ containerStyle = {},
11
+ toastOptions = {},
12
+ ...props }: React.ComponentPropsWithoutRef<typeof ToasterComponent>) => {
13
+ return (
14
+ <ToasterComponent
15
+ position={position}
16
+ reverseOrder={reverseOrder}
17
+ gutter={gutter}
18
+ containerClassName={containerClassName}
19
+ containerStyle={containerStyle}
20
+ {...props}
21
+ toastOptions={{
22
+ // Define default options
23
+ className: '',
24
+ duration: 8000,
25
+ removeDelay: 1000,
26
+ style: {
27
+ background: 'var(--background-presentation-state-information-secondary)',
28
+ color: 'var(--content-presentation-global-primary)',
29
+ borderRadius: '16px',
30
+ },
31
+
32
+ // Default options for specific types
33
+ success: {
34
+ duration: 3000,
35
+ style: {
36
+ background: 'var(--background-presentation-state-success-secondary)',
37
+ color: 'var(--content-presentation-global-primary)',
38
+ borderRadius: '16px',
39
+ },
40
+ iconTheme: {
41
+ primary: 'var(--background-presentation-state-success-primary)',
42
+ secondary: 'var(--background-presentation-state-success-secondary)',
43
+ },
44
+ },
45
+ error: {
46
+ duration: 5000,
47
+ style: {
48
+ background: 'var(--background-presentation-state-negative-secondary)',
49
+ color: 'var(--content-presentation-global-primary)',
50
+ borderRadius: '16px',
51
+ },
52
+ iconTheme: {
53
+ primary: 'var(--background-presentation-state-negative-primary)',
54
+ secondary: 'var(--background-presentation-state-negative-secondary)',
55
+ },
56
+ },
57
+ loading: {
58
+ duration: 4000,
59
+ style: {
60
+ background: 'var(--background-presentation-state-warning-secondary)',
61
+ color: 'var(--content-presentation-global-primary)',
62
+ borderRadius: '16px',
63
+ },
64
+ iconTheme: {
65
+ primary: 'var(--background-presentation-state-warning-primary)',
66
+ secondary: 'var(--background-presentation-state-warning-secondary)',
67
+ },
68
+ },
69
+ blank: {
70
+ duration: 4000,
71
+ style: {
72
+ background: 'var(--background-presentation-state-information-secondary)',
73
+ color: 'var(--content-presentation-global-primary)',
74
+ borderRadius: '16px',
75
+ },
76
+ iconTheme: {
77
+ primary: 'var(--background-presentation-state-information-primary)',
78
+ secondary: 'var(--background-presentation-state-information-secondary)',
79
+ },
80
+ },
81
+ ...toastOptions,
82
+ }}
83
+ />
84
+ )
85
+ }
86
+
87
+ export { Toaster, toast }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "torch-glare",
3
- "version": "1.1.6",
3
+ "version": "1.1.7",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "files": [
File without changes