react-better-html 1.1.242 → 1.1.244
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.js +114 -86
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +139 -111
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1968,6 +1968,75 @@ var import_react10 = require("react");
|
|
|
1968
1968
|
var import_react_better_core9 = require("react-better-core");
|
|
1969
1969
|
var import_styled_components6 = __toESM(require("styled-components"));
|
|
1970
1970
|
|
|
1971
|
+
// src/utils/variableFunctions.ts
|
|
1972
|
+
var checkBetterCoreContextValue = (value, functionsName) => {
|
|
1973
|
+
if (value === void 0) {
|
|
1974
|
+
throw new Error(
|
|
1975
|
+
`\`${functionsName}()\` must be used within a \`<BetterCoreProvider>\`. Make sure to add one at the root of your component tree.`
|
|
1976
|
+
);
|
|
1977
|
+
}
|
|
1978
|
+
return value !== void 0;
|
|
1979
|
+
};
|
|
1980
|
+
var checkBetterHtmlContextValue = (value, functionsName) => {
|
|
1981
|
+
if (value === void 0) {
|
|
1982
|
+
throw new Error(
|
|
1983
|
+
`\`${functionsName}()\` must be used within a \`<BetterHtmlProvider>\`. Make sure to add one at the root of your component tree.`
|
|
1984
|
+
);
|
|
1985
|
+
}
|
|
1986
|
+
return value !== void 0;
|
|
1987
|
+
};
|
|
1988
|
+
var alertControls = {
|
|
1989
|
+
createAlert: (alert) => {
|
|
1990
|
+
if (!checkBetterHtmlContextValue(externalBetterHtmlContextValue, "alertControls.createAlert"))
|
|
1991
|
+
return void 0;
|
|
1992
|
+
const readyAlert = {
|
|
1993
|
+
id: crypto.randomUUID(),
|
|
1994
|
+
...alert
|
|
1995
|
+
};
|
|
1996
|
+
externalBetterHtmlContextValue.setAlerts((oldValue) => [...oldValue, readyAlert]);
|
|
1997
|
+
return readyAlert;
|
|
1998
|
+
},
|
|
1999
|
+
removeAlert: (alertId) => {
|
|
2000
|
+
if (!checkBetterHtmlContextValue(externalBetterHtmlContextValue, "alertControls.removeAlert")) return;
|
|
2001
|
+
externalBetterHtmlContextValue.setAlerts((oldValue) => oldValue.filter((alert) => alert.id !== alertId));
|
|
2002
|
+
}
|
|
2003
|
+
};
|
|
2004
|
+
var sideMenuControls = {
|
|
2005
|
+
expand: () => {
|
|
2006
|
+
if (!checkBetterHtmlContextValue(externalBetterHtmlContextValue, "sideMenuControls.expand")) return;
|
|
2007
|
+
externalBetterHtmlContextValue.setSideMenuIsCollapsed.setFalse();
|
|
2008
|
+
},
|
|
2009
|
+
collapse: () => {
|
|
2010
|
+
if (!checkBetterHtmlContextValue(externalBetterHtmlContextValue, "sideMenuControls.collapse")) return;
|
|
2011
|
+
externalBetterHtmlContextValue.setSideMenuIsCollapsed.setTrue();
|
|
2012
|
+
},
|
|
2013
|
+
toggleExpanded: () => {
|
|
2014
|
+
if (!checkBetterHtmlContextValue(externalBetterHtmlContextValue, "sideMenuControls.toggleExpanded")) return;
|
|
2015
|
+
externalBetterHtmlContextValue.setSideMenuIsCollapsed.toggle();
|
|
2016
|
+
},
|
|
2017
|
+
open: () => {
|
|
2018
|
+
if (!checkBetterHtmlContextValue(externalBetterHtmlContextValue, "sideMenuControls.open")) return;
|
|
2019
|
+
externalBetterHtmlContextValue.setSideMenuIsOpenMobile.setTrue();
|
|
2020
|
+
},
|
|
2021
|
+
close: () => {
|
|
2022
|
+
if (!checkBetterHtmlContextValue(externalBetterHtmlContextValue, "sideMenuControls.close")) return;
|
|
2023
|
+
externalBetterHtmlContextValue.setSideMenuIsOpenMobile.setFalse();
|
|
2024
|
+
},
|
|
2025
|
+
toggleOpened: () => {
|
|
2026
|
+
if (!checkBetterHtmlContextValue(externalBetterHtmlContextValue, "sideMenuControls.toggleOpened")) return;
|
|
2027
|
+
externalBetterHtmlContextValue.setSideMenuIsOpenMobile.toggle();
|
|
2028
|
+
}
|
|
2029
|
+
};
|
|
2030
|
+
var filterHover = () => {
|
|
2031
|
+
if (!checkBetterCoreContextValue(externalBetterCoreContextValue, "filterHover")) return void 0;
|
|
2032
|
+
return {
|
|
2033
|
+
z05: externalBetterCoreContextValue.colorTheme === "dark" ? "brightness(1.2)" : "brightness(0.95)",
|
|
2034
|
+
z1: externalBetterCoreContextValue.colorTheme === "dark" ? "brightness(1.3)" : "brightness(0.9)",
|
|
2035
|
+
z2: externalBetterCoreContextValue.colorTheme === "dark" ? "brightness(1.6)" : "brightness(0.8)",
|
|
2036
|
+
z3: externalBetterCoreContextValue.colorTheme === "dark" ? "brightness(1.9)" : "brightness(0.7)"
|
|
2037
|
+
};
|
|
2038
|
+
};
|
|
2039
|
+
|
|
1971
2040
|
// src/components/Loader.tsx
|
|
1972
2041
|
var import_react9 = require("react");
|
|
1973
2042
|
var import_react_better_core8 = require("react-better-core");
|
|
@@ -2034,7 +2103,9 @@ var Loader_default = Loader2;
|
|
|
2034
2103
|
// src/components/Button.tsx
|
|
2035
2104
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
2036
2105
|
var ButtonElement = import_styled_components6.default.button.withConfig({
|
|
2037
|
-
shouldForwardProp: (prop) => !["theme", "colorTheme", "style", "hoverStyle", "isSmall", "withText", "isLoading"].includes(
|
|
2106
|
+
shouldForwardProp: (prop) => !["theme", "colorTheme", "style", "hoverStyle", "isSmall", "withText", "isLoading", "withNoBorder"].includes(
|
|
2107
|
+
prop
|
|
2108
|
+
)
|
|
2038
2109
|
})`
|
|
2039
2110
|
display: block;
|
|
2040
2111
|
position: relative;
|
|
@@ -2060,12 +2131,12 @@ var ButtonElement = import_styled_components6.default.button.withConfig({
|
|
|
2060
2131
|
cursor: pointer;
|
|
2061
2132
|
|
|
2062
2133
|
&:not(.secondary):hover {
|
|
2063
|
-
filter: ${props.
|
|
2134
|
+
filter: ${props.hoverStyle.filter ?? filterHover().z1};
|
|
2064
2135
|
}
|
|
2065
2136
|
|
|
2066
2137
|
&.secondary:hover {
|
|
2067
2138
|
${props.withNoBorder ? import_styled_components6.css`
|
|
2068
|
-
filter: ${props.
|
|
2139
|
+
filter: ${props.hoverStyle.filter ?? filterHover().z1};
|
|
2069
2140
|
` : import_styled_components6.css`
|
|
2070
2141
|
border-color: ${props.theme.colors.primary};
|
|
2071
2142
|
`}
|
|
@@ -3199,77 +3270,6 @@ var BetterHtmlProvider_default = (0, import_react14.memo)(BetterHtmlProvider);
|
|
|
3199
3270
|
|
|
3200
3271
|
// src/utils/functions.ts
|
|
3201
3272
|
var import_crypto_js = __toESM(require("crypto-js"));
|
|
3202
|
-
|
|
3203
|
-
// src/utils/variableFunctions.ts
|
|
3204
|
-
var checkBetterCoreContextValue = (value, functionsName) => {
|
|
3205
|
-
if (value === void 0) {
|
|
3206
|
-
throw new Error(
|
|
3207
|
-
`\`${functionsName}()\` must be used within a \`<BetterCoreProvider>\`. Make sure to add one at the root of your component tree.`
|
|
3208
|
-
);
|
|
3209
|
-
}
|
|
3210
|
-
return value !== void 0;
|
|
3211
|
-
};
|
|
3212
|
-
var checkBetterHtmlContextValue = (value, functionsName) => {
|
|
3213
|
-
if (value === void 0) {
|
|
3214
|
-
throw new Error(
|
|
3215
|
-
`\`${functionsName}()\` must be used within a \`<BetterHtmlProvider>\`. Make sure to add one at the root of your component tree.`
|
|
3216
|
-
);
|
|
3217
|
-
}
|
|
3218
|
-
return value !== void 0;
|
|
3219
|
-
};
|
|
3220
|
-
var alertControls = {
|
|
3221
|
-
createAlert: (alert) => {
|
|
3222
|
-
if (!checkBetterHtmlContextValue(externalBetterHtmlContextValue, "alertControls.createAlert"))
|
|
3223
|
-
return void 0;
|
|
3224
|
-
const readyAlert = {
|
|
3225
|
-
id: crypto.randomUUID(),
|
|
3226
|
-
...alert
|
|
3227
|
-
};
|
|
3228
|
-
externalBetterHtmlContextValue.setAlerts((oldValue) => [...oldValue, readyAlert]);
|
|
3229
|
-
return readyAlert;
|
|
3230
|
-
},
|
|
3231
|
-
removeAlert: (alertId) => {
|
|
3232
|
-
if (!checkBetterHtmlContextValue(externalBetterHtmlContextValue, "alertControls.removeAlert")) return;
|
|
3233
|
-
externalBetterHtmlContextValue.setAlerts((oldValue) => oldValue.filter((alert) => alert.id !== alertId));
|
|
3234
|
-
}
|
|
3235
|
-
};
|
|
3236
|
-
var sideMenuControls = {
|
|
3237
|
-
expand: () => {
|
|
3238
|
-
if (!checkBetterHtmlContextValue(externalBetterHtmlContextValue, "sideMenuControls.expand")) return;
|
|
3239
|
-
externalBetterHtmlContextValue.setSideMenuIsCollapsed.setFalse();
|
|
3240
|
-
},
|
|
3241
|
-
collapse: () => {
|
|
3242
|
-
if (!checkBetterHtmlContextValue(externalBetterHtmlContextValue, "sideMenuControls.collapse")) return;
|
|
3243
|
-
externalBetterHtmlContextValue.setSideMenuIsCollapsed.setTrue();
|
|
3244
|
-
},
|
|
3245
|
-
toggleExpanded: () => {
|
|
3246
|
-
if (!checkBetterHtmlContextValue(externalBetterHtmlContextValue, "sideMenuControls.toggleExpanded")) return;
|
|
3247
|
-
externalBetterHtmlContextValue.setSideMenuIsCollapsed.toggle();
|
|
3248
|
-
},
|
|
3249
|
-
open: () => {
|
|
3250
|
-
if (!checkBetterHtmlContextValue(externalBetterHtmlContextValue, "sideMenuControls.open")) return;
|
|
3251
|
-
externalBetterHtmlContextValue.setSideMenuIsOpenMobile.setTrue();
|
|
3252
|
-
},
|
|
3253
|
-
close: () => {
|
|
3254
|
-
if (!checkBetterHtmlContextValue(externalBetterHtmlContextValue, "sideMenuControls.close")) return;
|
|
3255
|
-
externalBetterHtmlContextValue.setSideMenuIsOpenMobile.setFalse();
|
|
3256
|
-
},
|
|
3257
|
-
toggleOpened: () => {
|
|
3258
|
-
if (!checkBetterHtmlContextValue(externalBetterHtmlContextValue, "sideMenuControls.toggleOpened")) return;
|
|
3259
|
-
externalBetterHtmlContextValue.setSideMenuIsOpenMobile.toggle();
|
|
3260
|
-
}
|
|
3261
|
-
};
|
|
3262
|
-
var filterHover = () => {
|
|
3263
|
-
if (!checkBetterCoreContextValue(externalBetterCoreContextValue, "filterHover")) return void 0;
|
|
3264
|
-
return {
|
|
3265
|
-
z05: externalBetterCoreContextValue.colorTheme === "dark" ? "brightness(1.2)" : "brightness(0.95)",
|
|
3266
|
-
z1: externalBetterCoreContextValue.colorTheme === "dark" ? "brightness(1.3)" : "brightness(0.9)",
|
|
3267
|
-
z2: externalBetterCoreContextValue.colorTheme === "dark" ? "brightness(1.6)" : "brightness(0.8)",
|
|
3268
|
-
z3: externalBetterCoreContextValue.colorTheme === "dark" ? "brightness(1.9)" : "brightness(0.7)"
|
|
3269
|
-
};
|
|
3270
|
-
};
|
|
3271
|
-
|
|
3272
|
-
// src/utils/functions.ts
|
|
3273
3273
|
var getBrowser = () => {
|
|
3274
3274
|
const userAgent = navigator.userAgent.toLowerCase();
|
|
3275
3275
|
if (userAgent.includes("firefox")) return "firefox";
|
|
@@ -4295,7 +4295,17 @@ var colorPickerSpacing = 4;
|
|
|
4295
4295
|
var colorPickerColorWidth = 12 + 27 + colorPickerSpacing;
|
|
4296
4296
|
var colorPickerValueWidth = 12 + 74 + colorPickerSpacing;
|
|
4297
4297
|
var InputElement = import_styled_components11.default.input.withConfig({
|
|
4298
|
-
shouldForwardProp: (prop) => ![
|
|
4298
|
+
shouldForwardProp: (prop) => ![
|
|
4299
|
+
"theme",
|
|
4300
|
+
"colorTheme",
|
|
4301
|
+
"withLeftIcon",
|
|
4302
|
+
"withRightIcon",
|
|
4303
|
+
"withPrefix",
|
|
4304
|
+
"withSuffix",
|
|
4305
|
+
"style",
|
|
4306
|
+
"hoverStyle",
|
|
4307
|
+
"withNoBorder"
|
|
4308
|
+
].includes(prop)
|
|
4299
4309
|
})`
|
|
4300
4310
|
position: relative;
|
|
4301
4311
|
width: 100%;
|
|
@@ -4321,7 +4331,11 @@ var InputElement = import_styled_components11.default.input.withConfig({
|
|
|
4321
4331
|
}
|
|
4322
4332
|
|
|
4323
4333
|
&:focus {
|
|
4324
|
-
|
|
4334
|
+
${(props) => props.withNoBorder ? import_styled_components11.css`
|
|
4335
|
+
filter: ${props.hoverStyle.filter ?? filterHover().z1};
|
|
4336
|
+
` : import_styled_components11.css`
|
|
4337
|
+
border-color: ${props.theme.colors.primary};
|
|
4338
|
+
`}
|
|
4325
4339
|
}
|
|
4326
4340
|
|
|
4327
4341
|
&:disabled {
|
|
@@ -4417,7 +4431,7 @@ var InputElement = import_styled_components11.default.input.withConfig({
|
|
|
4417
4431
|
}
|
|
4418
4432
|
`;
|
|
4419
4433
|
var TextareaElement = import_styled_components11.default.textarea.withConfig({
|
|
4420
|
-
shouldForwardProp: (prop) => !["theme", "withLeftIcon", "withRightIcon", "style", "hoverStyle"].includes(prop)
|
|
4434
|
+
shouldForwardProp: (prop) => !["theme", "colorTheme", "withLeftIcon", "withRightIcon", "style", "hoverStyle", "withNoBorder"].includes(prop)
|
|
4421
4435
|
})`
|
|
4422
4436
|
width: 100%;
|
|
4423
4437
|
min-height: 3lh;
|
|
@@ -4440,9 +4454,11 @@ var TextareaElement = import_styled_components11.default.textarea.withConfig({
|
|
|
4440
4454
|
color: ${(props) => props.theme.colors.textSecondary}80;
|
|
4441
4455
|
}
|
|
4442
4456
|
|
|
4443
|
-
|
|
4444
|
-
|
|
4445
|
-
|
|
4457
|
+
${(props) => props.withNoBorder ? import_styled_components11.css`
|
|
4458
|
+
filter: ${props.hoverStyle.filter ?? filterHover().z1};
|
|
4459
|
+
` : import_styled_components11.css`
|
|
4460
|
+
border-color: ${props.theme.colors.primary};
|
|
4461
|
+
`}
|
|
4446
4462
|
|
|
4447
4463
|
${(props) => props.style}
|
|
4448
4464
|
|
|
@@ -4566,6 +4582,7 @@ var InputFieldComponent = (0, import_react21.forwardRef)(function InputField(inp
|
|
|
4566
4582
|
InputElement,
|
|
4567
4583
|
{
|
|
4568
4584
|
theme: theme2,
|
|
4585
|
+
colorTheme,
|
|
4569
4586
|
withLeftIcon: leftIcon !== void 0,
|
|
4570
4587
|
withRightIcon: rightIcon !== void 0,
|
|
4571
4588
|
withPrefix: prefix !== void 0,
|
|
@@ -4576,6 +4593,7 @@ var InputFieldComponent = (0, import_react21.forwardRef)(function InputField(inp
|
|
|
4576
4593
|
onChange: onChangeElement,
|
|
4577
4594
|
style,
|
|
4578
4595
|
hoverStyle,
|
|
4596
|
+
withNoBorder: theme2.styles.borderWidth === 0,
|
|
4579
4597
|
...restProps,
|
|
4580
4598
|
...dataProps,
|
|
4581
4599
|
...ariaProps,
|
|
@@ -4660,6 +4678,7 @@ InputFieldComponent.multiline = (0, import_react21.forwardRef)(function Multilin
|
|
|
4660
4678
|
);
|
|
4661
4679
|
const theme2 = (0, import_react_better_core19.useTheme)();
|
|
4662
4680
|
const internalId = (0, import_react21.useId)();
|
|
4681
|
+
const { colorTheme } = (0, import_react_better_core19.useBetterCoreContext)();
|
|
4663
4682
|
const { style, hoverStyle, restProps } = useComponentPropsGrouper(props);
|
|
4664
4683
|
const dataProps = useComponentPropsWithPrefix(restProps, "data");
|
|
4665
4684
|
const ariaProps = useComponentPropsWithPrefix(restProps, "aria");
|
|
@@ -4702,6 +4721,7 @@ InputFieldComponent.multiline = (0, import_react21.forwardRef)(function Multilin
|
|
|
4702
4721
|
TextareaElement,
|
|
4703
4722
|
{
|
|
4704
4723
|
theme: theme2,
|
|
4724
|
+
colorTheme,
|
|
4705
4725
|
withLeftIcon: leftIcon !== void 0,
|
|
4706
4726
|
withRightIcon: rightIcon !== void 0,
|
|
4707
4727
|
required,
|
|
@@ -4710,6 +4730,7 @@ InputFieldComponent.multiline = (0, import_react21.forwardRef)(function Multilin
|
|
|
4710
4730
|
id: readyId,
|
|
4711
4731
|
style,
|
|
4712
4732
|
hoverStyle,
|
|
4733
|
+
withNoBorder: theme2.styles.borderWidth === 0,
|
|
4713
4734
|
...restProps,
|
|
4714
4735
|
...dataProps,
|
|
4715
4736
|
...ariaProps,
|
|
@@ -5468,7 +5489,7 @@ var componentSize = 26;
|
|
|
5468
5489
|
var switchComponentBallGap = 3;
|
|
5469
5490
|
var switchComponentMouseDownDifference = 4;
|
|
5470
5491
|
var InputElement2 = import_styled_components12.default.input.withConfig({
|
|
5471
|
-
shouldForwardProp: (prop) => !["theme", "style", "hoverStyle", "size"].includes(prop)
|
|
5492
|
+
shouldForwardProp: (prop) => !["theme", "colorTheme", "style", "hoverStyle", "size", "withNoBorder"].includes(prop)
|
|
5472
5493
|
})`
|
|
5473
5494
|
position: relative;
|
|
5474
5495
|
appearance: none;
|
|
@@ -5498,7 +5519,11 @@ var InputElement2 = import_styled_components12.default.input.withConfig({
|
|
|
5498
5519
|
${(props) => props.style}
|
|
5499
5520
|
|
|
5500
5521
|
&:hover {
|
|
5501
|
-
|
|
5522
|
+
${(props) => props.withNoBorder ? import_styled_components12.css`
|
|
5523
|
+
filter: ${props.hoverStyle.filter ?? filterHover().z1};
|
|
5524
|
+
` : import_styled_components12.css`
|
|
5525
|
+
border-color: ${props.theme.colors.primary};
|
|
5526
|
+
`}
|
|
5502
5527
|
|
|
5503
5528
|
${(props) => props.hoverStyle}
|
|
5504
5529
|
}
|
|
@@ -5572,7 +5597,7 @@ var ToggleInputComponent = (0, import_react22.forwardRef)(function ToggleInput({
|
|
|
5572
5597
|
textAdvanced,
|
|
5573
5598
|
errorText,
|
|
5574
5599
|
infoText,
|
|
5575
|
-
size,
|
|
5600
|
+
size = componentSize,
|
|
5576
5601
|
value,
|
|
5577
5602
|
onChange,
|
|
5578
5603
|
checked: controlledChecked,
|
|
@@ -5583,6 +5608,7 @@ var ToggleInputComponent = (0, import_react22.forwardRef)(function ToggleInput({
|
|
|
5583
5608
|
}, ref) {
|
|
5584
5609
|
const theme2 = (0, import_react_better_core20.useTheme)();
|
|
5585
5610
|
const internalId = (0, import_react22.useId)();
|
|
5611
|
+
const { colorTheme } = (0, import_react_better_core20.useBetterCoreContext)();
|
|
5586
5612
|
const { style, hoverStyle, excludeStyle, restProps } = useComponentPropsGrouper(props, true);
|
|
5587
5613
|
const dataProps = useComponentPropsWithPrefix(restProps, "data");
|
|
5588
5614
|
const ariaProps = useComponentPropsWithPrefix(restProps, "aria");
|
|
@@ -5623,7 +5649,9 @@ var ToggleInputComponent = (0, import_react22.forwardRef)(function ToggleInput({
|
|
|
5623
5649
|
InputElement2,
|
|
5624
5650
|
{
|
|
5625
5651
|
theme: theme2,
|
|
5652
|
+
colorTheme,
|
|
5626
5653
|
size,
|
|
5654
|
+
withNoBorder: theme2.styles.borderWidth === 0,
|
|
5627
5655
|
type: props.type ?? "checkbox",
|
|
5628
5656
|
checked,
|
|
5629
5657
|
onChange: onChangeElement,
|
|
@@ -5643,7 +5671,7 @@ var ToggleInputComponent = (0, import_react22.forwardRef)(function ToggleInput({
|
|
|
5643
5671
|
top: "50%",
|
|
5644
5672
|
left: "50%",
|
|
5645
5673
|
color: theme2.colors.base,
|
|
5646
|
-
size:
|
|
5674
|
+
size: size / 1.8,
|
|
5647
5675
|
transform: `translate(-50%, -50%)${checked ? "" : " scale(0.4)"}`,
|
|
5648
5676
|
opacity: checked ? 1 : 0,
|
|
5649
5677
|
pointerEvents: "none",
|
|
@@ -5653,8 +5681,8 @@ var ToggleInputComponent = (0, import_react22.forwardRef)(function ToggleInput({
|
|
|
5653
5681
|
Div_default,
|
|
5654
5682
|
{
|
|
5655
5683
|
position: "absolute",
|
|
5656
|
-
width:
|
|
5657
|
-
height:
|
|
5684
|
+
width: size / 2,
|
|
5685
|
+
height: size / 2,
|
|
5658
5686
|
top: "50%",
|
|
5659
5687
|
left: "50%",
|
|
5660
5688
|
backgroundColor: theme2.colors.base,
|