@flytedan/flytebot-design-system 0.36.0 → 0.38.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
@@ -248,6 +248,9 @@ var VARIANTS = {
248
248
  danger: "fd-btn-danger",
249
249
  link: "fd-btn-link"
250
250
  };
251
+ function isActivationKey(key) {
252
+ return key === "Enter" || key === " ";
253
+ }
251
254
  function Button({
252
255
  children,
253
256
  variant = "primary",
@@ -257,12 +260,16 @@ function Button({
257
260
  arrow = false,
258
261
  loading = false,
259
262
  disabled = false,
263
+ focusableWhenDisabled = false,
260
264
  block = false,
261
265
  as = "button",
262
266
  className = "",
267
+ onClick,
268
+ onKeyDown,
263
269
  ...rest
264
270
  }) {
265
271
  const Tag2 = as;
272
+ const inert = (disabled || loading) && focusableWhenDisabled;
266
273
  const cls = [
267
274
  "fd-btn",
268
275
  VARIANTS[variant] || VARIANTS.primary,
@@ -275,9 +282,16 @@ function Button({
275
282
  Tag2,
276
283
  {
277
284
  className: cls,
278
- disabled: Tag2 === "button" ? disabled || loading : void 0,
279
- "aria-disabled": disabled || loading ? "true" : void 0,
285
+ disabled: Tag2 === "button" ? (disabled || loading) && !focusableWhenDisabled : void 0,
286
+ "aria-disabled": focusableWhenDisabled ? String(disabled || loading) : disabled || loading ? "true" : void 0,
280
287
  "aria-busy": loading ? "true" : void 0,
288
+ onClick: inert ? (e) => {
289
+ e.preventDefault();
290
+ } : onClick,
291
+ onKeyDown: inert ? (e) => {
292
+ if (isActivationKey(e.key)) e.preventDefault();
293
+ onKeyDown?.(e);
294
+ } : onKeyDown,
281
295
  ...rest,
282
296
  children: [
283
297
  icon && !loading ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("i", { className: "ph ph-" + icon, "aria-hidden": "true" }) : null,
@@ -3436,12 +3450,23 @@ function DatePicker({ label, help, error, required = false, disabled = false, ra
3436
3450
 
3437
3451
  // src/components/forms/Textarea.tsx
3438
3452
  var import_jsx_runtime44 = require("react/jsx-runtime");
3439
- function Textarea({ label, help, error, required = false, rows = 4, disabled = false, id, className = "", style, ...rest }) {
3453
+ function Textarea({ label, help, error, required = false, rows = 4, disabled = false, busy = false, readOnly, id, className = "", style, ...rest }) {
3440
3454
  const fieldId = useFieldId(id);
3441
- const box = ["fd-input", "fd-input-textarea", error ? "fd-input-error" : "", disabled ? "fd-input-disabled" : ""].filter(Boolean).join(" ");
3455
+ const box = ["fd-input", "fd-input-textarea", error ? "fd-input-error" : "", disabled || busy ? "fd-input-disabled" : ""].filter(Boolean).join(" ");
3442
3456
  return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { className: ["fd-field", className].filter(Boolean).join(" "), style, children: [
3443
3457
  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 }) }),
3458
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className: box, children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
3459
+ "textarea",
3460
+ {
3461
+ id: fieldId,
3462
+ rows,
3463
+ disabled,
3464
+ readOnly: busy || readOnly,
3465
+ "aria-busy": busy || void 0,
3466
+ "aria-invalid": error ? "true" : void 0,
3467
+ ...rest
3468
+ }
3469
+ ) }),
3445
3470
  error ? /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("span", { className: "fd-field-error", children: [
3446
3471
  /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("i", { className: "ph ph-warning-circle", "aria-hidden": "true" }),
3447
3472
  error
@@ -3733,6 +3758,7 @@ function MultiSelectPanel({
3733
3758
  }, [mode2]);
3734
3759
  const doResolve = () => {
3735
3760
  if (!field.resolve) return;
3761
+ if (pasteLoading) return;
3736
3762
  const tokens = Array.from(new Set(pasteText.split(/[\n,]/).map((t) => t.trim()).filter(Boolean)));
3737
3763
  if (!tokens.length) return;
3738
3764
  setPasteLoading(true);
@@ -3815,7 +3841,7 @@ function MultiSelectPanel({
3815
3841
  rows: 4,
3816
3842
  placeholder: field.pastePlaceholder || field.placeholder || "Paste names, one per line or comma-separated",
3817
3843
  value: pasteText,
3818
- disabled: pasteLoading,
3844
+ busy: pasteLoading,
3819
3845
  onChange: (e) => setPasteText(e.target.value),
3820
3846
  onKeyDown: (e) => {
3821
3847
  if (e.key === "Enter" && (e.metaKey || e.ctrlKey)) {
@@ -3877,19 +3903,9 @@ function MultiSelectPanel({
3877
3903
  {
3878
3904
  size: "sm",
3879
3905
  variant: "secondary",
3880
- "aria-disabled": resolveDisabled,
3881
- onClick: (e) => {
3882
- if (resolveDisabled) {
3883
- e.preventDefault();
3884
- return;
3885
- }
3886
- doResolve();
3887
- },
3888
- onKeyDown: (e) => {
3889
- if (resolveDisabled && (e.key === "Enter" || e.key === " ")) {
3890
- e.preventDefault();
3891
- }
3892
- },
3906
+ disabled: resolveDisabled,
3907
+ focusableWhenDisabled: true,
3908
+ onClick: doResolve,
3893
3909
  children: pasteLoading ? "Resolving\u2026" : "Resolve"
3894
3910
  }
3895
3911
  ) : void 0;
@@ -4036,7 +4052,7 @@ function RangePanel({
4036
4052
  offset: 6,
4037
4053
  width: PANEL_WIDTH.range,
4038
4054
  label: field.label,
4039
- footer: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(Button, { size: "sm", variant: "secondary", onClick: onClose, disabled: doneDisabled, children: "Done" }),
4055
+ footer: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(Button, { size: "sm", variant: "secondary", disabled: doneDisabled, focusableWhenDisabled: true, onClick: onClose, children: "Done" }),
4040
4056
  children: /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("span", { className: "fd-stack fd-gap-sm", children: [
4041
4057
  /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("span", { ref: minWrapRef, children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
4042
4058
  NumberInput,
@@ -4151,7 +4167,6 @@ function DatePanel({
4151
4167
  };
4152
4168
  const doneDisabled = kind === "withinDays" && !validity.allValid();
4153
4169
  const confirm = () => {
4154
- if (doneDisabled) return;
4155
4170
  if (kind === "withinDays") {
4156
4171
  const shown = shownWithinDays();
4157
4172
  if (shown) onCommit(shown);
@@ -4168,7 +4183,7 @@ function DatePanel({
4168
4183
  offset: 6,
4169
4184
  width: PANEL_WIDTH.date,
4170
4185
  label: field.label,
4171
- footer: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(Button, { size: "sm", variant: "secondary", onClick: confirm, disabled: doneDisabled, children: "Done" }),
4186
+ footer: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(Button, { size: "sm", variant: "secondary", disabled: doneDisabled, focusableWhenDisabled: true, onClick: confirm, children: "Done" }),
4172
4187
  children: /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("span", { className: "fd-stack fd-gap-sm", children: [
4173
4188
  /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
4174
4189
  SegmentedControl,