@julseb-lib/react 0.0.88 → 0.0.89

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.
@@ -1,21 +1,20 @@
1
1
  import { useRef, type ChangeEvent, type FC } from "react"
2
- import { useClickOutside } from "../../"
2
+ import { useClickOutside, designTokens } from "../../"
3
3
  import {
4
- InputContainer,
5
- InputAndListContainer,
6
- InputWrapper,
7
- InputLeftContainer,
8
- InputPrefix,
9
- InputIcon,
10
- InputRightContainer,
11
- InputButton,
12
- InputValidationIcon,
13
- ListInput,
14
- ListInputItem,
4
+ InputContainer,
5
+ InputAndListContainer,
6
+ InputWrapper,
7
+ InputLeftContainer,
8
+ InputPrefix,
9
+ InputIcon,
10
+ InputRightContainer,
11
+ InputButton,
12
+ InputValidationIcon,
13
+ ListInput,
14
+ ListInputItem,
15
15
  } from "../InputComponents"
16
16
  import { Clock } from "../../icons"
17
17
  import { useKeyboardNavigation } from "../ComponentsMixins"
18
- import { designTokens } from "../../types"
19
18
  import { InputTime } from "./styles"
20
19
  import type { ILibTimepicker } from "./types"
21
20
 
@@ -65,243 +64,243 @@ import type { ILibTimepicker } from "./types"
65
64
  * />
66
65
  */
67
66
  export const Timepicker: FC<ILibTimepicker> = ({
68
- "data-testid": testid,
69
- ref,
70
- className,
71
- icon,
72
- iconSize,
73
- iconBaseUrl,
74
- iconClockSize = 16,
75
- iconClock = (
76
- <Clock
77
- data-testid={testid && `${testid}.RightContainer.IconClock`}
78
- className={className && "IconClock"}
79
- size={iconClockSize}
80
- />
81
- ),
82
- id,
83
- label,
84
- labelComment,
85
- helper,
86
- helperBottom,
87
- validation,
88
- inputBackground,
89
- inputVariant,
90
- containerStyle,
91
- inputAndListContainerStyle,
92
- listDirection,
93
- step = "1h",
94
- minTime,
95
- maxTime,
96
- value,
97
- setValue,
98
- prefix,
99
- disabled,
100
- tabIndex,
101
- ...rest
67
+ "data-testid": testid,
68
+ ref,
69
+ className,
70
+ icon,
71
+ iconSize,
72
+ iconBaseUrl,
73
+ iconClockSize = 16,
74
+ iconClock = (
75
+ <Clock
76
+ data-testid={testid && `${testid}.RightContainer.IconClock`}
77
+ className={className && "IconClock"}
78
+ size={iconClockSize}
79
+ />
80
+ ),
81
+ id,
82
+ label,
83
+ labelComment,
84
+ helper,
85
+ helperBottom,
86
+ validation,
87
+ inputBackground,
88
+ inputVariant,
89
+ containerStyle,
90
+ inputAndListContainerStyle,
91
+ listDirection,
92
+ step = "1h",
93
+ minTime,
94
+ maxTime,
95
+ value,
96
+ setValue,
97
+ prefix,
98
+ disabled,
99
+ tabIndex,
100
+ ...rest
102
101
  }) => {
103
- const hasContainer: boolean = !!(
104
- label ||
105
- labelComment ||
106
- helper ||
107
- helperBottom ||
108
- validation
109
- )
102
+ const hasContainer: boolean = !!(
103
+ label ||
104
+ labelComment ||
105
+ helper ||
106
+ helperBottom ||
107
+ validation
108
+ )
110
109
 
111
- const el = useRef<HTMLDivElement>(null)
110
+ const el = useRef<HTMLDivElement>(null)
112
111
 
113
- let times: Array<string> =
114
- step === "30min"
115
- ? Object.keys(designTokens.halfHours)
116
- : step === "15min"
117
- ? Object.keys(designTokens.quarterHours)
118
- : step === "1min"
119
- ? Object.keys(designTokens.minutes)
120
- : Object.keys(designTokens.hours)
112
+ let times: Array<string> =
113
+ step === "30min"
114
+ ? Object.keys(designTokens.halfHours)
115
+ : step === "15min"
116
+ ? Object.keys(designTokens.quarterHours)
117
+ : step === "1min"
118
+ ? Object.keys(designTokens.minutes)
119
+ : Object.keys(designTokens.hours)
121
120
 
122
- if (minTime) {
123
- times = times.splice(
124
- times.indexOf(times.find(found => found === minTime)!),
125
- times.length - 1
126
- )
127
- }
121
+ if (minTime) {
122
+ times = times.splice(
123
+ times.indexOf(times.find(found => found === minTime)!),
124
+ times.length - 1
125
+ )
126
+ }
128
127
 
129
- if (maxTime) {
130
- times = times.splice(0, times.indexOf(maxTime) + 1)
131
- }
128
+ if (maxTime) {
129
+ times = times.splice(0, times.indexOf(maxTime) + 1)
130
+ }
132
131
 
133
- const { isOpen, setIsOpen, cursor, listRef } = useKeyboardNavigation<
134
- typeof times
135
- >({
136
- data: times,
137
- value,
138
- setValue,
139
- })
132
+ const { isOpen, setIsOpen, cursor, listRef } = useKeyboardNavigation<
133
+ typeof times
134
+ >({
135
+ data: times,
136
+ value,
137
+ setValue,
138
+ })
140
139
 
141
- const handleClick = () => {
142
- if (isOpen) setIsOpen(false)
143
- setIsOpen(true)
144
- }
140
+ const handleClick = () => {
141
+ if (isOpen) setIsOpen(false)
142
+ setIsOpen(true)
143
+ }
145
144
 
146
- const handleOpen = () => setIsOpen(true)
147
- const handleClose = () => setIsOpen(false)
145
+ const handleOpen = () => setIsOpen(true)
146
+ const handleClose = () => setIsOpen(false)
148
147
 
149
- const handleChange = (e: ChangeEvent<HTMLInputElement>) =>
150
- setValue(
151
- e.target.value as keyof typeof designTokens.hours &
152
- keyof typeof designTokens.halfHours &
153
- keyof typeof designTokens.quarterHours &
154
- keyof typeof designTokens.minutes
155
- )
148
+ const handleChange = (e: ChangeEvent<HTMLInputElement>) =>
149
+ setValue(
150
+ e.target.value as keyof typeof designTokens.hours &
151
+ keyof typeof designTokens.halfHours &
152
+ keyof typeof designTokens.quarterHours &
153
+ keyof typeof designTokens.minutes
154
+ )
156
155
 
157
- const handleSelectTime = (time: string) => {
158
- setValue(time as any)
159
- handleClose()
160
- }
156
+ const handleSelectTime = (time: string) => {
157
+ setValue(time as any)
158
+ handleClose()
159
+ }
161
160
 
162
- useClickOutside(listRef, handleClose)
161
+ useClickOutside(listRef, handleClose)
163
162
 
164
- return (
165
- <InputContainer
166
- data-testid={testid}
167
- id={id}
168
- label={label}
169
- labelComment={labelComment}
170
- helper={helper}
171
- helperBottom={helperBottom}
172
- validation={validation}
173
- value={value}
174
- className={className}
175
- iconBaseUrl={iconBaseUrl}
176
- style={containerStyle}
177
- hasListOpen={isOpen}
178
- counter={undefined}
179
- maxLength={undefined}
180
- >
181
- <InputAndListContainer
182
- data-testid={testid}
183
- className={className}
184
- hasListOpen={isOpen}
185
- isParent={!hasContainer}
186
- ref={el}
187
- inputAndListContainerStyle={inputAndListContainerStyle}
188
- >
189
- <InputWrapper
190
- data-testid={testid}
191
- className={className}
192
- isTextArea={false}
193
- inputBackground={inputBackground}
194
- inputVariant={inputVariant}
195
- validationStatus={validation?.status}
196
- hasListOpen={isOpen}
197
- hasContainer
198
- >
199
- {(icon || prefix) && (
200
- <InputLeftContainer
201
- data-testid={testid}
202
- className={className}
203
- disabled={disabled}
204
- >
205
- {prefix && (
206
- <InputPrefix
207
- data-testid={testid}
208
- className={className}
209
- prefix={prefix}
210
- inputBackground={inputBackground}
211
- />
212
- )}
163
+ return (
164
+ <InputContainer
165
+ data-testid={testid}
166
+ id={id}
167
+ label={label}
168
+ labelComment={labelComment}
169
+ helper={helper}
170
+ helperBottom={helperBottom}
171
+ validation={validation}
172
+ value={value}
173
+ className={className}
174
+ iconBaseUrl={iconBaseUrl}
175
+ style={containerStyle}
176
+ hasListOpen={isOpen}
177
+ counter={undefined}
178
+ maxLength={undefined}
179
+ >
180
+ <InputAndListContainer
181
+ data-testid={testid}
182
+ className={className}
183
+ hasListOpen={isOpen}
184
+ isParent={!hasContainer}
185
+ ref={el}
186
+ inputAndListContainerStyle={inputAndListContainerStyle}
187
+ >
188
+ <InputWrapper
189
+ data-testid={testid}
190
+ className={className}
191
+ isTextArea={false}
192
+ inputBackground={inputBackground}
193
+ inputVariant={inputVariant}
194
+ validationStatus={validation?.status}
195
+ hasListOpen={isOpen}
196
+ hasContainer
197
+ >
198
+ {(icon || prefix) && (
199
+ <InputLeftContainer
200
+ data-testid={testid}
201
+ className={className}
202
+ disabled={disabled}
203
+ >
204
+ {prefix && (
205
+ <InputPrefix
206
+ data-testid={testid}
207
+ className={className}
208
+ prefix={prefix}
209
+ inputBackground={inputBackground}
210
+ />
211
+ )}
213
212
 
214
- {icon && (
215
- <InputIcon
216
- data-testid={testid}
217
- className={className}
218
- icon={icon}
219
- iconSize={iconSize}
220
- validationStatus={validation?.status}
221
- disabled={disabled}
222
- inputBackground={inputBackground}
223
- inputVariant={inputVariant}
224
- iconBaseUrl={iconBaseUrl}
225
- />
226
- )}
227
- </InputLeftContainer>
228
- )}
213
+ {icon && (
214
+ <InputIcon
215
+ data-testid={testid}
216
+ className={className}
217
+ icon={icon}
218
+ iconSize={iconSize}
219
+ validationStatus={validation?.status}
220
+ disabled={disabled}
221
+ inputBackground={inputBackground}
222
+ inputVariant={inputVariant}
223
+ iconBaseUrl={iconBaseUrl}
224
+ />
225
+ )}
226
+ </InputLeftContainer>
227
+ )}
229
228
 
230
- <InputTime
231
- data-testid={
232
- testid && `${testid}.InputWrapper.InputTime`
233
- }
234
- className={className && "InputTime"}
235
- ref={ref}
236
- onClick={handleClick}
237
- onFocus={handleOpen}
238
- tabIndex={tabIndex}
239
- value={value}
240
- onChange={handleChange}
241
- disabled={disabled}
242
- $disabled={disabled}
243
- $validationStatus={validation?.status}
244
- $inputBackground={inputBackground}
245
- $inputVariant={inputVariant}
246
- {...rest}
247
- />
229
+ <InputTime
230
+ data-testid={
231
+ testid && `${testid}.InputWrapper.InputTime`
232
+ }
233
+ className={className && "InputTime"}
234
+ ref={ref}
235
+ onClick={handleClick}
236
+ onFocus={handleOpen}
237
+ tabIndex={tabIndex}
238
+ value={value}
239
+ onChange={handleChange}
240
+ disabled={disabled}
241
+ $disabled={disabled}
242
+ $validationStatus={validation?.status}
243
+ $inputBackground={inputBackground}
244
+ $inputVariant={inputVariant}
245
+ {...rest}
246
+ />
248
247
 
249
- <InputRightContainer
250
- data-testid={testid}
251
- className={className}
252
- disabled={disabled}
253
- withBorder={false}
254
- withPadding
255
- >
256
- <InputButton
257
- data-testid={testid}
258
- className={className}
259
- icon={iconClock}
260
- iconSize={iconClockSize}
261
- onClick={handleClick}
262
- aria-label="Calendar"
263
- disabled={disabled}
264
- inputBackground={inputBackground}
265
- validationStatus={validation?.status}
266
- />
248
+ <InputRightContainer
249
+ data-testid={testid}
250
+ className={className}
251
+ disabled={disabled}
252
+ withBorder={false}
253
+ withPadding
254
+ >
255
+ <InputButton
256
+ data-testid={testid}
257
+ className={className}
258
+ icon={iconClock}
259
+ iconSize={iconClockSize}
260
+ onClick={handleClick}
261
+ aria-label="Calendar"
262
+ disabled={disabled}
263
+ inputBackground={inputBackground}
264
+ validationStatus={validation?.status}
265
+ />
267
266
 
268
- {validation && (
269
- <InputValidationIcon
270
- data-testid={testid}
271
- className={className}
272
- validation={validation}
273
- inputBackground={inputBackground}
274
- />
275
- )}
276
- </InputRightContainer>
277
- </InputWrapper>
267
+ {validation && (
268
+ <InputValidationIcon
269
+ data-testid={testid}
270
+ className={className}
271
+ validation={validation}
272
+ inputBackground={inputBackground}
273
+ />
274
+ )}
275
+ </InputRightContainer>
276
+ </InputWrapper>
278
277
 
279
- <ListInput
280
- data-testid={testid}
281
- className={className}
282
- direction={listDirection}
283
- inputBackground={inputBackground}
284
- inputVariant={inputVariant}
285
- validationStatus={validation?.status}
286
- isOpen={!!(value && isOpen)}
287
- ref={listRef}
288
- >
289
- {times.map((time, i) => (
290
- <ListInputItem
291
- key={time}
292
- data-testid={testid}
293
- className={className}
294
- validationStatus={validation?.status}
295
- inputBackground={inputBackground}
296
- onClick={() => handleSelectTime(time)}
297
- isActive={i === cursor}
298
- isHovered={value === time}
299
- >
300
- {time}
301
- </ListInputItem>
302
- ))}
303
- </ListInput>
304
- </InputAndListContainer>
305
- </InputContainer>
306
- )
278
+ <ListInput
279
+ data-testid={testid}
280
+ className={className}
281
+ direction={listDirection}
282
+ inputBackground={inputBackground}
283
+ inputVariant={inputVariant}
284
+ validationStatus={validation?.status}
285
+ isOpen={!!(value && isOpen)}
286
+ ref={listRef}
287
+ >
288
+ {times.map((time, i) => (
289
+ <ListInputItem
290
+ key={time}
291
+ data-testid={testid}
292
+ className={className}
293
+ validationStatus={validation?.status}
294
+ inputBackground={inputBackground}
295
+ onClick={() => handleSelectTime(time)}
296
+ isActive={i === cursor}
297
+ isHovered={value === time}
298
+ >
299
+ {time}
300
+ </ListInputItem>
301
+ ))}
302
+ </ListInput>
303
+ </InputAndListContainer>
304
+ </InputContainer>
305
+ )
307
306
  }
@@ -2,8 +2,9 @@ import type { IframeHTMLAttributes } from "react"
2
2
  import type { LibComponentBase } from "../../types"
3
3
 
4
4
  export interface ILibYoutube
5
- extends Exclude<LibComponentBase<HTMLIFrameElement>, "as">,
6
- IframeHTMLAttributes<HTMLIFrameElement> {
7
- aspectRatio?: string
8
- children?: never
5
+ extends Exclude<LibComponentBase<HTMLIFrameElement>, "as">,
6
+ IframeHTMLAttributes<HTMLIFrameElement> {
7
+ src: string
8
+ aspectRatio?: string
9
+ children?: never
9
10
  }
package/dist/lib/index.ts CHANGED
@@ -3,68 +3,69 @@
3
3
  export { ThemeProvider } from "styled-components"
4
4
  // import {} from "styled-components/cssprop"
5
5
  export * from "./utils"
6
+ export * from "./design-tokens"
6
7
  export {
7
- addDay,
8
- addMonth,
9
- addYear,
10
- calculateAverage,
11
- calculateTotalSum,
12
- capitalize,
13
- convertDate,
14
- convertDateShort,
15
- convertPrice,
16
- convertToEmail,
17
- convertYoutube,
18
- deleteDuplicates,
19
- detectLanguage,
20
- disableScroll,
21
- enableScroll,
22
- filterObject,
23
- formatDate,
24
- formatHour,
25
- generateNumbers,
26
- getFirstName,
27
- getInitials,
28
- getLastName,
29
- getNextDay,
30
- getPercentage,
31
- getRandom,
32
- getRandomAvatar,
33
- getRandomDate,
34
- getRandomNumber,
35
- getRandomString,
36
- getRandomTime,
37
- getTimeNow,
38
- getToday,
39
- getTomorrow,
40
- getYesterday,
41
- hexToRgb,
42
- emailRegex,
43
- passwordRegex,
44
- rgbToHex,
45
- scrollToTop,
46
- slugify,
47
- sortByFrequency,
48
- stringifyPx,
49
- toCamelCase,
50
- toConstantCase,
51
- toDotCase,
52
- toKebabCase,
53
- toPascalCase,
54
- toPathCase,
55
- toSentenceCase,
56
- toSnakeCase,
57
- toTitleCase,
58
- unslugify,
59
- uuid,
8
+ addDay,
9
+ addMonth,
10
+ addYear,
11
+ calculateAverage,
12
+ calculateTotalSum,
13
+ capitalize,
14
+ convertDate,
15
+ convertDateShort,
16
+ convertPrice,
17
+ convertToEmail,
18
+ convertYoutube,
19
+ deleteDuplicates,
20
+ detectLanguage,
21
+ disableScroll,
22
+ enableScroll,
23
+ filterObject,
24
+ formatDate,
25
+ formatHour,
26
+ generateNumbers,
27
+ getFirstName,
28
+ getInitials,
29
+ getLastName,
30
+ getNextDay,
31
+ getPercentage,
32
+ getRandom,
33
+ getRandomAvatar,
34
+ getRandomDate,
35
+ getRandomNumber,
36
+ getRandomString,
37
+ getRandomTime,
38
+ getTimeNow,
39
+ getToday,
40
+ getTomorrow,
41
+ getYesterday,
42
+ hexToRgb,
43
+ emailRegex,
44
+ passwordRegex,
45
+ rgbToHex,
46
+ scrollToTop,
47
+ slugify,
48
+ sortByFrequency,
49
+ stringifyPx,
50
+ toCamelCase,
51
+ toConstantCase,
52
+ toDotCase,
53
+ toKebabCase,
54
+ toPascalCase,
55
+ toPathCase,
56
+ toSentenceCase,
57
+ toSnakeCase,
58
+ toTitleCase,
59
+ unslugify,
60
+ uuid,
60
61
  } from "@julseb-lib/utils"
61
62
 
62
63
  export * from "./Variables"
63
64
  export * from "./Mixins"
64
65
 
65
66
  export {
66
- optionsMarkdown,
67
- markdownEditorOptions,
67
+ optionsMarkdown,
68
+ markdownEditorOptions,
68
69
  } from "./utils/options-markdown"
69
70
 
70
71
  export * from "./hooks"