@dreamtree-org/twreact-ui 1.0.58 → 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/README.md +3 -3
- 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/README.md
CHANGED
|
@@ -16,15 +16,15 @@ A comprehensive React + Tailwind CSS components library for building modern web
|
|
|
16
16
|
## Installation
|
|
17
17
|
|
|
18
18
|
```bash
|
|
19
|
-
npm install @dreamtree/twreact-ui
|
|
19
|
+
npm install @dreamtree-org/twreact-ui
|
|
20
20
|
# or
|
|
21
|
-
yarn add @dreamtree/twreact-ui
|
|
21
|
+
yarn add @dreamtree-org/twreact-ui
|
|
22
22
|
```
|
|
23
23
|
|
|
24
24
|
## Quick Start
|
|
25
25
|
|
|
26
26
|
```jsx
|
|
27
|
-
import { Button, Input, Card } from '@dreamtree/twreact-ui';
|
|
27
|
+
import { Button, Input, Card } from '@dreamtree-org/twreact-ui';
|
|
28
28
|
|
|
29
29
|
function App() {
|
|
30
30
|
return (
|
package/dist/index.esm.js
CHANGED
|
@@ -10316,6 +10316,9 @@ var DatePicker = /*#__PURE__*/React__default.forwardRef(function (_ref, forwarde
|
|
|
10316
10316
|
* - Sizes: 'sm' | 'md' | 'lg'
|
|
10317
10317
|
* - Accessible (role="switch", keyboard toggle)
|
|
10318
10318
|
* - Hidden input for form serialization (name prop)
|
|
10319
|
+
*
|
|
10320
|
+
* New props:
|
|
10321
|
+
* - topLabel, bottomLabel, rightLabel, leftLable (renders label in those positions)
|
|
10319
10322
|
*/
|
|
10320
10323
|
|
|
10321
10324
|
var SIZE_MAP$2 = {
|
|
@@ -10336,7 +10339,6 @@ var SIZE_MAP$2 = {
|
|
|
10336
10339
|
}
|
|
10337
10340
|
};
|
|
10338
10341
|
function Switch(props) {
|
|
10339
|
-
var _ref;
|
|
10340
10342
|
var id = props.id,
|
|
10341
10343
|
name = props.name,
|
|
10342
10344
|
checked = props.checked,
|
|
@@ -10351,9 +10353,10 @@ function Switch(props) {
|
|
|
10351
10353
|
thumbColor = props.thumbColor,
|
|
10352
10354
|
_props$className = props.className,
|
|
10353
10355
|
className = _props$className === void 0 ? "" : _props$className,
|
|
10354
|
-
|
|
10355
|
-
|
|
10356
|
-
|
|
10356
|
+
topLabel = props.topLabel,
|
|
10357
|
+
bottomLabel = props.bottomLabel,
|
|
10358
|
+
rightLabel = props.rightLabel,
|
|
10359
|
+
leftLable = props.leftLable,
|
|
10357
10360
|
ariaLabel = props.ariaLabel;
|
|
10358
10361
|
var isControlled = typeof checked === "boolean";
|
|
10359
10362
|
var _useState = useState(defaultChecked),
|
|
@@ -10401,17 +10404,30 @@ function Switch(props) {
|
|
|
10401
10404
|
|
|
10402
10405
|
// fallback when ON and no bgColor provided (keeps the switch visible)
|
|
10403
10406
|
var fallbackOnClass = isOn && !bgColor ? "bg-sky-500" : "";
|
|
10407
|
+
|
|
10408
|
+
// Accessible label fallback: prefer ariaLabel, otherwise first provided visible label, otherwise "Toggle"
|
|
10409
|
+
var accessibleLabel = ariaLabel || rightLabel || leftLable || topLabel || bottomLabel || "Toggle";
|
|
10410
|
+
|
|
10411
|
+
// Container layout: column if top or bottom labels exist, otherwise row
|
|
10412
|
+
var containerIsColumn = Boolean(topLabel || bottomLabel);
|
|
10413
|
+
var containerClass = [containerIsColumn ? "flex flex-col items-center" : "inline-flex items-center", "gap-2", className].filter(Boolean).join(" ");
|
|
10414
|
+
var labelOpacityClass = disabled ? "opacity-50" : "";
|
|
10404
10415
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
10405
|
-
className:
|
|
10406
|
-
},
|
|
10416
|
+
className: containerClass
|
|
10417
|
+
}, topLabel ? /*#__PURE__*/React__default.createElement("label", {
|
|
10407
10418
|
htmlFor: idRef.current,
|
|
10408
|
-
className:
|
|
10409
|
-
},
|
|
10419
|
+
className: labelOpacityClass
|
|
10420
|
+
}, topLabel) : null, /*#__PURE__*/React__default.createElement("div", {
|
|
10421
|
+
className: "inline-flex items-center gap-2"
|
|
10422
|
+
}, leftLable ? /*#__PURE__*/React__default.createElement("label", {
|
|
10423
|
+
htmlFor: idRef.current,
|
|
10424
|
+
className: labelOpacityClass
|
|
10425
|
+
}, leftLable) : null, /*#__PURE__*/React__default.createElement("button", {
|
|
10410
10426
|
id: idRef.current,
|
|
10411
10427
|
type: "button",
|
|
10412
10428
|
role: "switch",
|
|
10413
10429
|
"aria-checked": isOn,
|
|
10414
|
-
"aria-label":
|
|
10430
|
+
"aria-label": accessibleLabel,
|
|
10415
10431
|
"aria-disabled": disabled || undefined,
|
|
10416
10432
|
disabled: disabled,
|
|
10417
10433
|
tabIndex: disabled ? -1 : 0,
|
|
@@ -10421,14 +10437,17 @@ function Switch(props) {
|
|
|
10421
10437
|
style: trackStyle
|
|
10422
10438
|
}, /*#__PURE__*/React__default.createElement("span", {
|
|
10423
10439
|
className: "sr-only"
|
|
10424
|
-
},
|
|
10440
|
+
}, accessibleLabel), /*#__PURE__*/React__default.createElement("span", {
|
|
10425
10441
|
"aria-hidden": "true",
|
|
10426
10442
|
className: "".concat(knobBase, " ").concat(knobTransform),
|
|
10427
10443
|
style: knobStyle
|
|
10428
|
-
})),
|
|
10444
|
+
})), rightLabel ? /*#__PURE__*/React__default.createElement("label", {
|
|
10445
|
+
htmlFor: idRef.current,
|
|
10446
|
+
className: labelOpacityClass
|
|
10447
|
+
}, rightLabel) : null), bottomLabel ? /*#__PURE__*/React__default.createElement("label", {
|
|
10429
10448
|
htmlFor: idRef.current,
|
|
10430
|
-
className:
|
|
10431
|
-
},
|
|
10449
|
+
className: labelOpacityClass
|
|
10450
|
+
}, bottomLabel) : null, name ? /*#__PURE__*/React__default.createElement("input", {
|
|
10432
10451
|
type: "checkbox",
|
|
10433
10452
|
name: name,
|
|
10434
10453
|
readOnly: true,
|