x-ui-design 0.1.1 → 0.1.2

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "x-ui-design",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "license": "ISC",
5
5
  "author": "Gabriel Boyajyan",
6
6
  "scripts": {
@@ -10,7 +10,6 @@
10
10
  "lint": "next lint"
11
11
  },
12
12
  "dependencies": {
13
- "classcat": "^5.0.5",
14
13
  "next": "15.2.0",
15
14
  "react": "^19.0.0",
16
15
  "react-dom": "^19.0.0"
@@ -8,11 +8,11 @@ import {
8
8
  useEffect,
9
9
  useState
10
10
  } from 'react';
11
- import cc from 'classcat';
12
11
  import { SyntheticBaseEvent } from '@/xUiDesign/types';
13
12
  import { CheckboxProps } from '@/xUiDesign/types/checkbox';
14
13
  import { prefixClsCheckbox } from '@/xUiDesign/utils';
15
14
  import './style.css';
15
+ import { clsx } from '@/xUiDesign/helpers';
16
16
 
17
17
  const Checkbox = forwardRef<HTMLDivElement, CheckboxProps>(({
18
18
  prefixCls = prefixClsCheckbox,
@@ -68,7 +68,7 @@ const Checkbox = forwardRef<HTMLDivElement, CheckboxProps>(({
68
68
  ref={ref}
69
69
  style={style}
70
70
  onClick={handleClick}
71
- className={cc([
71
+ className={clsx([
72
72
  prefixCls,
73
73
  className,
74
74
  {
@@ -1,12 +1,12 @@
1
1
  'use client';
2
2
 
3
3
  import { useEffect, useRef, useState } from 'react';
4
- import cc from 'classcat';
5
4
  import { TRangePickerProps } from '@/xUiDesign/types/datepicker';
6
5
  import { prefixClsRangePicker } from '@/xUiDesign/utils';
7
6
  import './style.css';
8
7
  import { MONTH_LENGTH, NEXT_DAYS_COUNT_AS_CURRENT_MUNTH, NUMBER_SIX } from '..';
9
8
  import { CalendarIcon, ClearIcon, DateDistanceIcon } from '../../icons';
9
+ import { clsx } from '@/xUiDesign/helpers';
10
10
 
11
11
  const RangePicker = ({
12
12
  prefixCls = prefixClsRangePicker,
@@ -248,7 +248,7 @@ const RangePicker = ({
248
248
  })}
249
249
  onClick={() => day && handleSelect(day)}
250
250
  onMouseEnter={() => day && setHoveredDate(day)}
251
- className={cc([
251
+ className={clsx([
252
252
  `${prefixCls}-day`,
253
253
  {
254
254
  [`${prefixCls}-selected`]: isSelected,
@@ -322,7 +322,7 @@ const RangePicker = ({
322
322
  <div
323
323
  ref={containerRef}
324
324
  style={style}
325
- className={cc([
325
+ className={clsx([
326
326
  `${prefixCls}-range-container`,
327
327
  {
328
328
  [`${prefixCls}-${size}`]: size,
@@ -333,7 +333,7 @@ const RangePicker = ({
333
333
  <div className={`${prefixCls}-range-input-wrapper`}>
334
334
  <button
335
335
  type="button"
336
- className={cc([
336
+ className={clsx([
337
337
  `${prefixCls}-input`,
338
338
  {
339
339
  noBordered: !bordered,
@@ -11,10 +11,10 @@ import {
11
11
  useRef,
12
12
  useState
13
13
  } from 'react';
14
- import cc from 'classcat';
15
14
  import { RuleType } from '@/xUiDesign/types';
16
15
  import { TimePickerProps } from '@/xUiDesign/types/datepicker';
17
16
  import { prefixClsTimePicker } from '@/xUiDesign/utils';
17
+ import { clsx } from '@/xUiDesign/helpers';
18
18
  import './style.css';
19
19
  import { ClearIcon, TimeIcon } from '../../icons';
20
20
 
@@ -301,7 +301,7 @@ const TimePicker: FC<TimePickerProps> = ({
301
301
  ) : (
302
302
  <div
303
303
  key={h}
304
- className={cc([
304
+ className={clsx([
305
305
  `${prefixCls}-cell`,
306
306
  {
307
307
  [`${prefixCls}-cell-disabled`]:
@@ -331,7 +331,7 @@ const TimePicker: FC<TimePickerProps> = ({
331
331
  ) : (
332
332
  <div
333
333
  key={m}
334
- className={cc([
334
+ className={clsx([
335
335
  `${prefixCls}-cell`,
336
336
  {
337
337
  [`${prefixCls}-cell-disabled`]: getDisabled(
@@ -364,7 +364,7 @@ const TimePicker: FC<TimePickerProps> = ({
364
364
  ) : (
365
365
  <div
366
366
  key={s}
367
- className={cc([
367
+ className={clsx([
368
368
  `${prefixCls}-cell`,
369
369
  {
370
370
  [`${prefixCls}-cell-disabled`]: getDisabled(
@@ -412,7 +412,7 @@ const TimePicker: FC<TimePickerProps> = ({
412
412
  };
413
413
 
414
414
  return (
415
- <div className={cc([`${prefixCls}-wrapper`, className])} style={style}>
415
+ <div className={clsx([`${prefixCls}-wrapper`, className])} style={style}>
416
416
  <div
417
417
  className={`${prefixCls}-input-wrapper`}
418
418
  onClick={() => setOpen(true)}
@@ -1,12 +1,12 @@
1
1
  'use client';
2
2
 
3
3
  import { CSSProperties, useEffect, useRef, useState } from 'react';
4
- import cc from 'classcat';
5
4
  import { TDatePickerProps } from '@/xUiDesign/types/datepicker';
6
5
  import { prefixClsDatePicker } from '@/xUiDesign/utils';
7
6
  import RangePicker from './RangePicker';
8
7
  import './style.css';
9
8
  import { CalendarIcon, ClearIcon, ErrorIcon } from '../icons';
9
+ import { clsx } from '@/xUiDesign/helpers';
10
10
 
11
11
  const INPUT_SIZE = 12;
12
12
  const CONTENT_PADDING = 6;
@@ -256,7 +256,7 @@ const DatePickerComponent = ({
256
256
  return (
257
257
  <div
258
258
  ref={containerRef}
259
- className={cc([
259
+ className={clsx([
260
260
  `${prefixCls}-container`,
261
261
  {
262
262
  noStyle,
@@ -267,7 +267,7 @@ const DatePickerComponent = ({
267
267
  <div className={`${prefixCls}-input-wrapper`}>
268
268
  <button
269
269
  type="button"
270
- className={cc([
270
+ className={clsx([
271
271
  `${prefixCls}-input`,
272
272
  {
273
273
  noBordered: !bordered,
@@ -308,7 +308,7 @@ const DatePickerComponent = ({
308
308
 
309
309
  <div
310
310
  style={popupContainerRef.current ? { position: 'absolute' } : {}}
311
- className={cc([
311
+ className={clsx([
312
312
  placement,
313
313
  `${prefixCls}-dropdown-wrapper`,
314
314
  {
@@ -386,7 +386,7 @@ const DatePickerComponent = ({
386
386
  return (
387
387
  <button
388
388
  key={`${year}-${month}-${day}-${idx}`}
389
- className={cc([
389
+ className={clsx([
390
390
  `${prefixCls}-day`,
391
391
  {
392
392
  [`${prefixCls}-selected`]: isSelected,
@@ -10,7 +10,6 @@ import {
10
10
  useRef,
11
11
  useState
12
12
  } from 'react';
13
- import cc from 'classcat';
14
13
  import { RuleType, SyntheticBaseEvent } from '@/xUiDesign/types';
15
14
  import {
16
15
  FormItemChildComponentProps,
@@ -20,6 +19,7 @@ import { OptionProps } from '@/xUiDesign/types/select';
20
19
  import { prefixClsFormItem } from '@/xUiDesign/utils';
21
20
  import { FormContext } from '..';
22
21
  import './style.css';
22
+ import { clsx } from '@/xUiDesign/helpers';
23
23
 
24
24
  const REF_CLIENT_HEIGHT = 24;
25
25
 
@@ -106,7 +106,7 @@ export const FormItem = ({
106
106
  return (
107
107
  <div
108
108
  style={style}
109
- className={cc([
109
+ className={clsx([
110
110
  `${prefixCls}`,
111
111
  {
112
112
  [layout]: layout,
@@ -10,10 +10,10 @@ import {
10
10
  useRef,
11
11
  useState
12
12
  } from 'react';
13
- import cc from 'classcat';
14
13
  import { TextareaProps } from '@/xUiDesign/types/input';
15
14
  import { prefixClsTextArea } from '@/xUiDesign/utils';
16
15
  import './style.css';
16
+ import { clsx } from '@/xUiDesign/helpers';
17
17
 
18
18
  const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(
19
19
  (
@@ -90,7 +90,7 @@ const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(
90
90
  onChange={handleChange}
91
91
  onKeyDown={handleKeyDown}
92
92
  style={{ ...styles?.textarea, ...style }}
93
- className={cc([
93
+ className={clsx([
94
94
  `${prefixCls} ${prefixCls}-${size} ${prefixCls}-${variant} ${className}`,
95
95
  {
96
96
  [`${prefixCls}-bordered`]: bordered,
@@ -9,13 +9,13 @@ import {
9
9
  useRef,
10
10
  useState
11
11
  } from 'react';
12
- import cc from 'classcat';
13
12
  import { SyntheticBaseEvent, TargetProps } from '@/xUiDesign/types';
14
13
  import { InputProps } from '@/xUiDesign/types/input';
15
14
  import { prefixClsInput } from '@/xUiDesign/utils';
16
15
  import './style.css';
17
16
  import { Textarea } from './Textarea';
18
17
  import { ErrorIcon } from '../icons';
18
+ import { clsx } from '@/xUiDesign/helpers';
19
19
 
20
20
  const InputComponent = forwardRef(
21
21
  (
@@ -79,7 +79,7 @@ const InputComponent = forwardRef(
79
79
 
80
80
  return (
81
81
  <div
82
- className={cc([
82
+ className={clsx([
83
83
  `${prefixCls}-container`,
84
84
  {
85
85
  [`${prefixCls}-error`]: error,
@@ -112,7 +112,7 @@ const InputComponent = forwardRef(
112
112
  value={internalValue}
113
113
  onChange={handleChange}
114
114
  onKeyDown={handleOnKeyDown}
115
- className={cc([prefixCls, className])}
115
+ className={clsx([prefixCls, className])}
116
116
  />
117
117
 
118
118
  <span className={`${prefixCls}-clear`} onClick={handleClear}>
@@ -1,12 +1,12 @@
1
1
  "use client"
2
2
 
3
3
  import { ReactNode } from 'react';
4
- import cc from 'classcat';
5
4
  import { SizeType } from '@/xUiDesign/types';
6
5
  import { RadioProps } from '@/xUiDesign/types/radio';
7
6
  import { prefixClsRadio } from '@/xUiDesign/utils';
8
7
  import { Radio } from '..';
9
8
  import './style.css';
9
+ import { clsx } from '@/xUiDesign/helpers';
10
10
 
11
11
  interface RadioButtonProps extends RadioProps {
12
12
  children?: ReactNode;
@@ -27,7 +27,7 @@ const RadioButton = ({
27
27
  {...props}
28
28
  checked={checked}
29
29
  disabled={disabled}
30
- className={cc([
30
+ className={clsx([
31
31
  `${prefixCls}-button`,
32
32
  {
33
33
  disabled,
@@ -7,13 +7,13 @@ import {
7
7
  ReactElement,
8
8
  useMemo
9
9
  } from 'react';
10
- import cc from 'classcat';
11
10
  import { RuleType } from '@/xUiDesign/types';
12
11
  import { RadioGroupProps } from '@/xUiDesign/types/radio';
13
12
  import { prefixClsRadio } from '@/xUiDesign/utils';
14
13
  import { RadioButton } from '../Button';
15
14
  import { Radio } from '..';
16
15
  import './style.css';
16
+ import { clsx } from '@/xUiDesign/helpers';
17
17
 
18
18
  const RadioGroup = ({
19
19
  defaultValue,
@@ -83,7 +83,7 @@ const RadioGroup = ({
83
83
  <div
84
84
  id={id}
85
85
  style={style}
86
- className={cc([
86
+ className={clsx([
87
87
  `${prefixCls}-group`,
88
88
  {
89
89
  block,
@@ -1,8 +1,7 @@
1
1
  "use client"
2
2
 
3
3
  import { ForwardedRef, forwardRef, useEffect } from 'react';
4
- import cc from 'classcat';
5
- import { parseValue } from '@/xUiDesign/helpers';
4
+ import { clsx, parseValue } from '@/xUiDesign/helpers';
6
5
  import { RadioProps } from '@/xUiDesign/types/radio';
7
6
  import { prefixClsRadio } from '@/xUiDesign/utils';
8
7
  import { RadioButton } from './Button';
@@ -50,7 +49,7 @@ const RadioComponent = forwardRef<HTMLLabelElement, RadioProps>(
50
49
  title={title}
51
50
  onMouseEnter={onMouseEnter}
52
51
  onMouseLeave={onMouseLeave}
53
- className={cc([
52
+ className={clsx([
54
53
  `${prefixCls}-label`,
55
54
  {
56
55
  disabled,
@@ -69,7 +68,7 @@ const RadioComponent = forwardRef<HTMLLabelElement, RadioProps>(
69
68
  onFocus={e => onFocus?.(e)}
70
69
  />
71
70
  <span
72
- className={cc([
71
+ className={clsx([
73
72
  `${prefixCls} ${prefixCls}-${disabled ? 'disabled' : 'enabled'}`
74
73
  ])}
75
74
  />
@@ -1,8 +1,8 @@
1
1
  import { FC, MouseEventHandler } from 'react';
2
- import cc from 'classcat';
3
2
  import { OptionProps } from '@/xUiDesign/types/select';
4
3
  import { prefixClsSelect } from '@/xUiDesign/utils';
5
4
  import './style.css';
5
+ import { clsx } from '@/xUiDesign/helpers';
6
6
 
7
7
  const Option: FC<OptionProps> = ({
8
8
  value,
@@ -25,7 +25,7 @@ const Option: FC<OptionProps> = ({
25
25
 
26
26
  return (
27
27
  <div
28
- className={cc([
28
+ className={clsx([
29
29
  `${prefixCls}-option ${className} `,
30
30
  {
31
31
  selected: selected,
@@ -14,7 +14,6 @@ import {
14
14
  useState
15
15
  } from 'react';
16
16
  import { createPortal } from 'react-dom';
17
- import cc from 'classcat';
18
17
  import { EmptyContent } from '@/xUiDesign/components/Empty';
19
18
  import {
20
19
  ArrowIcon,
@@ -27,6 +26,7 @@ import {
27
26
  import { MouseEventHandlerSelect, SyntheticBaseEvent } from '@/xUiDesign/types';
28
27
  import { OptionType, SelectProps } from '@/xUiDesign/types/select';
29
28
  import { prefixClsSelect } from '@/xUiDesign/utils';
29
+ import { clsx } from '@/xUiDesign/helpers';
30
30
  import { Option } from './Option';
31
31
  import { Tag } from './Tag';
32
32
  import './style.css';
@@ -405,7 +405,7 @@ const SelectComponent = forwardRef<HTMLDivElement, SelectProps>((
405
405
  key={`${props.value}`}
406
406
  {...props}
407
407
  selected={isSelected}
408
- className={cc([
408
+ className={clsx([
409
409
  className,
410
410
  {
411
411
  [`${prefixCls}-focused`]: hasMode
@@ -451,7 +451,7 @@ const SelectComponent = forwardRef<HTMLDivElement, SelectProps>((
451
451
 
452
452
  const dropdownContent = !loading && isOpen && (
453
453
  <div
454
- className={cc([
454
+ className={clsx([
455
455
  `${prefixCls}-dropdown`,
456
456
  {
457
457
  [placement]: placement,
@@ -512,7 +512,7 @@ const SelectComponent = forwardRef<HTMLDivElement, SelectProps>((
512
512
  id={id}
513
513
  ref={selectRef}
514
514
  style={style}
515
- className={cc([
515
+ className={clsx([
516
516
  {
517
517
  [size]: size,
518
518
  'noStyle': noStyle,
@@ -1,7 +1,6 @@
1
1
  'use client';
2
2
 
3
3
  import { useRef, useState } from 'react';
4
- import cc from 'classcat';
5
4
  import { RuleType } from '@/xUiDesign/types';
6
5
  import {
7
6
  RcFile,
@@ -12,6 +11,7 @@ import {
12
11
  import { prefixClsUpload } from '@/xUiDesign/utils';
13
12
  import './style.css';
14
13
  import { StampleIcon, TrashIcon } from '../icons';
14
+ import { clsx } from '@/xUiDesign/helpers';
15
15
 
16
16
  const IMAGE_SIZE = 40;
17
17
  const IMAGE_PROGRESS_PERCENT = 100;
@@ -194,7 +194,7 @@ const Upload = ({
194
194
 
195
195
  return (
196
196
  <div
197
- className={cc([
197
+ className={clsx([
198
198
  `${prefixCls}-wrapper`,
199
199
  className,
200
200
  rootClassName,
@@ -206,7 +206,7 @@ const Upload = ({
206
206
  style={style}
207
207
  >
208
208
  <span
209
- className={cc([`${prefixCls}`, `${prefixCls}-${listType}`])}
209
+ className={clsx([`${prefixCls}`, `${prefixCls}-${listType}`])}
210
210
  onClick={handleClick}
211
211
  >
212
212
  {children}
@@ -15,3 +15,34 @@ export const parseValue = (value: RuleType): RuleType => {
15
15
 
16
16
  return value;
17
17
  };
18
+
19
+ export function clsx(...args: RuleType[]): string {
20
+ return args
21
+ .flatMap(arg => {
22
+ if (!arg) {
23
+ return [];
24
+ }
25
+
26
+ if (typeof arg === 'string') {
27
+ return [arg];
28
+ }
29
+
30
+ if (typeof arg === 'number') {
31
+ return [String(arg)];
32
+ }
33
+
34
+ if (Array.isArray(arg)) {
35
+ return clsx(...arg).split(' ');
36
+ }
37
+
38
+ if (typeof arg === 'object') {
39
+ return Object.entries(arg)
40
+ .filter(([, value]) => Boolean(value))
41
+ .map(([key]) => key);
42
+ }
43
+
44
+ return [];
45
+ })
46
+ .filter(Boolean)
47
+ .join(' ');
48
+ }