@fairfox/polly 0.29.4 → 0.30.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.
@@ -8,7 +8,7 @@
8
8
  * callback), and the body scroll locks.
9
9
  */
10
10
  import type { ReadonlySignal } from "@preact/signals";
11
- import { type ComponentChildren } from "preact";
11
+ import { type ComponentChildren, type JSX } from "preact";
12
12
  type RootProps = {
13
13
  when: ReadonlySignal<boolean> | boolean;
14
14
  onClose?: () => void;
@@ -17,28 +17,31 @@ type RootProps = {
17
17
  "aria-label"?: string;
18
18
  };
19
19
  declare function Root({ when, onClose, children, "aria-label": ariaLabel }: RootProps): import("preact").VNode<any> | null;
20
- declare function Backdrop(): import("preact").JSX.Element;
21
- declare function Content({ children }: {
20
+ declare function Backdrop(): JSX.Element;
21
+ type ContentProps = {
22
22
  children: ComponentChildren;
23
- }): import("preact").JSX.Element;
23
+ className?: string;
24
+ style?: JSX.CSSProperties;
25
+ };
26
+ declare function Content({ children, className, style }: ContentProps): JSX.Element;
24
27
  declare function Header({ children }: {
25
28
  children: ComponentChildren;
26
- }): import("preact").JSX.Element;
29
+ }): JSX.Element;
27
30
  declare function Title({ children }: {
28
31
  children: ComponentChildren;
29
- }): import("preact").JSX.Element;
32
+ }): JSX.Element;
30
33
  declare function Body({ children }: {
31
34
  children: ComponentChildren;
32
- }): import("preact").JSX.Element;
35
+ }): JSX.Element;
33
36
  declare function Footer({ children }: {
34
37
  children: ComponentChildren;
35
- }): import("preact").JSX.Element;
38
+ }): JSX.Element;
36
39
  type CloseProps = {
37
40
  children: ComponentChildren;
38
41
  /** Fire a registered data-action instead of calling the onClose callback. */
39
42
  action?: string;
40
43
  };
41
- declare function Close({ children, action }: CloseProps): import("preact").JSX.Element;
44
+ declare function Close({ children, action }: CloseProps): JSX.Element;
42
45
  export declare const Modal: {
43
46
  Root: typeof Root;
44
47
  Backdrop: typeof Backdrop;
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Surface — the one primitive that owns visual-surface concerns.
3
+ *
4
+ * Where Layout governs spatial concerns (grid, flex, gap, alignment),
5
+ * Surface governs the chrome that sits on top of layout: padding,
6
+ * background, border, radius, shadow, and the narrow positioning idioms
7
+ * (sticky strips, fixed floating panes) that consumers reach for inline
8
+ * styles to express. Every prop maps to a `--polly-*` token through a
9
+ * local `--s-*` custom property, so consumers can retheme an individual
10
+ * Surface by overriding the polly token in `style` without touching the
11
+ * primitive's CSS.
12
+ */
13
+ import { type ComponentChildren, type JSX } from "preact";
14
+ export type SurfaceVariant = "plain" | "raised" | "sunken" | "bubble" | "chip" | "callout" | "floating" | "sticky-bar";
15
+ type Background = "raised" | "sunken" | "transparent" | (string & {});
16
+ type Radius = "none" | "sm" | "md" | "lg" | "full";
17
+ type Border = "none" | "default" | "strong";
18
+ type BorderWidth = "none" | "default" | "medium" | "thick";
19
+ type BorderSides = "all" | "block-start" | "block-end" | "inline-start" | "inline-end" | "block" | "inline";
20
+ type Shadow = "none" | "sm" | "md" | "lg";
21
+ type Position = "static" | "relative" | "sticky" | "fixed";
22
+ /**
23
+ * Arbitrary `data-*` and `aria-*` attributes forwarded to the rendered element
24
+ * so consumers (Modal, Toast, Card, etc.) can compose Surface without losing
25
+ * DOM hooks or ARIA semantics.
26
+ */
27
+ export type SurfaceDataAttrs = {
28
+ [dataAttr: `data-${string}`]: string | number | boolean | undefined;
29
+ [ariaAttr: `aria-${string}`]: string | number | boolean | undefined;
30
+ };
31
+ export type SurfaceProps = SurfaceDataAttrs & {
32
+ children?: ComponentChildren;
33
+ /** Polymorphic element (div, section, article, aside, header, …). Defaults to 'div'. */
34
+ as?: keyof JSX.IntrinsicElements;
35
+ /** Named preset that resolves to a default bundle of the props below. Explicit props override. */
36
+ variant?: SurfaceVariant;
37
+ /** Any CSS length, typically `var(--polly-space-*)`. */
38
+ padding?: string;
39
+ /** Named values map to `var(--polly-surface-*)`; raw strings pass through for one-off colours. */
40
+ background?: Background;
41
+ radius?: Radius;
42
+ border?: Border;
43
+ borderWidth?: BorderWidth;
44
+ borderSides?: BorderSides;
45
+ shadow?: Shadow;
46
+ /** display: inline-block — Surface flows inline with surrounding text. */
47
+ inline?: boolean;
48
+ width?: string;
49
+ height?: string;
50
+ minHeight?: string;
51
+ maxInlineSize?: string;
52
+ position?: Position;
53
+ /** Any CSS inset value (`'0'`, `'auto auto 1rem 1rem'`, `'1rem'`, …). */
54
+ inset?: string;
55
+ zIndex?: number;
56
+ className?: string;
57
+ /**
58
+ * Per-instance overrides. The supported retint path is to set polly tokens
59
+ * here, e.g. `style={{ "--polly-surface-raised": "#fef3c7" }}`. Surface
60
+ * merges this into its own computed style.
61
+ */
62
+ style?: JSX.CSSProperties;
63
+ id?: string;
64
+ role?: JSX.AriaRole;
65
+ tabIndex?: number;
66
+ "aria-label"?: string;
67
+ "aria-labelledby"?: string;
68
+ "aria-describedby"?: string;
69
+ onClick?: JSX.MouseEventHandler<HTMLElement>;
70
+ onKeyDown?: JSX.KeyboardEventHandler<HTMLElement>;
71
+ };
72
+ export declare function Surface(props: SurfaceProps): JSX.Element;
73
+ export {};
@@ -261,6 +261,77 @@
261
261
  }
262
262
  }
263
263
 
264
+ /* src/polly-ui/Surface.module.css */
265
+ @layer polly-components {
266
+ .surface_pQCFqA {
267
+ --s-p: 0;
268
+ --s-bg: transparent;
269
+ --s-radius: 0;
270
+ --s-border-color: transparent;
271
+ --s-border-width: 0;
272
+ --s-shadow: none;
273
+ --s-w: auto;
274
+ --s-h: auto;
275
+ --s-mh: auto;
276
+ --s-mis: none;
277
+ --s-position: static;
278
+ --s-inset: auto;
279
+ --s-z: auto;
280
+ box-sizing: border-box;
281
+ padding: var(--s-p);
282
+ background: var(--s-bg);
283
+ border-style: solid;
284
+ border-color: var(--s-border-color);
285
+ border-width: var(--s-border-width);
286
+ border-radius: var(--s-radius);
287
+ box-shadow: var(--s-shadow);
288
+ inline-size: var(--s-w);
289
+ block-size: var(--s-h);
290
+ min-block-size: var(--s-mh);
291
+ max-inline-size: var(--s-mis);
292
+ position: var(--s-position);
293
+ inset: var(--s-inset);
294
+ z-index: var(--s-z);
295
+ }
296
+
297
+ .inline_pQCFqA {
298
+ display: inline-block;
299
+ inline-size: auto;
300
+ }
301
+
302
+ .sides-block-start_pQCFqA {
303
+ border-style: none;
304
+ border-block-start-style: solid;
305
+ }
306
+
307
+ .sides-block-end_pQCFqA {
308
+ border-style: none;
309
+ border-block-end-style: solid;
310
+ }
311
+
312
+ .sides-inline-start_pQCFqA {
313
+ border-style: none;
314
+ border-inline-start-style: solid;
315
+ }
316
+
317
+ .sides-inline-end_pQCFqA {
318
+ border-style: none;
319
+ border-inline-end-style: solid;
320
+ }
321
+
322
+ .sides-block_pQCFqA {
323
+ border-style: none;
324
+ border-block-start-style: solid;
325
+ border-block-end-style: solid;
326
+ }
327
+
328
+ .sides-inline_pQCFqA {
329
+ border-style: none;
330
+ border-left-style: solid;
331
+ border-right-style: solid;
332
+ }
333
+ }
334
+
264
335
  /* src/polly-ui/Checkbox.module.css */
265
336
  @layer polly-components {
266
337
  .checkbox_EKE5sg {
@@ -404,13 +475,8 @@
404
475
  }
405
476
 
406
477
  .surface_fLMrWA {
407
- position: relative;
408
478
  pointer-events: auto;
409
- background: var(--polly-surface-raised);
410
479
  color: var(--polly-text);
411
- border: var(--polly-border-width-default) solid var(--polly-border);
412
- border-radius: var(--polly-radius-lg);
413
- box-shadow: var(--polly-shadow-lg);
414
480
  max-inline-size: min(640px, calc(100vw - 2 * var(--polly-space-lg)));
415
481
  max-block-size: calc(100vh - 2 * var(--polly-space-lg));
416
482
  overflow: auto;
@@ -717,23 +783,18 @@
717
783
  display: grid;
718
784
  grid-template-columns: 1fr auto;
719
785
  gap: var(--polly-space-md);
720
- padding: var(--polly-space-md) var(--polly-space-lg);
721
- background: var(--polly-surface-raised);
722
786
  color: var(--polly-text);
723
- border: var(--polly-border-width-default) solid var(--polly-border);
724
- border-radius: var(--polly-radius-md);
725
- box-shadow: var(--polly-shadow-md);
726
787
  align-items: center;
727
788
  min-inline-size: 16em;
728
789
  max-inline-size: 28em;
729
790
  }
730
791
 
731
792
  .item_xVzRuA[data-severity="error"] {
732
- border-color: var(--polly-danger);
793
+ --polly-border: var(--polly-danger);
733
794
  }
734
795
 
735
796
  .item_xVzRuA[data-severity="warning"] {
736
- border-color: var(--polly-warning);
797
+ --polly-border: var(--polly-warning);
737
798
  }
738
799
 
739
800
  .message_xVzRuA {
@@ -11,6 +11,7 @@ export { ActionForm, type ActionFormProps } from "./ActionForm.tsx";
11
11
  export { ActionInput, type ActionInputProps, type ActionInputSaveOn, type ActionInputVariant, } from "./ActionInput.tsx";
12
12
  export { Badge, type BadgeProps, type BadgeVariant } from "./Badge.tsx";
13
13
  export { Button, type ButtonColor, type ButtonProps, type ButtonSize, type ButtonTier, } from "./Button.tsx";
14
+ export { Card, type CardProps, type CardSlotProps } from "./Card.tsx";
14
15
  export { Checkbox, type CheckboxProps } from "./Checkbox.tsx";
15
16
  export { Collapsible, type CollapsibleProps } from "./Collapsible.tsx";
16
17
  export { ConfirmDialog, type ConfirmOptions, confirm } from "./ConfirmDialog.tsx";
@@ -20,6 +21,7 @@ export { Modal } from "./Modal.tsx";
20
21
  export { getOverlayRootNode, OverlayRoot } from "./OverlayRoot.tsx";
21
22
  export { Select, type SelectOption, type SelectProps } from "./Select.tsx";
22
23
  export { Skeleton, type SkeletonProps, type SkeletonVariant } from "./Skeleton.tsx";
24
+ export { Surface, type SurfaceProps, type SurfaceVariant } from "./Surface.tsx";
23
25
  export { type Tab, Tabs, type TabsProps } from "./Tabs.tsx";
24
26
  export { TextInput, type TextInputProps } from "./TextInput.tsx";
25
27
  export { Toast, type ToastViewportProps } from "./Toast.tsx";