@apliteni/apliteni-ui 0.160.0 → 0.161.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.
@@ -814,6 +814,38 @@ to fit its label at `--text-xs`. Other sizes keep their 16px glyph at stroke-wid
814
814
  dots fit inside the smaller target. The size does not change the variant's colour or its
815
815
  interaction states.
816
816
 
817
+ ### Hold to confirm
818
+
819
+ Use React `<Button hold>` for one primary or danger action that the user cannot undo, such as
820
+ a send to many people or the deletion of a workspace. Do not use it for an action that the user
821
+ can undo, for a routine save or for a form submit. Use a plain button for those. A link takes no
822
+ `hold`.
823
+
824
+ ```tsx
825
+ <Button hold variant="danger" onConfirm={deleteWorkspace}>Delete workspace</Button>
826
+ ```
827
+
828
+ Put the action in `onConfirm`. The button calls only `onConfirm`. A click does not call
829
+ `onClick`, and the button never submits its form.
830
+
831
+ **What the user sees.** The user presses the button and holds it for 1000 ms. A fill grows from
832
+ the start edge. A primary button fills with `--accent`. A danger button stays quiet at rest and
833
+ shows `--pink` only while it is hovered, focused or held. If the user releases before the end,
834
+ the fill goes back to empty and nothing happens. A press shorter than 300 ms shows "Hold to
835
+ confirm" above the button. A slide off the button does not stop the hold. Under reduced motion
836
+ the fill moves in four 250 ms steps, and the hold still takes 1000 ms. A busy or disabled button
837
+ does not hold.
838
+
839
+ **Keyboard and screen reader.** Enter or Space held for 1000 ms confirms, the same as a pointer.
840
+ Two presses within 3000 ms also confirm. This is the path for a screen reader user. The button
841
+ gives the description "Hold to confirm, or press twice." after any `aria-describedby` of your
842
+ own.
843
+
844
+ **Room on the screen.** The hint shows over the content above the button, so the button does
845
+ not move. Leave room for one line above the button. An ancestor with `overflow: hidden` clips
846
+ the hint. If a result replaces the button after the confirm, give the result the focus. Give
847
+ its row a minimum height of `--btn-height-md`, so the row keeps the height of an md button.
848
+
817
849
  ### Code highlighting
818
850
 
819
851
  `hlCode(raw, lang)` returns highlighted HTML. `codeTokens(raw, lang)` returns the same tokens as
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apliteni/apliteni-ui",
3
- "version": "0.160.0",
3
+ "version": "0.161.0",
4
4
  "workspaces": [
5
5
  "react"
6
6
  ],
@@ -47,12 +47,19 @@ type ButtonOptions = {
47
47
  completionMessage?: string;
48
48
  children?: ReactNode;
49
49
  };
50
- type NativeButtonProps = ButtonOptions & ButtonHTMLAttributes<HTMLButtonElement> & {
50
+ type HoldOptions = {
51
+ /** Hold to confirm: a 1 s press, or two presses within 3 s, calls onConfirm. A click never calls onClick. */
52
+ hold?: boolean;
53
+ onConfirm?: () => void;
54
+ };
55
+ type NativeButtonProps = ButtonOptions & HoldOptions & ButtonHTMLAttributes<HTMLButtonElement> & {
51
56
  href?: never;
52
57
  };
53
58
  type ButtonLinkProps = ButtonOptions & AnchorHTMLAttributes<HTMLAnchorElement> & {
54
59
  href: string;
55
60
  disabled?: boolean;
61
+ hold?: never;
62
+ onConfirm?: never;
56
63
  };
57
64
  type ButtonProps = NativeButtonProps | ButtonLinkProps;
58
65
  type ButtonElement = HTMLButtonElement | HTMLAnchorElement;