@adam-milo/ui 1.0.134 → 1.0.135
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/index45.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("react"),o=require("@adam-milo/icons"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("react"),o=require("@adam-milo/icons"),a=require("./index67.cjs"),r=require("./index102.cjs"),n=["none","desc","asc"],s={none:"Not sorted",asc:"Sorted A to Z",desc:"Sorted Z to A"},i=t.forwardRef(({direction:i,defaultDirection:c="none",onDirectionChange:d,cycle:l=n,onClick:u,disabled:b,className:m,"aria-label":y,"data-testid":f,"data-cy":x,...S},j)=>{const p=void 0!==i,[g,h]=t.useState(c),q=p?i:g,v=f||`sort-button-${q}`,C=x||`sort-button-${q}`,N=t.useCallback(e=>{if(u?.(e),e.defaultPrevented)return;const t=l.length>0?l:n,o=t.indexOf(q),a=t[(o+1)%t.length];p||h(a),a!==q&&d?.(a)},[l,q,p,u,d]),k="asc"===q?"[transform:scaleY(-1)]":void 0;return e.jsx("button",{ref:j,type:"button",disabled:b,className:a.cn(r.baseStyles,r.directionStyles[q],m),onClick:N,"aria-label":y||s[q],"aria-pressed":"none"!==q,"data-direction":q,"data-testid":v,"data-cy":C,...S,children:e.jsx(o.Icon,{name:"CustomDownArrowIcon",size:"xs",color:"inherit",decorative:!0,className:k,"data-cy":`${C}-icon`})})});i.displayName="SortButton",exports.SortButton=i;
|
package/dist/index45.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsx as t}from"react/jsx-runtime";import{forwardRef as e,useState as o,useCallback as a}from"react";import{Icon as r}from"@adam-milo/icons";import{cn as n}from"./index67.js";import{directionStyles as i,baseStyles as
|
|
2
|
-
return t("button",{ref:v,type:"button",disabled:p,className:n(
|
|
1
|
+
import{jsx as t}from"react/jsx-runtime";import{forwardRef as e,useState as o,useCallback as a}from"react";import{Icon as r}from"@adam-milo/icons";import{cn as n}from"./index67.js";import{directionStyles as i,baseStyles as s}from"./index102.js";const d=["none","desc","asc"],c={none:"Not sorted",asc:"Sorted A to Z",desc:"Sorted Z to A"},l=e(({direction:e,defaultDirection:l="none",onDirectionChange:m,cycle:f=d,onClick:u,disabled:p,className:b,"aria-label":x,"data-testid":y,"data-cy":h,...N},v)=>{const C=void 0!==e,[g,j]=o(l),A=C?e:g,D=y||`sort-button-${A}`,S=h||`sort-button-${A}`,$=a(t=>{if(u?.(t),t.defaultPrevented)return;const e=f.length>0?f:d,o=e.indexOf(A),a=e[(o+1)%e.length];C||j(a),a!==A&&m?.(a)},[f,A,C,u,m]),k="asc"===A?"[transform:scaleY(-1)]":void 0;/* @__PURE__ */
|
|
2
|
+
return t("button",{ref:v,type:"button",disabled:p,className:n(s,i[A],b),onClick:$,"aria-label":x||c[A],"aria-pressed":"none"!==A,"data-direction":A,"data-testid":D,"data-cy":S,...N,children:/* @__PURE__ */t(r,{name:"CustomDownArrowIcon",size:"xs",color:"inherit",decorative:!0,className:k,"data-cy":`${S}-icon`})})});l.displayName="SortButton";export{l as SortButton};
|
|
@@ -78,7 +78,7 @@ export interface DataTableProps extends TableHTMLAttributes<HTMLTableElement> {
|
|
|
78
78
|
sortDirection?: SortDirection;
|
|
79
79
|
/**
|
|
80
80
|
* Called when a sortable column's sort control is toggled. Receives the
|
|
81
|
-
* column key and its next direction (`none` → `
|
|
81
|
+
* column key and its next direction (`none` → `desc` → `asc` → `none`). The
|
|
82
82
|
* table does not sort data itself — reorder `data` in response.
|
|
83
83
|
*/
|
|
84
84
|
onSortChange?: (key: string, direction: SortDirection) => void;
|
|
@@ -2,9 +2,9 @@ import { ButtonHTMLAttributes } from 'react';
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Logical state of a sort control.
|
|
5
|
-
* - `none`: no sort applied (idle / "disabled" in the design)
|
|
6
|
-
* - `
|
|
7
|
-
* - `
|
|
5
|
+
* - `none`: no sort applied (idle / "disabled" in the design) — down arrow, muted
|
|
6
|
+
* - `desc`: Z → A (descending) — down arrow
|
|
7
|
+
* - `asc`: A → Z (ascending) — up arrow (flipped)
|
|
8
8
|
*/
|
|
9
9
|
export type SortDirection = 'none' | 'asc' | 'desc';
|
|
10
10
|
export interface SortButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'onChange'> {
|
|
@@ -16,7 +16,7 @@ export interface SortButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonEle
|
|
|
16
16
|
onDirectionChange?: (direction: SortDirection) => void;
|
|
17
17
|
/**
|
|
18
18
|
* Order to cycle through on each click.
|
|
19
|
-
* Defaults to `['none', '
|
|
19
|
+
* Defaults to `['none', 'desc', 'asc']` (idle → Z-A ↓ → A-Z ↑ → idle).
|
|
20
20
|
*/
|
|
21
21
|
cycle?: readonly SortDirection[];
|
|
22
22
|
/** Accessible label describing what's being sorted (e.g. "Sort by name"). */
|