@particle-network/ui-react 0.5.1-beta.1 → 0.5.1-beta.10

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 (89) hide show
  1. package/dist/components/ProgressWrapper/index.d.ts +2 -2
  2. package/dist/components/ProgressWrapper/index.js +1 -1
  3. package/dist/components/UXAutocomplete/index.js +1 -2
  4. package/dist/components/UXButton/button-theme.js +38 -2
  5. package/dist/components/UXButton/button.js +1 -1
  6. package/dist/components/UXCheckbox/checkbox.extend.js +16 -13
  7. package/dist/components/UXChip/chip.extend.d.ts +2 -1
  8. package/dist/components/UXChip/index.d.ts +1 -1
  9. package/dist/components/UXColorPicker/color-fields.d.ts +3 -0
  10. package/dist/components/UXColorPicker/color-fields.js +142 -0
  11. package/dist/components/UXColorPicker/color-input.d.ts +7 -0
  12. package/dist/components/UXColorPicker/color-input.js +12 -0
  13. package/dist/components/UXColorPicker/color-picker.d.ts +3 -0
  14. package/dist/components/UXColorPicker/color-picker.js +228 -0
  15. package/dist/components/UXColorPicker/index.d.ts +5 -0
  16. package/dist/components/UXColorPicker/index.js +3 -0
  17. package/dist/components/UXColorPicker/types.d.ts +51 -0
  18. package/dist/components/UXColorPicker/types.js +0 -0
  19. package/dist/components/UXColorPicker/utils.d.ts +7 -0
  20. package/dist/components/UXColorPicker/utils.js +6 -0
  21. package/dist/components/UXCopy/index.js +2 -2
  22. package/dist/components/UXEmpty/index.js +2 -2
  23. package/dist/components/UXHint/index.js +1 -1
  24. package/dist/components/UXInput/index.d.ts +6 -6
  25. package/dist/components/UXInput/input.extend.d.ts +6 -6
  26. package/dist/components/UXRadio/radio.extend.js +3 -3
  27. package/dist/components/UXSlider/use-slider.d.ts +1 -1
  28. package/dist/components/UXSlider/use-slider.js +1 -1
  29. package/dist/components/UXSpinner/spinner.d.ts +1 -5
  30. package/dist/components/UXSpinner/spinner.js +3 -4
  31. package/dist/components/UXSwitch/index.d.ts +2 -2
  32. package/dist/components/UXSwitch/switch.extend.d.ts +2 -2
  33. package/dist/components/UXSwitch/switch.extend.js +6 -6
  34. package/dist/components/UXTabs/tabs.classes.js +4 -4
  35. package/dist/components/UXThemeSwitch/constants.d.ts +9 -0
  36. package/dist/components/UXThemeSwitch/constants.js +3 -0
  37. package/dist/components/UXThemeSwitch/custom-theme-config.d.ts +2 -0
  38. package/dist/components/UXThemeSwitch/custom-theme-config.js +171 -0
  39. package/dist/components/UXThemeSwitch/theme-item.js +94 -15
  40. package/dist/components/UXThemeSwitch/theme-switch.js +26 -5
  41. package/dist/components/UXThemeSwitch/use-color-scheme.js +11 -8
  42. package/dist/components/UXThemeSwitch/use-theme-color.d.ts +1 -22
  43. package/dist/components/UXThemeSwitch/use-theme-color.js +3 -7
  44. package/dist/components/UXThemeSwitch/use-theme-store.d.ts +5 -0
  45. package/dist/components/UXThemeSwitch/use-theme-store.js +9 -3
  46. package/dist/components/UXThemeSwitch/use-theme.d.ts +2 -0
  47. package/dist/components/UXThemeSwitch/use-theme.js +10 -53
  48. package/dist/components/UXThemeSwitch/utils.d.ts +28 -0
  49. package/dist/components/UXThemeSwitch/utils.js +222 -0
  50. package/dist/components/UXToast/index.js +3 -3
  51. package/dist/components/index.d.ts +1 -0
  52. package/dist/components/index.js +1 -0
  53. package/dist/components/layout/Box/box-theme.d.ts +2225 -0
  54. package/dist/components/layout/Box/box-theme.js +348 -0
  55. package/dist/components/layout/Box/box.d.ts +14 -0
  56. package/dist/components/layout/Box/box.js +99 -0
  57. package/dist/components/layout/Circle.js +2 -3
  58. package/dist/components/layout/Flex.d.ts +3 -27
  59. package/dist/components/layout/Flex.js +6 -19
  60. package/dist/components/layout/HStack.d.ts +1 -1
  61. package/dist/components/layout/Square.js +3 -3
  62. package/dist/components/layout/VStack.d.ts +1 -1
  63. package/dist/components/layout/VStack.js +2 -2
  64. package/dist/components/layout/index.d.ts +1 -0
  65. package/dist/components/layout/index.js +1 -0
  66. package/dist/components/typography/Text.js +22 -7
  67. package/dist/components/typography/Text.type.d.ts +3 -26
  68. package/dist/components/typography/Text.type.js +0 -47
  69. package/dist/components/typography/text-theme.d.ts +178 -0
  70. package/dist/components/typography/text-theme.js +79 -0
  71. package/dist/heroui/constants.d.ts +18 -0
  72. package/dist/heroui/constants.js +98 -0
  73. package/dist/heroui/types.d.ts +91 -0
  74. package/dist/heroui/types.js +0 -0
  75. package/dist/heroui/utils/colors.d.ts +34 -0
  76. package/dist/heroui/utils/colors.js +121 -0
  77. package/dist/heroui/utils/object.d.ts +1 -0
  78. package/dist/heroui/utils/object.js +17 -0
  79. package/dist/hooks/useI18n.d.ts +133 -25
  80. package/dist/hooks/useI18n.js +84 -2
  81. package/dist/hooks/useLang.d.ts +5 -1
  82. package/dist/hooks/useLang.js +13 -1
  83. package/dist/utils/cn.d.ts +2 -0
  84. package/dist/utils/cn.js +258 -0
  85. package/dist/utils/index.d.ts +1 -0
  86. package/dist/utils/index.js +2 -1
  87. package/dist/utils/input-classes.js +2 -2
  88. package/package.json +8 -5
  89. package/tailwind-preset.js +84 -160
@@ -0,0 +1,222 @@
1
+ import { hexColorToHSLValue, themeKeys } from "@particle-network/ui-shared";
2
+ import { readableColor } from "color2k";
3
+ import { generateThemeColor } from "../../heroui/utils/colors.js";
4
+ import { DEFAULT_FONT_FAMILY, PRELOAD_FONTS_URL } from "./constants.js";
5
+ const getCSSProperties = (theme)=>{
6
+ const { colorVariables } = theme;
7
+ return {
8
+ foreground: [
9
+ [
10
+ '--heroui-foreground',
11
+ colorVariables.foreground
12
+ ]
13
+ ],
14
+ secondary: [
15
+ ...generateThemeColor(colorVariables.secondary, 'secondary', theme.colorScheme).cssVariables,
16
+ [
17
+ '--heroui-foreground-300',
18
+ colorVariables.secondary
19
+ ]
20
+ ],
21
+ tertiary: [
22
+ [
23
+ '--heroui-tertiary',
24
+ colorVariables.tertiary
25
+ ],
26
+ [
27
+ '--heroui-foreground-100',
28
+ colorVariables.tertiary
29
+ ],
30
+ [
31
+ '--heroui-tertiary-foreground',
32
+ readableColor(colorVariables.tertiary)
33
+ ]
34
+ ],
35
+ primary: generateThemeColor(colorVariables.primary, 'primary', theme.colorScheme).cssVariables,
36
+ success: generateThemeColor(colorVariables.success, 'success', theme.colorScheme).cssVariables,
37
+ danger: generateThemeColor(colorVariables.danger, 'danger', theme.colorScheme).cssVariables,
38
+ alert: [
39
+ [
40
+ '--heroui-alert',
41
+ colorVariables.alert
42
+ ],
43
+ [
44
+ '--heroui-alert-foreground',
45
+ readableColor(colorVariables.alert)
46
+ ]
47
+ ],
48
+ warning: generateThemeColor(colorVariables.warning, 'warning', theme.colorScheme).cssVariables,
49
+ blue: [
50
+ [
51
+ '--heroui-blue',
52
+ colorVariables.blue
53
+ ],
54
+ [
55
+ '--heroui-blue-foreground',
56
+ readableColor(colorVariables.blue)
57
+ ]
58
+ ],
59
+ bgDefault: [
60
+ [
61
+ '--heroui-background',
62
+ colorVariables.bgDefault
63
+ ],
64
+ [
65
+ '--heroui-background-500',
66
+ colorVariables.bgDefault
67
+ ]
68
+ ],
69
+ bg200: [
70
+ [
71
+ '--heroui-background-200',
72
+ colorVariables.bg200
73
+ ]
74
+ ],
75
+ bg300: [
76
+ [
77
+ '--heroui-background-300',
78
+ colorVariables.bg300
79
+ ]
80
+ ],
81
+ bg400: [
82
+ [
83
+ '--heroui-background-400',
84
+ colorVariables.bg400
85
+ ]
86
+ ],
87
+ cursor: [
88
+ [
89
+ '--heroui-cursor',
90
+ colorVariables.cursor
91
+ ],
92
+ [
93
+ '--heroui-cursor-foreground',
94
+ readableColor(colorVariables.cursor)
95
+ ]
96
+ ],
97
+ overlay: [
98
+ [
99
+ '--heroui-overlay',
100
+ colorVariables.overlay
101
+ ],
102
+ [
103
+ '--heroui-content1',
104
+ colorVariables.overlay
105
+ ],
106
+ [
107
+ '--heroui-overlay-foreground',
108
+ readableColor(colorVariables.overlay)
109
+ ],
110
+ [
111
+ '--heroui-content1-foreground',
112
+ readableColor(colorVariables.overlay)
113
+ ]
114
+ ],
115
+ divider: [
116
+ [
117
+ '--heroui-divider',
118
+ colorVariables.divider
119
+ ],
120
+ [
121
+ '--heroui-divider-foreground',
122
+ readableColor(colorVariables.divider)
123
+ ]
124
+ ],
125
+ bullish: [
126
+ [
127
+ '--heroui-bullish',
128
+ colorVariables.bullish
129
+ ],
130
+ [
131
+ '--heroui-bullish-foreground',
132
+ readableColor(colorVariables.bullish)
133
+ ]
134
+ ],
135
+ bearish: [
136
+ [
137
+ '--heroui-bearish',
138
+ colorVariables.bearish
139
+ ],
140
+ [
141
+ '--heroui-bearish-foreground',
142
+ readableColor(colorVariables.bearish)
143
+ ]
144
+ ]
145
+ };
146
+ };
147
+ const preloadFonts = ()=>{
148
+ if ('undefined' == typeof window) return;
149
+ const existingLink = document.getElementById('ux-preload-fonts-link');
150
+ if (existingLink) return;
151
+ const linkElement = document.createElement('link');
152
+ linkElement.id = 'ux-preload-fonts-link';
153
+ linkElement.rel = 'stylesheet';
154
+ linkElement.href = PRELOAD_FONTS_URL;
155
+ document.head.appendChild(linkElement);
156
+ };
157
+ const setCSSProperty = (property, value)=>{
158
+ if ('undefined' == typeof window) return;
159
+ const root = document.documentElement;
160
+ root.style.setProperty(property, hexColorToHSLValue(value));
161
+ };
162
+ const applyCustomThemeColors = (theme)=>{
163
+ if ('undefined' == typeof window) return;
164
+ const cssProperties = getCSSProperties(theme);
165
+ Object.entries(cssProperties).forEach(([, value])=>{
166
+ value.forEach(([variable, value])=>{
167
+ setCSSProperty(variable, value);
168
+ });
169
+ });
170
+ };
171
+ const clearCustomThemeColors = ()=>{
172
+ if ('undefined' == typeof window) return;
173
+ const rootStyles = getComputedStyle(document.documentElement);
174
+ Array.from(rootStyles).filter((prop)=>prop.startsWith('--heroui')).forEach((prop)=>{
175
+ document.documentElement.style.removeProperty(prop);
176
+ });
177
+ };
178
+ const applyTheme = (theme)=>{
179
+ if ('undefined' == typeof window) return;
180
+ const root = document.documentElement;
181
+ const isClassListCorrect = root.classList.contains(theme.id);
182
+ const isDataThemeCorrect = root.getAttribute('data-theme') === theme.colorScheme;
183
+ const isDataPrefersColorCorrect = root.getAttribute('data-prefers-color') === theme.colorScheme;
184
+ if ('custom' === theme.id) {
185
+ clearCustomThemeColors();
186
+ applyCustomThemeColors(theme);
187
+ } else clearCustomThemeColors();
188
+ if (isClassListCorrect && isDataThemeCorrect && isDataPrefersColorCorrect && 'custom' !== theme.id) return;
189
+ if (!isDataThemeCorrect) root.setAttribute('data-theme', theme.colorScheme);
190
+ if (!isDataPrefersColorCorrect) root.setAttribute('data-prefers-color', theme.colorScheme);
191
+ root.classList.remove('dark');
192
+ root.classList.remove('light');
193
+ if (!isClassListCorrect) {
194
+ themeKeys.forEach((key)=>{
195
+ root.classList.remove(key);
196
+ });
197
+ root.classList.add('custom' === theme.id ? theme.baseThemeId : theme.id);
198
+ }
199
+ };
200
+ const extractFontFamilyFromLink = (link)=>{
201
+ if (!link) return null;
202
+ try {
203
+ const url = new URL(link);
204
+ const familyParam = url.searchParams.get('family');
205
+ if (!familyParam) return null;
206
+ const firstFamily = familyParam.split('&family=')[0].split(':')[0].replace(/\+/g, ' ');
207
+ return firstFamily;
208
+ } catch {
209
+ return null;
210
+ }
211
+ };
212
+ const applyFont = (fontName)=>{
213
+ if ('undefined' == typeof window) return;
214
+ if (fontName) {
215
+ document.documentElement.style.setProperty('--ux-font-family', `"${fontName}", ${DEFAULT_FONT_FAMILY}`);
216
+ document.body.style.fontFamily = `"${fontName}", ${DEFAULT_FONT_FAMILY}`;
217
+ } else {
218
+ document.documentElement.style.setProperty('--ux-font-family', DEFAULT_FONT_FAMILY);
219
+ document.body.style.fontFamily = DEFAULT_FONT_FAMILY;
220
+ }
221
+ };
222
+ export { applyCustomThemeColors, applyFont, applyTheme, clearCustomThemeColors, extractFontFamilyFromLink, preloadFonts, setCSSProperty };
@@ -37,14 +37,14 @@ const show = (props)=>{
37
37
  return addToast({
38
38
  classNames: {
39
39
  base: [
40
- 'bg-tertiary rounded-xl px-3.5 py-3 shadow-none border-none !w-fit max-w-[90vw] md:max-w-[400px] m-0',
40
+ 'bg-cursor rounded-xl px-3.5 py-3 shadow-none border-none !w-fit max-w-[90vw] md:max-w-[400px] m-0',
41
41
  !hideCloseButton && 'pr-12',
42
42
  'flat' === variant && 'success' === type && 'bg-[#0E3728]',
43
43
  'flat' === variant && 'error' === type && 'bg-[#501D1D]',
44
44
  base
45
45
  ],
46
46
  description: [
47
- 'text-tertiary-foreground text-xs font-medium me-0 leading-4 line-clamp-4',
47
+ 'text-cursor-foreground text-xs font-medium me-0 leading-4 line-clamp-4',
48
48
  'flat' === variant && 'text-white',
49
49
  hasLongWord(description) && 'break-all',
50
50
  descriptionClassName
@@ -72,7 +72,7 @@ const show = (props)=>{
72
72
  icon: icon ?? getIcon(type),
73
73
  hideIcon: !icon && !getIcon(type),
74
74
  closeIcon: /*#__PURE__*/ jsx(CloseIcon, {
75
- className: 'flat' === variant ? 'text-white' : 'text-tertiary-foreground'
75
+ className: 'flat' === variant ? 'text-white' : 'text-cursor-foreground'
76
76
  }),
77
77
  loadingComponent: /*#__PURE__*/ jsx(UXSpinner, {
78
78
  size: 18
@@ -6,6 +6,7 @@ export * from './UXButton';
6
6
  export * from './UXCalendar';
7
7
  export * from './UXCheckbox';
8
8
  export * from './UXChip';
9
+ export * from './UXColorPicker';
9
10
  export * from './UXCopy';
10
11
  export * from './UXDatePicker';
11
12
  export * from './UXDateRangePicker';
@@ -6,6 +6,7 @@ export * from "./UXButton/index.js";
6
6
  export * from "./UXCalendar/index.js";
7
7
  export * from "./UXCheckbox/index.js";
8
8
  export * from "./UXChip/index.js";
9
+ export * from "./UXColorPicker/index.js";
9
10
  export * from "./UXCopy/index.js";
10
11
  export * from "./UXDatePicker/index.js";
11
12
  export * from "./UXDateRangePicker/index.js";