react-better-html 1.1.86 → 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.mjs CHANGED
@@ -1347,8 +1347,8 @@ var theme = {
1347
1347
  error: "#f5384b",
1348
1348
  base: "#f8f8f8",
1349
1349
  backgroundBase: "#111111",
1350
- backgroundSecondary: "#222222",
1351
- backgroundContent: "#333333",
1350
+ backgroundSecondary: "#282828",
1351
+ backgroundContent: "#444444",
1352
1352
  border: "#777777"
1353
1353
  }
1354
1354
  }
@@ -2212,7 +2212,7 @@ DivComponent.column = forwardRef(function Column({ flexReverse, invertFlexDirect
2212
2212
  DivComponent,
2213
2213
  {
2214
2214
  display: "flex",
2215
- flexDirection: (invertFlexDirection ? "column" : "row") + reverseSuffix,
2215
+ flexDirection: (invertFlexDirection ? "row" : "column") + reverseSuffix,
2216
2216
  ref,
2217
2217
  ...props
2218
2218
  }
@@ -3094,27 +3094,160 @@ var PageHeader_default = memo11(PageHeader);
3094
3094
 
3095
3095
  // src/components/Chip.tsx
3096
3096
  import { forwardRef as forwardRef6, memo as memo12 } from "react";
3097
+
3098
+ // src/utils/colorManipulation.ts
3099
+ var rgbToHsl = (r, g, b) => {
3100
+ r /= 255;
3101
+ g /= 255;
3102
+ b /= 255;
3103
+ const max = Math.max(r, g, b);
3104
+ const min = Math.min(r, g, b);
3105
+ let h = 0;
3106
+ let s = 0;
3107
+ const l = (max + min) / 2;
3108
+ if (max !== min) {
3109
+ const d = max - min;
3110
+ s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
3111
+ switch (max) {
3112
+ case r:
3113
+ h = (g - b) / d + (g < b ? 6 : 0);
3114
+ break;
3115
+ case g:
3116
+ h = (b - r) / d + 2;
3117
+ break;
3118
+ case b:
3119
+ h = (r - g) / d + 4;
3120
+ break;
3121
+ }
3122
+ h /= 6;
3123
+ }
3124
+ return [h, s, l];
3125
+ };
3126
+ var hslToRgb = (h, s, l) => {
3127
+ let r, g, b;
3128
+ if (s === 0) {
3129
+ r = g = b = l;
3130
+ } else {
3131
+ const hue2rgb = (p2, q2, t) => {
3132
+ if (t < 0) t += 1;
3133
+ if (t > 1) t -= 1;
3134
+ if (t < 1 / 6) return p2 + (q2 - p2) * 6 * t;
3135
+ if (t < 1 / 2) return q2;
3136
+ if (t < 2 / 3) return p2 + (q2 - p2) * (2 / 3 - t) * 6;
3137
+ return p2;
3138
+ };
3139
+ const q = l < 0.5 ? l * (1 + s) : l + s - l * s;
3140
+ const p = 2 * l - q;
3141
+ r = hue2rgb(p, q, h + 1 / 3);
3142
+ g = hue2rgb(p, q, h);
3143
+ b = hue2rgb(p, q, h - 1 / 3);
3144
+ }
3145
+ return [Math.round(r * 255), Math.round(g * 255), Math.round(b * 255)];
3146
+ };
3147
+ var lightenColor = (hexColor, amount) => {
3148
+ let hex = hexColor.replace(/^#/, "");
3149
+ if (hex.length === 3) {
3150
+ hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
3151
+ }
3152
+ const safeAmount = Math.max(0, Math.min(1, amount));
3153
+ const r = parseInt(hex.substring(0, 2), 16);
3154
+ const g = parseInt(hex.substring(2, 4), 16);
3155
+ const b = parseInt(hex.substring(4, 6), 16);
3156
+ const lightenComponent = (component) => {
3157
+ return Math.round(component + (255 - component) * safeAmount);
3158
+ };
3159
+ const rHex = lightenComponent(r).toString(16).padStart(2, "0");
3160
+ const gHex = lightenComponent(g).toString(16).padStart(2, "0");
3161
+ const bHex = lightenComponent(b).toString(16).padStart(2, "0");
3162
+ return `#${rHex}${gHex}${bHex}`;
3163
+ };
3164
+ var darkenColor = (hexColor, amount) => {
3165
+ let hex = hexColor.replace(/^#/, "");
3166
+ if (hex.length === 3) {
3167
+ hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
3168
+ }
3169
+ const safeAmount = Math.max(0, Math.min(1, amount));
3170
+ const r = parseInt(hex.substring(0, 2), 16);
3171
+ const g = parseInt(hex.substring(2, 4), 16);
3172
+ const b = parseInt(hex.substring(4, 6), 16);
3173
+ const darkenComponent = (component) => {
3174
+ return Math.round(component * (1 - safeAmount));
3175
+ };
3176
+ const rHex = darkenComponent(r).toString(16).padStart(2, "0");
3177
+ const gHex = darkenComponent(g).toString(16).padStart(2, "0");
3178
+ const bHex = darkenComponent(b).toString(16).padStart(2, "0");
3179
+ return `#${rHex}${gHex}${bHex}`;
3180
+ };
3181
+ var saturateColor = (hexColor, amount) => {
3182
+ let hex = hexColor.replace(/^#/, "");
3183
+ if (hex.length === 3) {
3184
+ hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
3185
+ }
3186
+ const safeAmount = Math.max(0, Math.min(1, amount));
3187
+ const r = parseInt(hex.substring(0, 2), 16);
3188
+ const g = parseInt(hex.substring(2, 4), 16);
3189
+ const b = parseInt(hex.substring(4, 6), 16);
3190
+ const [h, s, l] = rgbToHsl(r, g, b);
3191
+ const newSaturation = Math.min(1, s + safeAmount * (1 - s));
3192
+ const [newR, newG, newB] = hslToRgb(h, newSaturation, l);
3193
+ const rHex = Math.round(newR).toString(16).padStart(2, "0");
3194
+ const gHex = Math.round(newG).toString(16).padStart(2, "0");
3195
+ const bHex = Math.round(newB).toString(16).padStart(2, "0");
3196
+ return `#${rHex}${gHex}${bHex}`;
3197
+ };
3198
+ var desaturateColor = (hexColor, amount) => {
3199
+ let hex = hexColor.replace(/^#/, "");
3200
+ if (hex.length === 3) {
3201
+ hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
3202
+ }
3203
+ const safeAmount = Math.max(0, Math.min(1, amount));
3204
+ const r = parseInt(hex.substring(0, 2), 16);
3205
+ const g = parseInt(hex.substring(2, 4), 16);
3206
+ const b = parseInt(hex.substring(4, 6), 16);
3207
+ const [h, s, l] = rgbToHsl(r, g, b);
3208
+ const newSaturation = Math.max(0, s * (1 - safeAmount));
3209
+ const [newR, newG, newB] = hslToRgb(h, newSaturation, l);
3210
+ const rHex = Math.round(newR).toString(16).padStart(2, "0");
3211
+ const gHex = Math.round(newG).toString(16).padStart(2, "0");
3212
+ const bHex = Math.round(newB).toString(16).padStart(2, "0");
3213
+ return `#${rHex}${gHex}${bHex}`;
3214
+ };
3215
+
3216
+ // src/components/Chip.tsx
3097
3217
  import { jsx as jsx12 } from "react/jsx-runtime";
3098
- var ChipComponent = forwardRef6(function Chip({ text, color, backgroundColor, borderRadius }, ref) {
3218
+ var ChipComponent = forwardRef6(function Chip({ text, color, backgroundColor, borderRadius, isSmall, isCircle, ...props }, ref) {
3099
3219
  const theme2 = useTheme();
3100
3220
  return /* @__PURE__ */ jsx12(
3101
3221
  Div_default,
3102
3222
  {
3103
3223
  width: "fit-content",
3104
3224
  backgroundColor: backgroundColor ?? theme2.colors.backgroundSecondary,
3105
- borderRadius: borderRadius ?? theme2.styles.borderRadius / 1.3,
3106
- paddingBlock: theme2.styles.gap,
3107
- paddingInline: theme2.styles.space,
3225
+ borderRadius: isCircle ? 999 : borderRadius ?? theme2.styles.borderRadius / 1.3,
3226
+ paddingBlock: theme2.styles.gap / (isSmall ? 2 : 1),
3227
+ paddingInline: theme2.styles.space / (isSmall ? 1.5 : 1),
3228
+ ...props,
3108
3229
  ref,
3109
3230
  children: /* @__PURE__ */ jsx12(Text_default, { color: color ?? theme2.colors.textPrimary, children: text })
3110
3231
  }
3111
3232
  );
3112
3233
  });
3113
- ChipComponent.circle = forwardRef6(function Circle(props, ref) {
3114
- return /* @__PURE__ */ jsx12(ChipComponent, { borderRadius: 999, ref, ...props });
3234
+ ChipComponent.colored = forwardRef6(function Colored({ color, ...props }, ref) {
3235
+ const theme2 = useTheme();
3236
+ const { colorTheme } = useBetterHtmlContextInternal();
3237
+ const readyColor = color ?? theme2.colors.textSecondary;
3238
+ return /* @__PURE__ */ jsx12(
3239
+ ChipComponent,
3240
+ {
3241
+ color: colorTheme === "light" ? darkenColor(readyColor, 0.7) : lightenColor(readyColor, 0.7),
3242
+ backgroundColor: readyColor + "40",
3243
+ border: `1px solid ${readyColor}`,
3244
+ ref,
3245
+ ...props
3246
+ }
3247
+ );
3115
3248
  });
3116
3249
  var Chip2 = memo12(ChipComponent);
3117
- Chip2.circle = ChipComponent.circle;
3250
+ Chip2.colored = ChipComponent.colored;
3118
3251
  var Chip_default = Chip2;
3119
3252
 
3120
3253
  // src/components/InputField.tsx
@@ -6909,13 +7042,17 @@ export {
6909
7042
  Tabs_default as Tabs,
6910
7043
  Text_default as Text,
6911
7044
  ToggleInput_default as ToggleInput,
7045
+ darkenColor,
7046
+ desaturateColor,
6912
7047
  formatPhoneNumber,
6913
7048
  generateRandomString,
6914
7049
  getBrowser,
6915
7050
  getFormErrorObject,
6916
7051
  isMobileDevice,
7052
+ lightenColor,
6917
7053
  loaderControls,
6918
7054
  reactRouterDomPlugin,
7055
+ saturateColor,
6919
7056
  useBetterHtmlContext,
6920
7057
  useBooleanState,
6921
7058
  useDebounceState,