react-better-html 1.1.87 → 1.1.88

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/dist/index.d.mts CHANGED
@@ -332,14 +332,20 @@ type ChipProps = {
332
332
  backgroundColor?: string;
333
333
  /** @default theme.styles.borderRadius / 1.3 */
334
334
  borderRadius?: number;
335
- };
335
+ /** @default false */
336
+ isSmall?: boolean;
337
+ /** @default false */
338
+ isCircle?: boolean;
339
+ } & Pick<DivProps<unknown>, "border" | "borderColor" | "borderWidth" | "borderStyle"> & Pick<TextProps, "fontFamily" | "fontSize" | "fontWeight" | "fontStyle">;
336
340
  type ChipComponentType = {
337
341
  (props: ComponentPropWithRef<HTMLDivElement, ChipProps>): React.ReactElement;
338
- circle: (props: ComponentPropWithRef<HTMLDivElement, OmitProps<ChipProps, "borderRadius">>) => React.ReactElement;
342
+ colored: (props: ComponentPropWithRef<HTMLDivElement, OmitProps<ChipProps, "color" | "backgroundColor"> & {
343
+ color?: Color;
344
+ }>) => React.ReactElement;
339
345
  };
340
346
  declare const ChipComponent: ChipComponentType;
341
347
  declare const Chip: typeof ChipComponent & {
342
- circle: typeof ChipComponent.circle;
348
+ colored: typeof ChipComponent.colored;
343
349
  };
344
350
 
345
351
  type InputFieldProps = {
@@ -745,6 +751,11 @@ declare const getBrowser: () => BrowserName | undefined;
745
751
  declare const formatPhoneNumber: (phoneNumber: string) => string;
746
752
  declare const getFormErrorObject: <FormFields extends ReturnType<typeof useForm>["values"]>(formValues: FormFields) => PartialRecord<keyof FormFields, string>;
747
753
 
754
+ declare const lightenColor: (hexColor: string, amount: number) => string;
755
+ declare const darkenColor: (hexColor: string, amount: number) => string;
756
+ declare const saturateColor: (hexColor: string, amount: number) => string;
757
+ declare const desaturateColor: (hexColor: string, amount: number) => string;
758
+
748
759
  declare const loaderControls: {
749
760
  startLoading: (loaderName: LoaderName | AnyOtherString) => void;
750
761
  stopLoading: (loaderName: LoaderName | AnyOtherString) => void;
@@ -754,4 +765,4 @@ declare const isMobileDevice: boolean;
754
765
 
755
766
  declare const reactRouterDomPlugin: BetterHtmlPlugin;
756
767
 
757
- export { type AppConfig, type AssetName, type AssetsConfig, type BetterHtmlConfig, type BetterHtmlPlugin, _default as BetterHtmlProvider, type BetterHtmlProviderValue, type BrowserName, Button, type ButtonProps, Chip, type ChipProps, type Color, type ColorName, type ColorTheme, ColorThemeSwitch, type ColorThemeSwitchProps, type Colors, type DeepPartialRecord, Div, type DivProps, _default$6 as Divider, Dropdown, type DropdownOption, type DropdownProps, type ExcludeOptions, Foldable, type FoldableProps, type FoldableRef, _default$2 as Form, type FormProps, FormRow, type FormRowProps, type HorizontalDividerProps, _default$8 as Icon, type IconName, type IconProps, type IconsConfig, _default$7 as Image, type ImageProps, InputField, type InputFieldProps, _default$1 as Label, type LabelProps, Loader, type LoaderConfig, type LoaderName, type LoaderProps, Modal, type ModalProps, type ModalRef, type OmitProps, _default$4 as PageHeader, type PageHeaderProps, _default$5 as PageHolder, type PageHolderProps, type PartialRecord, type PickAllRequired, type PickValue, type PluginName, type Styles, type TabGroup, Table, type TableColumn, type TableProps, Tabs, type TabsProps, type TabsRef, Text, type TextAs, type TextProps, type TextareaFieldProps, type Theme, type ThemeConfig, _default$3 as ToggleInput, type ToggleInputProps, type ToggleInputRef, type VerticalDividerProps, formatPhoneNumber, generateRandomString, getBrowser, getFormErrorObject, isMobileDevice, loaderControls, reactRouterDomPlugin, useBetterHtmlContext, useBooleanState, useDebounceState, useForm, useLoader, useLoaderControls, useMediaQuery, usePageResize, usePageScroll, useTheme, useUrlQuery };
768
+ export { type AppConfig, type AssetName, type AssetsConfig, type BetterHtmlConfig, type BetterHtmlPlugin, _default as BetterHtmlProvider, type BetterHtmlProviderValue, type BrowserName, Button, type ButtonProps, Chip, type ChipProps, type Color, type ColorName, type ColorTheme, ColorThemeSwitch, type ColorThemeSwitchProps, type Colors, type DeepPartialRecord, Div, type DivProps, _default$6 as Divider, Dropdown, type DropdownOption, type DropdownProps, type ExcludeOptions, Foldable, type FoldableProps, type FoldableRef, _default$2 as Form, type FormProps, FormRow, type FormRowProps, type HorizontalDividerProps, _default$8 as Icon, type IconName, type IconProps, type IconsConfig, _default$7 as Image, type ImageProps, InputField, type InputFieldProps, _default$1 as Label, type LabelProps, Loader, type LoaderConfig, type LoaderName, type LoaderProps, Modal, type ModalProps, type ModalRef, type OmitProps, _default$4 as PageHeader, type PageHeaderProps, _default$5 as PageHolder, type PageHolderProps, type PartialRecord, type PickAllRequired, type PickValue, type PluginName, type Styles, type TabGroup, Table, type TableColumn, type TableProps, Tabs, type TabsProps, type TabsRef, Text, type TextAs, type TextProps, type TextareaFieldProps, type Theme, type ThemeConfig, _default$3 as ToggleInput, type ToggleInputProps, type ToggleInputRef, type VerticalDividerProps, darkenColor, desaturateColor, formatPhoneNumber, generateRandomString, getBrowser, getFormErrorObject, isMobileDevice, lightenColor, loaderControls, reactRouterDomPlugin, saturateColor, useBetterHtmlContext, useBooleanState, useDebounceState, useForm, useLoader, useLoaderControls, useMediaQuery, usePageResize, usePageScroll, useTheme, useUrlQuery };
package/dist/index.d.ts CHANGED
@@ -332,14 +332,20 @@ type ChipProps = {
332
332
  backgroundColor?: string;
333
333
  /** @default theme.styles.borderRadius / 1.3 */
334
334
  borderRadius?: number;
335
- };
335
+ /** @default false */
336
+ isSmall?: boolean;
337
+ /** @default false */
338
+ isCircle?: boolean;
339
+ } & Pick<DivProps<unknown>, "border" | "borderColor" | "borderWidth" | "borderStyle"> & Pick<TextProps, "fontFamily" | "fontSize" | "fontWeight" | "fontStyle">;
336
340
  type ChipComponentType = {
337
341
  (props: ComponentPropWithRef<HTMLDivElement, ChipProps>): React.ReactElement;
338
- circle: (props: ComponentPropWithRef<HTMLDivElement, OmitProps<ChipProps, "borderRadius">>) => React.ReactElement;
342
+ colored: (props: ComponentPropWithRef<HTMLDivElement, OmitProps<ChipProps, "color" | "backgroundColor"> & {
343
+ color?: Color;
344
+ }>) => React.ReactElement;
339
345
  };
340
346
  declare const ChipComponent: ChipComponentType;
341
347
  declare const Chip: typeof ChipComponent & {
342
- circle: typeof ChipComponent.circle;
348
+ colored: typeof ChipComponent.colored;
343
349
  };
344
350
 
345
351
  type InputFieldProps = {
@@ -745,6 +751,11 @@ declare const getBrowser: () => BrowserName | undefined;
745
751
  declare const formatPhoneNumber: (phoneNumber: string) => string;
746
752
  declare const getFormErrorObject: <FormFields extends ReturnType<typeof useForm>["values"]>(formValues: FormFields) => PartialRecord<keyof FormFields, string>;
747
753
 
754
+ declare const lightenColor: (hexColor: string, amount: number) => string;
755
+ declare const darkenColor: (hexColor: string, amount: number) => string;
756
+ declare const saturateColor: (hexColor: string, amount: number) => string;
757
+ declare const desaturateColor: (hexColor: string, amount: number) => string;
758
+
748
759
  declare const loaderControls: {
749
760
  startLoading: (loaderName: LoaderName | AnyOtherString) => void;
750
761
  stopLoading: (loaderName: LoaderName | AnyOtherString) => void;
@@ -754,4 +765,4 @@ declare const isMobileDevice: boolean;
754
765
 
755
766
  declare const reactRouterDomPlugin: BetterHtmlPlugin;
756
767
 
757
- export { type AppConfig, type AssetName, type AssetsConfig, type BetterHtmlConfig, type BetterHtmlPlugin, _default as BetterHtmlProvider, type BetterHtmlProviderValue, type BrowserName, Button, type ButtonProps, Chip, type ChipProps, type Color, type ColorName, type ColorTheme, ColorThemeSwitch, type ColorThemeSwitchProps, type Colors, type DeepPartialRecord, Div, type DivProps, _default$6 as Divider, Dropdown, type DropdownOption, type DropdownProps, type ExcludeOptions, Foldable, type FoldableProps, type FoldableRef, _default$2 as Form, type FormProps, FormRow, type FormRowProps, type HorizontalDividerProps, _default$8 as Icon, type IconName, type IconProps, type IconsConfig, _default$7 as Image, type ImageProps, InputField, type InputFieldProps, _default$1 as Label, type LabelProps, Loader, type LoaderConfig, type LoaderName, type LoaderProps, Modal, type ModalProps, type ModalRef, type OmitProps, _default$4 as PageHeader, type PageHeaderProps, _default$5 as PageHolder, type PageHolderProps, type PartialRecord, type PickAllRequired, type PickValue, type PluginName, type Styles, type TabGroup, Table, type TableColumn, type TableProps, Tabs, type TabsProps, type TabsRef, Text, type TextAs, type TextProps, type TextareaFieldProps, type Theme, type ThemeConfig, _default$3 as ToggleInput, type ToggleInputProps, type ToggleInputRef, type VerticalDividerProps, formatPhoneNumber, generateRandomString, getBrowser, getFormErrorObject, isMobileDevice, loaderControls, reactRouterDomPlugin, useBetterHtmlContext, useBooleanState, useDebounceState, useForm, useLoader, useLoaderControls, useMediaQuery, usePageResize, usePageScroll, useTheme, useUrlQuery };
768
+ export { type AppConfig, type AssetName, type AssetsConfig, type BetterHtmlConfig, type BetterHtmlPlugin, _default as BetterHtmlProvider, type BetterHtmlProviderValue, type BrowserName, Button, type ButtonProps, Chip, type ChipProps, type Color, type ColorName, type ColorTheme, ColorThemeSwitch, type ColorThemeSwitchProps, type Colors, type DeepPartialRecord, Div, type DivProps, _default$6 as Divider, Dropdown, type DropdownOption, type DropdownProps, type ExcludeOptions, Foldable, type FoldableProps, type FoldableRef, _default$2 as Form, type FormProps, FormRow, type FormRowProps, type HorizontalDividerProps, _default$8 as Icon, type IconName, type IconProps, type IconsConfig, _default$7 as Image, type ImageProps, InputField, type InputFieldProps, _default$1 as Label, type LabelProps, Loader, type LoaderConfig, type LoaderName, type LoaderProps, Modal, type ModalProps, type ModalRef, type OmitProps, _default$4 as PageHeader, type PageHeaderProps, _default$5 as PageHolder, type PageHolderProps, type PartialRecord, type PickAllRequired, type PickValue, type PluginName, type Styles, type TabGroup, Table, type TableColumn, type TableProps, Tabs, type TabsProps, type TabsRef, Text, type TextAs, type TextProps, type TextareaFieldProps, type Theme, type ThemeConfig, _default$3 as ToggleInput, type ToggleInputProps, type ToggleInputRef, type VerticalDividerProps, darkenColor, desaturateColor, formatPhoneNumber, generateRandomString, getBrowser, getFormErrorObject, isMobileDevice, lightenColor, loaderControls, reactRouterDomPlugin, saturateColor, useBetterHtmlContext, useBooleanState, useDebounceState, useForm, useLoader, useLoaderControls, useMediaQuery, usePageResize, usePageScroll, useTheme, useUrlQuery };
package/dist/index.js CHANGED
@@ -52,13 +52,17 @@ __export(index_exports, {
52
52
  Tabs: () => Tabs_default,
53
53
  Text: () => Text_default,
54
54
  ToggleInput: () => ToggleInput_default,
55
+ darkenColor: () => darkenColor,
56
+ desaturateColor: () => desaturateColor,
55
57
  formatPhoneNumber: () => formatPhoneNumber,
56
58
  generateRandomString: () => generateRandomString,
57
59
  getBrowser: () => getBrowser,
58
60
  getFormErrorObject: () => getFormErrorObject,
59
61
  isMobileDevice: () => isMobileDevice,
62
+ lightenColor: () => lightenColor,
60
63
  loaderControls: () => loaderControls,
61
64
  reactRouterDomPlugin: () => reactRouterDomPlugin,
65
+ saturateColor: () => saturateColor,
62
66
  useBetterHtmlContext: () => useBetterHtmlContext,
63
67
  useBooleanState: () => useBooleanState,
64
68
  useDebounceState: () => useDebounceState,
@@ -1422,8 +1426,8 @@ var theme = {
1422
1426
  error: "#f5384b",
1423
1427
  base: "#f8f8f8",
1424
1428
  backgroundBase: "#111111",
1425
- backgroundSecondary: "#222222",
1426
- backgroundContent: "#333333",
1429
+ backgroundSecondary: "#282828",
1430
+ backgroundContent: "#444444",
1427
1431
  border: "#777777"
1428
1432
  }
1429
1433
  }
@@ -3169,27 +3173,160 @@ var PageHeader_default = (0, import_react13.memo)(PageHeader);
3169
3173
 
3170
3174
  // src/components/Chip.tsx
3171
3175
  var import_react14 = require("react");
3176
+
3177
+ // src/utils/colorManipulation.ts
3178
+ var rgbToHsl = (r, g, b) => {
3179
+ r /= 255;
3180
+ g /= 255;
3181
+ b /= 255;
3182
+ const max = Math.max(r, g, b);
3183
+ const min = Math.min(r, g, b);
3184
+ let h = 0;
3185
+ let s = 0;
3186
+ const l = (max + min) / 2;
3187
+ if (max !== min) {
3188
+ const d = max - min;
3189
+ s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
3190
+ switch (max) {
3191
+ case r:
3192
+ h = (g - b) / d + (g < b ? 6 : 0);
3193
+ break;
3194
+ case g:
3195
+ h = (b - r) / d + 2;
3196
+ break;
3197
+ case b:
3198
+ h = (r - g) / d + 4;
3199
+ break;
3200
+ }
3201
+ h /= 6;
3202
+ }
3203
+ return [h, s, l];
3204
+ };
3205
+ var hslToRgb = (h, s, l) => {
3206
+ let r, g, b;
3207
+ if (s === 0) {
3208
+ r = g = b = l;
3209
+ } else {
3210
+ const hue2rgb = (p2, q2, t) => {
3211
+ if (t < 0) t += 1;
3212
+ if (t > 1) t -= 1;
3213
+ if (t < 1 / 6) return p2 + (q2 - p2) * 6 * t;
3214
+ if (t < 1 / 2) return q2;
3215
+ if (t < 2 / 3) return p2 + (q2 - p2) * (2 / 3 - t) * 6;
3216
+ return p2;
3217
+ };
3218
+ const q = l < 0.5 ? l * (1 + s) : l + s - l * s;
3219
+ const p = 2 * l - q;
3220
+ r = hue2rgb(p, q, h + 1 / 3);
3221
+ g = hue2rgb(p, q, h);
3222
+ b = hue2rgb(p, q, h - 1 / 3);
3223
+ }
3224
+ return [Math.round(r * 255), Math.round(g * 255), Math.round(b * 255)];
3225
+ };
3226
+ var lightenColor = (hexColor, amount) => {
3227
+ let hex = hexColor.replace(/^#/, "");
3228
+ if (hex.length === 3) {
3229
+ hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
3230
+ }
3231
+ const safeAmount = Math.max(0, Math.min(1, amount));
3232
+ const r = parseInt(hex.substring(0, 2), 16);
3233
+ const g = parseInt(hex.substring(2, 4), 16);
3234
+ const b = parseInt(hex.substring(4, 6), 16);
3235
+ const lightenComponent = (component) => {
3236
+ return Math.round(component + (255 - component) * safeAmount);
3237
+ };
3238
+ const rHex = lightenComponent(r).toString(16).padStart(2, "0");
3239
+ const gHex = lightenComponent(g).toString(16).padStart(2, "0");
3240
+ const bHex = lightenComponent(b).toString(16).padStart(2, "0");
3241
+ return `#${rHex}${gHex}${bHex}`;
3242
+ };
3243
+ var darkenColor = (hexColor, amount) => {
3244
+ let hex = hexColor.replace(/^#/, "");
3245
+ if (hex.length === 3) {
3246
+ hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
3247
+ }
3248
+ const safeAmount = Math.max(0, Math.min(1, amount));
3249
+ const r = parseInt(hex.substring(0, 2), 16);
3250
+ const g = parseInt(hex.substring(2, 4), 16);
3251
+ const b = parseInt(hex.substring(4, 6), 16);
3252
+ const darkenComponent = (component) => {
3253
+ return Math.round(component * (1 - safeAmount));
3254
+ };
3255
+ const rHex = darkenComponent(r).toString(16).padStart(2, "0");
3256
+ const gHex = darkenComponent(g).toString(16).padStart(2, "0");
3257
+ const bHex = darkenComponent(b).toString(16).padStart(2, "0");
3258
+ return `#${rHex}${gHex}${bHex}`;
3259
+ };
3260
+ var saturateColor = (hexColor, amount) => {
3261
+ let hex = hexColor.replace(/^#/, "");
3262
+ if (hex.length === 3) {
3263
+ hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
3264
+ }
3265
+ const safeAmount = Math.max(0, Math.min(1, amount));
3266
+ const r = parseInt(hex.substring(0, 2), 16);
3267
+ const g = parseInt(hex.substring(2, 4), 16);
3268
+ const b = parseInt(hex.substring(4, 6), 16);
3269
+ const [h, s, l] = rgbToHsl(r, g, b);
3270
+ const newSaturation = Math.min(1, s + safeAmount * (1 - s));
3271
+ const [newR, newG, newB] = hslToRgb(h, newSaturation, l);
3272
+ const rHex = Math.round(newR).toString(16).padStart(2, "0");
3273
+ const gHex = Math.round(newG).toString(16).padStart(2, "0");
3274
+ const bHex = Math.round(newB).toString(16).padStart(2, "0");
3275
+ return `#${rHex}${gHex}${bHex}`;
3276
+ };
3277
+ var desaturateColor = (hexColor, amount) => {
3278
+ let hex = hexColor.replace(/^#/, "");
3279
+ if (hex.length === 3) {
3280
+ hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
3281
+ }
3282
+ const safeAmount = Math.max(0, Math.min(1, amount));
3283
+ const r = parseInt(hex.substring(0, 2), 16);
3284
+ const g = parseInt(hex.substring(2, 4), 16);
3285
+ const b = parseInt(hex.substring(4, 6), 16);
3286
+ const [h, s, l] = rgbToHsl(r, g, b);
3287
+ const newSaturation = Math.max(0, s * (1 - safeAmount));
3288
+ const [newR, newG, newB] = hslToRgb(h, newSaturation, l);
3289
+ const rHex = Math.round(newR).toString(16).padStart(2, "0");
3290
+ const gHex = Math.round(newG).toString(16).padStart(2, "0");
3291
+ const bHex = Math.round(newB).toString(16).padStart(2, "0");
3292
+ return `#${rHex}${gHex}${bHex}`;
3293
+ };
3294
+
3295
+ // src/components/Chip.tsx
3172
3296
  var import_jsx_runtime12 = require("react/jsx-runtime");
3173
- var ChipComponent = (0, import_react14.forwardRef)(function Chip({ text, color, backgroundColor, borderRadius }, ref) {
3297
+ var ChipComponent = (0, import_react14.forwardRef)(function Chip({ text, color, backgroundColor, borderRadius, isSmall, isCircle, ...props }, ref) {
3174
3298
  const theme2 = useTheme();
3175
3299
  return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
3176
3300
  Div_default,
3177
3301
  {
3178
3302
  width: "fit-content",
3179
3303
  backgroundColor: backgroundColor ?? theme2.colors.backgroundSecondary,
3180
- borderRadius: borderRadius ?? theme2.styles.borderRadius / 1.3,
3181
- paddingBlock: theme2.styles.gap,
3182
- paddingInline: theme2.styles.space,
3304
+ borderRadius: isCircle ? 999 : borderRadius ?? theme2.styles.borderRadius / 1.3,
3305
+ paddingBlock: theme2.styles.gap / (isSmall ? 2 : 1),
3306
+ paddingInline: theme2.styles.space / (isSmall ? 1.5 : 1),
3307
+ ...props,
3183
3308
  ref,
3184
3309
  children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Text_default, { color: color ?? theme2.colors.textPrimary, children: text })
3185
3310
  }
3186
3311
  );
3187
3312
  });
3188
- ChipComponent.circle = (0, import_react14.forwardRef)(function Circle(props, ref) {
3189
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ChipComponent, { borderRadius: 999, ref, ...props });
3313
+ ChipComponent.colored = (0, import_react14.forwardRef)(function Colored({ color, ...props }, ref) {
3314
+ const theme2 = useTheme();
3315
+ const { colorTheme } = useBetterHtmlContextInternal();
3316
+ const readyColor = color ?? theme2.colors.textSecondary;
3317
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
3318
+ ChipComponent,
3319
+ {
3320
+ color: colorTheme === "light" ? darkenColor(readyColor, 0.7) : lightenColor(readyColor, 0.7),
3321
+ backgroundColor: readyColor + "40",
3322
+ border: `1px solid ${readyColor}`,
3323
+ ref,
3324
+ ...props
3325
+ }
3326
+ );
3190
3327
  });
3191
3328
  var Chip2 = (0, import_react14.memo)(ChipComponent);
3192
- Chip2.circle = ChipComponent.circle;
3329
+ Chip2.colored = ChipComponent.colored;
3193
3330
  var Chip_default = Chip2;
3194
3331
 
3195
3332
  // src/components/InputField.tsx
@@ -6985,13 +7122,17 @@ var reactRouterDomPlugin = {
6985
7122
  Tabs,
6986
7123
  Text,
6987
7124
  ToggleInput,
7125
+ darkenColor,
7126
+ desaturateColor,
6988
7127
  formatPhoneNumber,
6989
7128
  generateRandomString,
6990
7129
  getBrowser,
6991
7130
  getFormErrorObject,
6992
7131
  isMobileDevice,
7132
+ lightenColor,
6993
7133
  loaderControls,
6994
7134
  reactRouterDomPlugin,
7135
+ saturateColor,
6995
7136
  useBetterHtmlContext,
6996
7137
  useBooleanState,
6997
7138
  useDebounceState,