@octaviaflow/core 3.1.0-beta.57 → 3.1.0-beta.59
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/components/Button/Button.d.ts.map +1 -1
- package/dist/components/Select/Select.d.ts.map +1 -1
- package/dist/components/Switch/Switch.d.ts.map +1 -1
- package/dist/index.cjs +1324 -1298
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +33 -7
- package/dist/index.js.map +1 -1
- package/dist/utils/a11y.d.ts +23 -1
- package/dist/utils/a11y.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2222,6 +2222,27 @@ function $6b915bde6cd300dd$var$toggleKey(set, key) {
|
|
|
2222
2222
|
}
|
|
2223
2223
|
|
|
2224
2224
|
// src/utils/a11y.ts
|
|
2225
|
+
import { isValidElement as isValidElement2 } from "react";
|
|
2226
|
+
function hasRenderableText(node) {
|
|
2227
|
+
if (node === null || node === void 0 || typeof node === "boolean") return false;
|
|
2228
|
+
if (typeof node === "string") return node.trim().length > 0;
|
|
2229
|
+
if (typeof node === "number") return true;
|
|
2230
|
+
if (Array.isArray(node)) return node.some(hasRenderableText);
|
|
2231
|
+
if (isValidElement2(node)) {
|
|
2232
|
+
return hasRenderableText(node.props.children);
|
|
2233
|
+
}
|
|
2234
|
+
return false;
|
|
2235
|
+
}
|
|
2236
|
+
function getRenderableText(node) {
|
|
2237
|
+
if (node === null || node === void 0 || typeof node === "boolean") return "";
|
|
2238
|
+
if (typeof node === "string") return node;
|
|
2239
|
+
if (typeof node === "number") return String(node);
|
|
2240
|
+
if (Array.isArray(node)) return node.map(getRenderableText).join("");
|
|
2241
|
+
if (isValidElement2(node)) {
|
|
2242
|
+
return getRenderableText(node.props.children);
|
|
2243
|
+
}
|
|
2244
|
+
return "";
|
|
2245
|
+
}
|
|
2225
2246
|
function resolveAccessibleName(input) {
|
|
2226
2247
|
if (input.ariaLabelledby) {
|
|
2227
2248
|
return { "aria-labelledby": input.ariaLabelledby };
|
|
@@ -4291,7 +4312,7 @@ var Button = forwardRef13(function Button2({
|
|
|
4291
4312
|
const hasAction = Boolean(props.onClick) || type === "submit" || type === "reset";
|
|
4292
4313
|
const resolvedCursor = cursor ?? (disabled ? "not-allowed" : loading ? "progress" : hasAction ? "pointer" : "default");
|
|
4293
4314
|
const resolvedType = type ?? "button";
|
|
4294
|
-
const hasVisibleText =
|
|
4315
|
+
const hasVisibleText = hasRenderableText(children);
|
|
4295
4316
|
const needsAriaName = !hasVisibleText && !asChild;
|
|
4296
4317
|
const ariaNameProps = needsAriaName ? resolveAccessibleName({
|
|
4297
4318
|
ariaLabel: props["aria-label"],
|
|
@@ -4419,7 +4440,7 @@ import { CheckmarkIcon, ChevronDownIcon as ChevronDownIcon2 } from "@octaviaflow
|
|
|
4419
4440
|
import { AnimatePresence as AnimatePresence4, motion as motion7 } from "framer-motion";
|
|
4420
4441
|
import {
|
|
4421
4442
|
cloneElement as cloneElement2,
|
|
4422
|
-
isValidElement as
|
|
4443
|
+
isValidElement as isValidElement3,
|
|
4423
4444
|
useCallback as useCallback6,
|
|
4424
4445
|
useEffect as useEffect2,
|
|
4425
4446
|
useId as useId8,
|
|
@@ -4601,7 +4622,7 @@ function Tooltip({
|
|
|
4601
4622
|
state,
|
|
4602
4623
|
triggerRef
|
|
4603
4624
|
);
|
|
4604
|
-
if (!
|
|
4625
|
+
if (!isValidElement3(children)) {
|
|
4605
4626
|
return /* @__PURE__ */ jsx15(Fragment7, { children });
|
|
4606
4627
|
}
|
|
4607
4628
|
const childProps = children.props;
|
|
@@ -4717,12 +4738,13 @@ function Option({
|
|
|
4717
4738
|
}
|
|
4718
4739
|
);
|
|
4719
4740
|
}
|
|
4741
|
+
var DEFAULT_SELECT_PLACEHOLDER = "Select an option...";
|
|
4720
4742
|
var Select = forwardRef14(function Select2({
|
|
4721
4743
|
options,
|
|
4722
4744
|
value,
|
|
4723
4745
|
defaultValue,
|
|
4724
4746
|
onChange,
|
|
4725
|
-
placeholder =
|
|
4747
|
+
placeholder = DEFAULT_SELECT_PLACEHOLDER,
|
|
4726
4748
|
searchable = false,
|
|
4727
4749
|
label,
|
|
4728
4750
|
error = false,
|
|
@@ -4772,9 +4794,12 @@ var Select = forwardRef14(function Select2({
|
|
|
4772
4794
|
label,
|
|
4773
4795
|
ariaLabel,
|
|
4774
4796
|
ariaLabelledby: ariaLabelledBy,
|
|
4775
|
-
componentName: "Select"
|
|
4797
|
+
componentName: "Select",
|
|
4798
|
+
fallbacks: [
|
|
4799
|
+
placeholder && placeholder !== DEFAULT_SELECT_PLACEHOLDER ? placeholder : void 0
|
|
4800
|
+
]
|
|
4776
4801
|
}),
|
|
4777
|
-
[label, ariaLabel, ariaLabelledBy]
|
|
4802
|
+
[label, ariaLabel, ariaLabelledBy, placeholder]
|
|
4778
4803
|
);
|
|
4779
4804
|
const ariaProps = useMemo4(() => {
|
|
4780
4805
|
const items = filteredOptions.map((o) => ({
|
|
@@ -28952,8 +28977,9 @@ var Switch = forwardRef106(function Switch2({
|
|
|
28952
28977
|
defaultSelected: defaultChecked,
|
|
28953
28978
|
onChange
|
|
28954
28979
|
});
|
|
28980
|
+
const labelText = getRenderableText(label).trim();
|
|
28955
28981
|
const ariaNameProps = resolveAccessibleName({
|
|
28956
|
-
label:
|
|
28982
|
+
label: labelText || void 0,
|
|
28957
28983
|
ariaLabel: props["aria-label"],
|
|
28958
28984
|
ariaLabelledby: props["aria-labelledby"],
|
|
28959
28985
|
componentName: "Switch"
|