@dreamtree-org/twreact-ui 1.0.59 → 1.0.60
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.esm.js +32 -13
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +32 -13
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -10336,6 +10336,9 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (_ref, forwardedRef) {
|
|
|
10336
10336
|
* - Sizes: 'sm' | 'md' | 'lg'
|
|
10337
10337
|
* - Accessible (role="switch", keyboard toggle)
|
|
10338
10338
|
* - Hidden input for form serialization (name prop)
|
|
10339
|
+
*
|
|
10340
|
+
* New props:
|
|
10341
|
+
* - topLabel, bottomLabel, rightLabel, leftLable (renders label in those positions)
|
|
10339
10342
|
*/
|
|
10340
10343
|
|
|
10341
10344
|
var SIZE_MAP$2 = {
|
|
@@ -10356,7 +10359,6 @@ var SIZE_MAP$2 = {
|
|
|
10356
10359
|
}
|
|
10357
10360
|
};
|
|
10358
10361
|
function Switch(props) {
|
|
10359
|
-
var _ref;
|
|
10360
10362
|
var id = props.id,
|
|
10361
10363
|
name = props.name,
|
|
10362
10364
|
checked = props.checked,
|
|
@@ -10371,9 +10373,10 @@ function Switch(props) {
|
|
|
10371
10373
|
thumbColor = props.thumbColor,
|
|
10372
10374
|
_props$className = props.className,
|
|
10373
10375
|
className = _props$className === void 0 ? "" : _props$className,
|
|
10374
|
-
|
|
10375
|
-
|
|
10376
|
-
|
|
10376
|
+
topLabel = props.topLabel,
|
|
10377
|
+
bottomLabel = props.bottomLabel,
|
|
10378
|
+
rightLabel = props.rightLabel,
|
|
10379
|
+
leftLable = props.leftLable,
|
|
10377
10380
|
ariaLabel = props.ariaLabel;
|
|
10378
10381
|
var isControlled = typeof checked === "boolean";
|
|
10379
10382
|
var _useState = React.useState(defaultChecked),
|
|
@@ -10421,17 +10424,30 @@ function Switch(props) {
|
|
|
10421
10424
|
|
|
10422
10425
|
// fallback when ON and no bgColor provided (keeps the switch visible)
|
|
10423
10426
|
var fallbackOnClass = isOn && !bgColor ? "bg-sky-500" : "";
|
|
10427
|
+
|
|
10428
|
+
// Accessible label fallback: prefer ariaLabel, otherwise first provided visible label, otherwise "Toggle"
|
|
10429
|
+
var accessibleLabel = ariaLabel || rightLabel || leftLable || topLabel || bottomLabel || "Toggle";
|
|
10430
|
+
|
|
10431
|
+
// Container layout: column if top or bottom labels exist, otherwise row
|
|
10432
|
+
var containerIsColumn = Boolean(topLabel || bottomLabel);
|
|
10433
|
+
var containerClass = [containerIsColumn ? "flex flex-col items-center" : "inline-flex items-center", "gap-2", className].filter(Boolean).join(" ");
|
|
10434
|
+
var labelOpacityClass = disabled ? "opacity-50" : "";
|
|
10424
10435
|
return /*#__PURE__*/React.createElement("div", {
|
|
10425
|
-
className:
|
|
10426
|
-
},
|
|
10436
|
+
className: containerClass
|
|
10437
|
+
}, topLabel ? /*#__PURE__*/React.createElement("label", {
|
|
10427
10438
|
htmlFor: idRef.current,
|
|
10428
|
-
className:
|
|
10429
|
-
},
|
|
10439
|
+
className: labelOpacityClass
|
|
10440
|
+
}, topLabel) : null, /*#__PURE__*/React.createElement("div", {
|
|
10441
|
+
className: "inline-flex items-center gap-2"
|
|
10442
|
+
}, leftLable ? /*#__PURE__*/React.createElement("label", {
|
|
10443
|
+
htmlFor: idRef.current,
|
|
10444
|
+
className: labelOpacityClass
|
|
10445
|
+
}, leftLable) : null, /*#__PURE__*/React.createElement("button", {
|
|
10430
10446
|
id: idRef.current,
|
|
10431
10447
|
type: "button",
|
|
10432
10448
|
role: "switch",
|
|
10433
10449
|
"aria-checked": isOn,
|
|
10434
|
-
"aria-label":
|
|
10450
|
+
"aria-label": accessibleLabel,
|
|
10435
10451
|
"aria-disabled": disabled || undefined,
|
|
10436
10452
|
disabled: disabled,
|
|
10437
10453
|
tabIndex: disabled ? -1 : 0,
|
|
@@ -10441,14 +10457,17 @@ function Switch(props) {
|
|
|
10441
10457
|
style: trackStyle
|
|
10442
10458
|
}, /*#__PURE__*/React.createElement("span", {
|
|
10443
10459
|
className: "sr-only"
|
|
10444
|
-
},
|
|
10460
|
+
}, accessibleLabel), /*#__PURE__*/React.createElement("span", {
|
|
10445
10461
|
"aria-hidden": "true",
|
|
10446
10462
|
className: "".concat(knobBase, " ").concat(knobTransform),
|
|
10447
10463
|
style: knobStyle
|
|
10448
|
-
})),
|
|
10464
|
+
})), rightLabel ? /*#__PURE__*/React.createElement("label", {
|
|
10465
|
+
htmlFor: idRef.current,
|
|
10466
|
+
className: labelOpacityClass
|
|
10467
|
+
}, rightLabel) : null), bottomLabel ? /*#__PURE__*/React.createElement("label", {
|
|
10449
10468
|
htmlFor: idRef.current,
|
|
10450
|
-
className:
|
|
10451
|
-
},
|
|
10469
|
+
className: labelOpacityClass
|
|
10470
|
+
}, bottomLabel) : null, name ? /*#__PURE__*/React.createElement("input", {
|
|
10452
10471
|
type: "checkbox",
|
|
10453
10472
|
name: name,
|
|
10454
10473
|
readOnly: true,
|