@lax-wp/design-system 0.4.5 → 0.4.6

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.
@@ -17,6 +17,10 @@ export interface IButtonProps {
17
17
  options?: ItemType[];
18
18
  tooltip?: string;
19
19
  tooltipPlacement?: 'top' | 'bottom' | 'left' | 'right';
20
+ /** Array of keyboard shortcut keys to display inline in the button (e.g., ['Meta', 'S'] or ['Ctrl', 'Enter']) */
21
+ shortcuts?: string[];
22
+ /** Array of keyboard shortcut keys to display in the tooltip (e.g., ['Meta', 'S']). Falls back to shortcuts if not provided. */
23
+ tooltipShortcuts?: string[];
20
24
  theme?: 'light' | 'dark';
21
25
  }
22
26
  export type IButtonStatus = 'secondary-neutral' | 'primary' | 'secondary' | 'error' | 'warning' | 'success' | 'error-secondary' | 'cancel' | 'no-background' | 'publish' | 'default';
package/dist/index.es.js CHANGED
@@ -19225,27 +19225,29 @@ const Button = ({
19225
19225
  options: ft,
19226
19226
  tooltip: mt,
19227
19227
  tooltipPlacement: yt = "top",
19228
- theme: gt = "light"
19228
+ shortcuts: gt,
19229
+ tooltipShortcuts: _t,
19230
+ theme: xt = "light"
19229
19231
  }) => {
19230
- const _t = useCallback(() => {
19232
+ const Et = useCallback(() => {
19231
19233
  switch (t) {
19232
19234
  case "outline":
19233
- return bt();
19235
+ return wt();
19234
19236
  case "ghost":
19235
- return Ct();
19237
+ return St();
19236
19238
  case "dashed":
19237
- return wt();
19239
+ return jt();
19238
19240
  default:
19239
- return Et();
19241
+ return Ct();
19240
19242
  }
19241
- }, [t, e, a, gt]), xt = useCallback(() => {
19243
+ }, [t, e, a, xt]), bt = useCallback(() => {
19242
19244
  switch (t) {
19243
19245
  case "dashed":
19244
- return St();
19246
+ return It();
19245
19247
  default:
19246
19248
  return {};
19247
19249
  }
19248
- }, [t, e, a, gt]), Et = useCallback(() => {
19250
+ }, [t, e, a, xt]), Ct = useCallback(() => {
19249
19251
  switch (e) {
19250
19252
  case "primary":
19251
19253
  return "bg-primary-600 text-white focus:border-primary-200 hover:bg-primary-700 disabled:opacity-60";
@@ -19268,7 +19270,7 @@ const Button = ({
19268
19270
  default:
19269
19271
  return "bg-white dark:bg-black-800 text-neutral-900 dark:text-white border-white border hover:bg-neutral-100 dark:hover:bg-black-600 disabled:opacity-60";
19270
19272
  }
19271
- }, [e, a, gt]), bt = useCallback(() => {
19273
+ }, [e, a, xt]), wt = useCallback(() => {
19272
19274
  switch (e) {
19273
19275
  case "primary":
19274
19276
  return "text-primary-700 dark:text-primary-600 border-primary-700 border dark:border-primary-600 hover:bg-primary-100 disabled:opacity-60";
@@ -19285,7 +19287,7 @@ const Button = ({
19285
19287
  default:
19286
19288
  return "bg-white dark:bg-black-800 text-neutral-900 dark:text-white border-neutral-300 dark:border-neutral-700 border hover:bg-neutral-100 dark:hover:bg-black-600 disabled:opacity-60";
19287
19289
  }
19288
- }, [e, gt]), Ct = useCallback(() => {
19290
+ }, [e, xt]), St = useCallback(() => {
19289
19291
  switch (e) {
19290
19292
  case "primary":
19291
19293
  return "text-primary-700 dark:text-primary-600 border border-transparent dark:border-transparent hover:text-primary-700 disabled:opacity-60";
@@ -19300,14 +19302,14 @@ const Button = ({
19300
19302
  default:
19301
19303
  return "text-neutral-900 dark:text-white border border-transparent dark:border-transparent hover:text-[#667085] disabled:opacity-60";
19302
19304
  }
19303
- }, [e, gt]), wt = useCallback(() => {
19305
+ }, [e, xt]), jt = useCallback(() => {
19304
19306
  switch (e) {
19305
19307
  case "primary":
19306
19308
  return "bg-primary-50 dark:bg-black-700 text-primary-600 dark:text-primary-600 disabled:text-primary-100 hover:bg-primary-100 dark:hover:bg-black-600";
19307
19309
  default:
19308
19310
  return "bg-primary-50 dark:bg-black-700 text-primary-600 dark:text-primary-600 disabled:text-primary-100 hover:bg-primary-100 dark:hover:bg-black-600";
19309
19311
  }
19310
- }, [e, gt]), St = useCallback(() => {
19312
+ }, [e, xt]), It = useCallback(() => {
19311
19313
  switch (e) {
19312
19314
  case "primary":
19313
19315
  return {
@@ -19319,8 +19321,49 @@ const Button = ({
19319
19321
  default:
19320
19322
  return {};
19321
19323
  }
19322
- }, [e, gt]), jt = () => /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(CgSpinner, { size: 24, className: "inline mr-2 spinner" }) });
19323
- return /* @__PURE__ */ jsxRuntimeExports.jsx(Tooltip, { title: mt, placement: yt, delayShow: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
19324
+ }, [e, xt]), Dt = useCallback(() => {
19325
+ if (!t || t === "filled")
19326
+ switch (e) {
19327
+ case "primary":
19328
+ return "bg-primary-700 text-primary-100";
19329
+ case "secondary":
19330
+ return "bg-primary-100 text-primary-700 dark:bg-black-700 dark:text-primary-400";
19331
+ case "secondary-neutral":
19332
+ return "bg-neutral-100 text-neutral-500 dark:bg-black-700 dark:text-black-300";
19333
+ case "error":
19334
+ return "bg-error-700 text-error-100 dark:bg-error-600 dark:text-error-100";
19335
+ case "error-secondary":
19336
+ return "bg-error-200 text-error-700 dark:bg-black-700 dark:text-error-400";
19337
+ case "warning":
19338
+ return "bg-warning-400 text-white dark:bg-warning-700 dark:text-warning-100";
19339
+ case "success":
19340
+ return "bg-success-700 text-success-100";
19341
+ case "publish":
19342
+ return "bg-teal-900 text-teal-200";
19343
+ case "no-background":
19344
+ return "bg-neutral-100 text-neutral-500 dark:bg-black-700 dark:text-neutral-400";
19345
+ default:
19346
+ return "bg-neutral-100 text-neutral-500 dark:bg-black-700 dark:text-neutral-400";
19347
+ }
19348
+ switch (e) {
19349
+ case "primary":
19350
+ case "secondary":
19351
+ return "bg-primary-100 text-primary-800 dark:bg-primary-950 dark:text-primary-400";
19352
+ case "error":
19353
+ case "error-secondary":
19354
+ return "bg-error-100 text-error-700 dark:bg-error-950 dark:text-error-400";
19355
+ case "warning":
19356
+ return "bg-warning-100 text-warning-700 dark:bg-warning-950 dark:text-warning-400";
19357
+ case "success":
19358
+ return "bg-success-100 text-success-700 dark:bg-success-950 dark:text-success-400";
19359
+ default:
19360
+ return "bg-neutral-100 text-neutral-500 dark:bg-black-700 dark:text-neutral-400";
19361
+ }
19362
+ }, [e, t]), zt = useOS(), Bt = useMemo(() => gt?.length ? gt.map((Ht) => {
19363
+ const Ot = SHORTCUT_KEY_MAP[Ht];
19364
+ return Ot ? zt === "macos" ? Ot.macos : Ot.other : Ht;
19365
+ }) : [], [gt, zt]), kt = () => /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(CgSpinner, { size: 24, className: "inline mr-2 spinner" }) });
19366
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(Tooltip, { title: mt, placement: yt, shortcuts: _t, delayShow: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
19324
19367
  "button",
19325
19368
  {
19326
19369
  className: `
@@ -19340,9 +19383,9 @@ const Button = ({
19340
19383
  gap-1.5
19341
19384
  relative
19342
19385
  max-h-[32px]
19343
- ${_t()}
19386
+ ${Et()}
19344
19387
  `,
19345
- style: { ...xt() },
19388
+ style: { ...bt() },
19346
19389
  disabled: a || o,
19347
19390
  id: $e,
19348
19391
  onClick: ze,
@@ -19350,9 +19393,17 @@ const Button = ({
19350
19393
  title: Le,
19351
19394
  type: dt,
19352
19395
  children: [
19353
- o && jt(),
19396
+ o && kt(),
19354
19397
  s,
19355
- ft?.length ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { onClick: (It) => It.stopPropagation(), children: /* @__PURE__ */ jsxRuntimeExports.jsx(
19398
+ Bt.length > 0 ? /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "inline-flex items-center gap-0.5 ml-1 flex-shrink-0", children: Bt.map((Ht, Ot) => /* @__PURE__ */ jsxRuntimeExports.jsx(
19399
+ "kbd",
19400
+ {
19401
+ className: `inline-flex items-center justify-center min-w-[20px] h-5 px-1 rounded text-[11px] font-medium leading-none ${Dt()}`,
19402
+ children: Ht
19403
+ },
19404
+ Ot
19405
+ )) }) : null,
19406
+ ft?.length ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { onClick: (Ht) => Ht.stopPropagation(), children: /* @__PURE__ */ jsxRuntimeExports.jsx(
19356
19407
  Dropdown,
19357
19408
  {
19358
19409
  menu: {