@stackone/malachite 2.68.1 → 2.70.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.
@@ -0,0 +1,12 @@
1
+ import { useContext as o, createContext as e } from "react";
2
+ const r = e(null), n = () => {
3
+ const t = o(r);
4
+ if (!t)
5
+ throw new Error("useToast must be used within a ToastProvider");
6
+ return t;
7
+ };
8
+ export {
9
+ r as ToastContext,
10
+ n as useToast
11
+ };
12
+ //# sourceMappingURL=toastContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toastContext.js","sources":["../../src/components/toastContext.ts"],"sourcesContent":["import { createContext, useContext } from 'react';\nimport type { ToastApi } from './toastTypes';\n\nexport const ToastContext = createContext<ToastApi | null>(null);\n\n/** Shows a toast from anywhere under a `ToastProvider`. Throws outside one. */\nexport const useToast = (): ToastApi => {\n const api = useContext(ToastContext);\n if (!api) {\n throw new Error('useToast must be used within a ToastProvider');\n }\n return api;\n};\n"],"names":["ToastContext","createContext","useToast","api","useContext"],"mappings":";AAGO,MAAMA,IAAeC,EAA+B,IAAI,GAGlDC,IAAW,MAAgB;AACpC,QAAMC,IAAMC,EAAWJ,CAAY;AACnC,MAAI,CAACG;AACD,UAAM,IAAI,MAAM,8CAA8C;AAElE,SAAOA;AACX;"}
@@ -0,0 +1,6 @@
1
+ const T = 3e3, _ = 5e3;
2
+ export {
3
+ _ as TOAST_ANNOUNCEMENT_LIFETIME_MS,
4
+ T as TOAST_DEFAULT_DURATION_MS
5
+ };
6
+ //# sourceMappingURL=toastTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toastTypes.js","sources":["../../src/components/toastTypes.ts"],"sourcesContent":["export type ToastVariant = 'success' | 'error';\n\nexport interface ToastOptions {\n message: string;\n /** Defaults to `'success'`. */\n variant?: ToastVariant;\n}\n\nexport interface ToastApi {\n show: (options: ToastOptions) => void;\n}\n\nexport interface QueuedToast {\n id: number;\n message: string;\n variant: ToastVariant;\n}\n\nexport const TOAST_DEFAULT_DURATION_MS = 3000;\nexport const TOAST_MAX_VISIBLE = 3;\nexport const TOAST_ANNOUNCEMENT_LIFETIME_MS = 5000;\n"],"names":["TOAST_DEFAULT_DURATION_MS","TOAST_ANNOUNCEMENT_LIFETIME_MS"],"mappings":"AAkBO,MAAMA,IAA4B,KAE5BC,IAAiC;"}
package/dist/index.d.ts CHANGED
@@ -9,6 +9,29 @@ import { NamedExoticComponent } from 'react';
9
9
  import { ReactNode } from 'react';
10
10
  import { UseFormReturn } from 'react-hook-form';
11
11
 
12
+ export declare type AccessEffect = 'read' | 'write' | 'delete';
13
+
14
+ export declare const AccessPills: default_2.FC<AccessPillsProps>;
15
+
16
+ export declare interface AccessPillsProps {
17
+ value: Record<AccessEffect, AccessPillState>;
18
+ /** Reports the pill pressed. Cascading the change to the other effects is the caller's call. */
19
+ onToggle: (effect: AccessEffect) => void;
20
+ /** An effect with nothing to grant, e.g. a connector with no delete actions. */
21
+ disabled?: Partial<Record<AccessEffect, boolean>>;
22
+ /** Why a pill is disabled, per effect or one sentence for all of them. */
23
+ disabledReason?: string | Partial<Record<AccessEffect, string>>;
24
+ size?: AccessPillsSize;
25
+ 'aria-label'?: string;
26
+ 'aria-labelledby'?: string;
27
+ }
28
+
29
+ /** `dense` draws the pills smaller, for a narrow screen. */
30
+ export declare type AccessPillsSize = 'default' | 'dense';
31
+
32
+ /** `'mixed'` is partly on: some, not all, of the effect's actions are allowed. */
33
+ export declare type AccessPillState = boolean | 'mixed';
34
+
12
35
  export declare const Accordion: default_2.FC<AccordionProps>;
13
36
 
14
37
  declare interface AccordionBaseProps {
@@ -5326,6 +5349,26 @@ export declare const ThumbsDownIcon: React.FC<IconProps_107>;
5326
5349
 
5327
5350
  export declare const ThumbsUpIcon: React.FC<IconProps_108>;
5328
5351
 
5352
+ export declare interface ToastApi {
5353
+ show: (options: ToastOptions) => void;
5354
+ }
5355
+
5356
+ export declare interface ToastOptions {
5357
+ message: string;
5358
+ /** Defaults to `'success'`. */
5359
+ variant?: ToastVariant;
5360
+ }
5361
+
5362
+ export declare const ToastProvider: React.FC<ToastProviderProps>;
5363
+
5364
+ export declare interface ToastProviderProps {
5365
+ children?: React.ReactNode;
5366
+ /** How long each toast stays, in ms. Defaults to 3000. */
5367
+ duration?: number;
5368
+ }
5369
+
5370
+ export declare type ToastVariant = 'success' | 'error';
5371
+
5329
5372
  export declare const Toggle: default_2.ForwardRefExoticComponent<ToggleProps & default_2.RefAttributes<HTMLElement>>;
5330
5373
 
5331
5374
  declare interface ToggleProps {
@@ -5516,6 +5559,9 @@ export declare const useHasOpenOverlay: () => boolean;
5516
5559
 
5517
5560
  export declare const useSidebarCollapsed: () => boolean;
5518
5561
 
5562
+ /** Shows a toast from anywhere under a `ToastProvider`. Throws outside one. */
5563
+ export declare const useToast: () => ToastApi;
5564
+
5519
5565
  export declare const WarningCircleFilled: React.FC<IconProps_114>;
5520
5566
 
5521
5567
  export declare const WarningTriangleIcon: React.FC<IconProps_115>;