@flytedan/flytebot-design-system 0.37.0 → 0.39.0

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.cjs CHANGED
@@ -257,12 +257,16 @@ function Button({
257
257
  arrow = false,
258
258
  loading = false,
259
259
  disabled = false,
260
+ focusableWhenDisabled = false,
260
261
  block = false,
261
262
  as = "button",
262
263
  className = "",
264
+ onClick,
265
+ onKeyDown,
263
266
  ...rest
264
267
  }) {
265
268
  const Tag2 = as;
269
+ const inert = (disabled || loading) && focusableWhenDisabled;
266
270
  const cls = [
267
271
  "fd-btn",
268
272
  VARIANTS[variant] || VARIANTS.primary,
@@ -275,9 +279,14 @@ function Button({
275
279
  Tag2,
276
280
  {
277
281
  className: cls,
278
- disabled: Tag2 === "button" ? disabled || loading : void 0,
282
+ disabled: Tag2 === "button" ? (disabled || loading) && !focusableWhenDisabled : void 0,
279
283
  "aria-disabled": disabled || loading ? "true" : void 0,
280
284
  "aria-busy": loading ? "true" : void 0,
285
+ onClick: inert ? (e) => {
286
+ e.preventDefault();
287
+ e.stopPropagation();
288
+ } : onClick,
289
+ onKeyDown,
281
290
  ...rest,
282
291
  children: [
283
292
  icon && !loading ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("i", { className: "ph ph-" + icon, "aria-hidden": "true" }) : null,
@@ -3436,12 +3445,23 @@ function DatePicker({ label, help, error, required = false, disabled = false, ra
3436
3445
 
3437
3446
  // src/components/forms/Textarea.tsx
3438
3447
  var import_jsx_runtime44 = require("react/jsx-runtime");
3439
- function Textarea({ label, help, error, required = false, rows = 4, disabled = false, id, className = "", style, ...rest }) {
3448
+ function Textarea({ label, help, error, required = false, rows = 4, disabled = false, busy = false, readOnly, id, className = "", style, ...rest }) {
3440
3449
  const fieldId = useFieldId(id);
3441
- const box = ["fd-input", "fd-input-textarea", error ? "fd-input-error" : "", disabled ? "fd-input-disabled" : ""].filter(Boolean).join(" ");
3450
+ const box = ["fd-input", "fd-input-textarea", error ? "fd-input-error" : "", disabled || busy ? "fd-input-disabled" : ""].filter(Boolean).join(" ");
3442
3451
  return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { className: ["fd-field", className].filter(Boolean).join(" "), style, children: [
3443
3452
  label ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(FieldLabel, { htmlFor: fieldId, required, children: label }) : null,
3444
- /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className: box, children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("textarea", { id: fieldId, rows, disabled, "aria-invalid": error ? "true" : void 0, ...rest }) }),
3453
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className: box, children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
3454
+ "textarea",
3455
+ {
3456
+ id: fieldId,
3457
+ rows,
3458
+ disabled,
3459
+ readOnly: busy || readOnly,
3460
+ "aria-busy": busy || void 0,
3461
+ "aria-invalid": error ? "true" : void 0,
3462
+ ...rest
3463
+ }
3464
+ ) }),
3445
3465
  error ? /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("span", { className: "fd-field-error", children: [
3446
3466
  /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("i", { className: "ph ph-warning-circle", "aria-hidden": "true" }),
3447
3467
  error
@@ -3816,8 +3836,7 @@ function MultiSelectPanel({
3816
3836
  rows: 4,
3817
3837
  placeholder: field.pastePlaceholder || field.placeholder || "Paste names, one per line or comma-separated",
3818
3838
  value: pasteText,
3819
- readOnly: pasteLoading,
3820
- "aria-busy": pasteLoading || void 0,
3839
+ busy: pasteLoading,
3821
3840
  onChange: (e) => setPasteText(e.target.value),
3822
3841
  onKeyDown: (e) => {
3823
3842
  if (e.key === "Enter" && (e.metaKey || e.ctrlKey)) {
@@ -3879,19 +3898,9 @@ function MultiSelectPanel({
3879
3898
  {
3880
3899
  size: "sm",
3881
3900
  variant: "secondary",
3882
- "aria-disabled": resolveDisabled,
3883
- onClick: (e) => {
3884
- if (resolveDisabled) {
3885
- e.preventDefault();
3886
- return;
3887
- }
3888
- doResolve();
3889
- },
3890
- onKeyDown: (e) => {
3891
- if (resolveDisabled && (e.key === "Enter" || e.key === " ")) {
3892
- e.preventDefault();
3893
- }
3894
- },
3901
+ disabled: resolveDisabled,
3902
+ focusableWhenDisabled: true,
3903
+ onClick: doResolve,
3895
3904
  children: pasteLoading ? "Resolving\u2026" : "Resolve"
3896
3905
  }
3897
3906
  ) : void 0;
@@ -4028,16 +4037,6 @@ function RangePanel({
4028
4037
  setDraft(next);
4029
4038
  publish();
4030
4039
  };
4031
- const doneClick = (e) => {
4032
- if (doneDisabled) {
4033
- e.preventDefault();
4034
- return;
4035
- }
4036
- onClose();
4037
- };
4038
- const doneKeyDown = (e) => {
4039
- if (doneDisabled && (e.key === "Enter" || e.key === " ")) e.preventDefault();
4040
- };
4041
4040
  return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
4042
4041
  Popover,
4043
4042
  {
@@ -4048,7 +4047,7 @@ function RangePanel({
4048
4047
  offset: 6,
4049
4048
  width: PANEL_WIDTH.range,
4050
4049
  label: field.label,
4051
- footer: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(Button, { size: "sm", variant: "secondary", "aria-disabled": doneDisabled, onClick: doneClick, onKeyDown: doneKeyDown, children: "Done" }),
4050
+ footer: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(Button, { size: "sm", variant: "secondary", disabled: doneDisabled, focusableWhenDisabled: true, onClick: onClose, children: "Done" }),
4052
4051
  children: /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("span", { className: "fd-stack fd-gap-sm", children: [
4053
4052
  /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("span", { ref: minWrapRef, children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
4054
4053
  NumberInput,
@@ -4163,16 +4162,12 @@ function DatePanel({
4163
4162
  };
4164
4163
  const doneDisabled = kind === "withinDays" && !validity.allValid();
4165
4164
  const confirm = () => {
4166
- if (doneDisabled) return;
4167
4165
  if (kind === "withinDays") {
4168
4166
  const shown = shownWithinDays();
4169
4167
  if (shown) onCommit(shown);
4170
4168
  }
4171
4169
  onClose();
4172
4170
  };
4173
- const doneKeyDown = (e) => {
4174
- if (doneDisabled && (e.key === "Enter" || e.key === " ")) e.preventDefault();
4175
- };
4176
4171
  return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
4177
4172
  Popover,
4178
4173
  {
@@ -4183,7 +4178,7 @@ function DatePanel({
4183
4178
  offset: 6,
4184
4179
  width: PANEL_WIDTH.date,
4185
4180
  label: field.label,
4186
- footer: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(Button, { size: "sm", variant: "secondary", "aria-disabled": doneDisabled, onClick: confirm, onKeyDown: doneKeyDown, children: "Done" }),
4181
+ footer: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(Button, { size: "sm", variant: "secondary", disabled: doneDisabled, focusableWhenDisabled: true, onClick: confirm, children: "Done" }),
4187
4182
  children: /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("span", { className: "fd-stack fd-gap-sm", children: [
4188
4183
  /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
4189
4184
  SegmentedControl,