@plasmicapp/react-web 0.2.103 → 0.2.106

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.
Files changed (66) hide show
  1. package/dist/all.d.ts +495 -106
  2. package/dist/index-common.d.ts +2 -1
  3. package/dist/plume/menu-button/menu-trigger.d.ts +1 -1
  4. package/dist/plume/select/index.d.ts +1 -0
  5. package/dist/plume/triggered-overlay/index.d.ts +1 -0
  6. package/dist/react-web.cjs.development.js +302 -127
  7. package/dist/react-web.cjs.development.js.map +1 -1
  8. package/dist/react-web.cjs.production.min.js +1 -1
  9. package/dist/react-web.cjs.production.min.js.map +1 -1
  10. package/dist/react-web.esm.js +300 -129
  11. package/dist/react-web.esm.js.map +1 -1
  12. package/dist/render/PlasmicHead.d.ts +35 -0
  13. package/dist/render/ssr.d.ts +2 -1
  14. package/dist/render/triggers.d.ts +4 -4
  15. package/dist/states/index.d.ts +3 -1
  16. package/dist/stories/UseDollarState.stories.d.ts +7 -0
  17. package/package.json +20 -19
  18. package/skinny/dist/collection-utils-3487dd27.js +238 -0
  19. package/skinny/dist/collection-utils-3487dd27.js.map +1 -0
  20. package/skinny/dist/collection-utils-57c273dc.js +238 -0
  21. package/skinny/dist/collection-utils-57c273dc.js.map +1 -0
  22. package/skinny/dist/common-182a0b0c.js +201 -0
  23. package/skinny/dist/common-182a0b0c.js.map +1 -0
  24. package/skinny/dist/index-common.d.ts +2 -1
  25. package/skinny/dist/index.js +65 -45
  26. package/skinny/dist/index.js.map +1 -1
  27. package/skinny/dist/plume/button/index.js +5 -5
  28. package/skinny/dist/plume/button/index.js.map +1 -1
  29. package/skinny/dist/plume/checkbox/index.js +7 -7
  30. package/skinny/dist/plume/checkbox/index.js.map +1 -1
  31. package/skinny/dist/plume/menu/index.js +12 -12
  32. package/skinny/dist/plume/menu/index.js.map +1 -1
  33. package/skinny/dist/plume/menu-button/index.js +7 -7
  34. package/skinny/dist/plume/menu-button/index.js.map +1 -1
  35. package/skinny/dist/plume/menu-button/menu-trigger.d.ts +1 -1
  36. package/skinny/dist/plume/select/index.d.ts +1 -0
  37. package/skinny/dist/plume/select/index.js +13 -13
  38. package/skinny/dist/plume/select/index.js.map +1 -1
  39. package/skinny/dist/plume/switch/index.js +7 -7
  40. package/skinny/dist/plume/switch/index.js.map +1 -1
  41. package/skinny/dist/plume/text-input/index.js +5 -5
  42. package/skinny/dist/plume/text-input/index.js.map +1 -1
  43. package/skinny/dist/plume/triggered-overlay/index.d.ts +1 -0
  44. package/skinny/dist/plume/triggered-overlay/index.js +8 -7
  45. package/skinny/dist/plume/triggered-overlay/index.js.map +1 -1
  46. package/skinny/dist/plume-utils-623b91cc.js +35 -0
  47. package/skinny/dist/plume-utils-623b91cc.js.map +1 -0
  48. package/skinny/dist/props-utils-b2ad4997.js +8 -0
  49. package/skinny/dist/props-utils-b2ad4997.js.map +1 -0
  50. package/skinny/dist/react-utils-35cb2a4e.js +201 -0
  51. package/skinny/dist/react-utils-35cb2a4e.js.map +1 -0
  52. package/skinny/dist/render/PlasmicHead.d.ts +35 -0
  53. package/skinny/dist/render/PlasmicImg/index.js +3 -3
  54. package/skinny/dist/render/PlasmicImg/index.js.map +1 -1
  55. package/skinny/dist/render/ssr.d.ts +2 -1
  56. package/skinny/dist/render/triggers.d.ts +4 -4
  57. package/skinny/dist/ssr-14264281.js +158 -0
  58. package/skinny/dist/ssr-14264281.js.map +1 -0
  59. package/skinny/dist/ssr-579df58f.js +158 -0
  60. package/skinny/dist/ssr-579df58f.js.map +1 -0
  61. package/skinny/dist/ssr-9ebd98ed.js +158 -0
  62. package/skinny/dist/ssr-9ebd98ed.js.map +1 -0
  63. package/skinny/dist/ssr-d2fd94f2.js +31 -0
  64. package/skinny/dist/ssr-d2fd94f2.js.map +1 -0
  65. package/skinny/dist/states/index.d.ts +3 -1
  66. package/skinny/dist/stories/UseDollarState.stories.d.ts +7 -0
package/dist/all.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import React__default, { FocusEvent, KeyboardEvent as KeyboardEvent$1, SyntheticEvent, ReactNode } from 'react';
2
+ import React__default, { AriaAttributes, DOMAttributes as DOMAttributes$1, AriaRole, CSSProperties, Key, ReactNode, ReactElement, FocusEvent, KeyboardEvent as KeyboardEvent$1, SyntheticEvent } from 'react';
3
3
 
4
4
  // This is the only way I found to break circular references between ClassArray and ClassValue
5
5
  // https://github.com/Microsoft/TypeScript/issues/3496#issuecomment-128553540
@@ -82,6 +82,39 @@ declare function deriveRenderOpts(props: Record<string, any>, config: {
82
82
 
83
83
  declare function ensureGlobalVariants<T extends Record<string, any>>(globalVariantValues: T): T;
84
84
 
85
+ declare type PlasmicHeadProps = {
86
+ title?: string;
87
+ description?: string;
88
+ image?: string;
89
+ canonical?: string;
90
+ };
91
+ declare function PlasmicHead(props: PlasmicHeadProps): JSX.Element | null;
92
+ declare const plasmicHeadMeta: {
93
+ name: string;
94
+ displayName: string;
95
+ description: string;
96
+ importName: string;
97
+ importPath: string;
98
+ props: {
99
+ title: {
100
+ type: string;
101
+ displayName: string;
102
+ };
103
+ description: {
104
+ type: string;
105
+ displayName: string;
106
+ };
107
+ image: {
108
+ type: string;
109
+ displayName: string;
110
+ };
111
+ canonical: {
112
+ type: string;
113
+ displayName: string;
114
+ };
115
+ };
116
+ };
117
+
85
118
  declare function PlasmicIcon(props: React.ComponentProps<"svg"> & {
86
119
  PlasmicIconType: React.ComponentType;
87
120
  }): JSX.Element;
@@ -213,6 +246,7 @@ interface PlasmicRootProviderProps {
213
246
  platform?: "nextjs" | "gatsby";
214
247
  children?: React.ReactNode;
215
248
  translator?: PlasmicTranslator;
249
+ Head?: React.ComponentType<any>;
216
250
  }
217
251
  declare function PlasmicRootProvider(props: PlasmicRootProviderProps): JSX.Element;
218
252
  declare const useIsSSR: typeof useIsSSR$1;
@@ -268,109 +302,6 @@ declare const Stack: (<T extends "symbol" | "object" | "a" | "abbr" | "address"
268
302
  }>;
269
303
  };
270
304
 
271
- declare function useFocused(opts: {
272
- isTextInput?: boolean;
273
- }): (boolean | React.HTMLAttributes<HTMLElement>)[];
274
- declare function useFocusVisible(opts: {
275
- isTextInput?: boolean;
276
- }): (boolean | React.HTMLAttributes<HTMLElement>)[];
277
- declare function useFocusedWithin(opts: {
278
- isTextInput?: boolean;
279
- }): (boolean | React.HTMLAttributes<HTMLElement>)[];
280
- declare function useFocusVisibleWithin(opts: {
281
- isTextInput?: boolean;
282
- }): (boolean | React.HTMLAttributes<HTMLElement>)[];
283
- declare function useHover(): (boolean | {
284
- onMouseEnter: () => void;
285
- onMouseLeave: () => void;
286
- })[];
287
- declare function usePressed(): (boolean | {
288
- onMouseDown: () => void;
289
- onMouseUp: () => void;
290
- })[];
291
- declare const TRIGGER_TO_HOOK: {
292
- readonly useHover: typeof useHover;
293
- readonly useFocused: typeof useFocused;
294
- readonly useFocusVisible: typeof useFocusVisible;
295
- readonly useFocusedWithin: typeof useFocusedWithin;
296
- readonly useFocusVisibleWithin: typeof useFocusVisibleWithin;
297
- readonly usePressed: typeof usePressed;
298
- };
299
- declare type TriggerType = keyof typeof TRIGGER_TO_HOOK;
300
- interface TriggerOpts {
301
- isTextInput?: boolean;
302
- }
303
- /**
304
- * Installs argment trigger. All the useTrigger calls must use hardcoded `trigger` arg,
305
- * as it's not valid to install variable React hooks!
306
- */
307
- declare function useTrigger(trigger: TriggerType, opts: TriggerOpts): [boolean, React.HTMLAttributes<HTMLElement>];
308
-
309
- declare const classNames: ClassNamesExport;
310
-
311
- declare function setPlumeStrictMode(mode: boolean): void;
312
- declare type VariantArgChoices<T> = T extends (infer M)[] ? M : T extends SingleChoiceArg<infer M> ? M : never;
313
- declare type VariantArgsChoices<V> = {
314
- [k in keyof V]-?: VariantArgChoices<V[k]>;
315
- };
316
- declare type DictValues<V extends Record<string, any>> = V[keyof V];
317
- declare type DictTuples<V extends Record<string, any>> = DictValues<{
318
- [K in keyof V]: [K, V[K]];
319
- }>;
320
- declare type VariantDefTuple<V> = DictTuples<VariantArgsChoices<V>>;
321
- declare type DistributeTuple<T> = T extends [infer T1, infer T2] ? {
322
- group: T1;
323
- variant: T2;
324
- } : never;
325
- declare type VariantDef<V> = DistributeTuple<VariantDefTuple<V>>;
326
- declare type PlasmicClass<V extends Record<string, any>, A extends Record<string, any>, O extends Record<string, any>> = {
327
- (props: {
328
- variants?: V;
329
- args?: A;
330
- overrides?: O;
331
- }): React.ReactElement | null;
332
- internalVariantProps: (keyof V)[];
333
- internalArgProps: (keyof A)[];
334
- };
335
- declare type AnyPlasmicClass = PlasmicClass<any, any, any>;
336
- declare type PlasmicClassVariants<C extends AnyPlasmicClass> = C extends PlasmicClass<infer V, any, any> ? V : unknown;
337
- declare type PlasmicClassArgs<C extends AnyPlasmicClass> = C extends PlasmicClass<any, infer A, any> ? A : unknown;
338
- declare type PlasmicClassOverrides<C extends AnyPlasmicClass> = C extends PlasmicClass<any, any, infer O> ? O : unknown;
339
-
340
- interface CommonProps {
341
- showStartIcon?: boolean;
342
- showEndIcon?: boolean;
343
- startIcon?: React.ReactNode;
344
- endIcon?: React.ReactNode;
345
- children?: React.ReactNode;
346
- isDisabled?: boolean;
347
- }
348
- interface HtmlButtonProps extends Omit<React.ComponentProps<"button">, "ref" | "disabled"> {
349
- }
350
- interface HtmlAnchorProps extends Omit<React.ComponentProps<"a">, "ref" | "href"> {
351
- link?: string;
352
- }
353
- declare type BaseButtonProps = CommonProps & HtmlButtonProps & HtmlAnchorProps;
354
- declare type HtmlAnchorOnlyProps = Exclude<keyof HtmlAnchorProps, keyof HtmlButtonProps>;
355
- declare type HtmlButtonOnlyProps = Exclude<keyof HtmlButtonProps, keyof HtmlAnchorProps>;
356
- declare type ButtonRef = React.Ref<HTMLButtonElement | HTMLAnchorElement>;
357
- interface ButtonConfig<C extends AnyPlasmicClass> {
358
- showStartIconVariant: VariantDef<PlasmicClassVariants<C>>;
359
- showEndIconVariant?: VariantDef<PlasmicClassVariants<C>>;
360
- isDisabledVariant?: VariantDef<PlasmicClassVariants<C>>;
361
- startIconSlot?: keyof PlasmicClassArgs<C>;
362
- endIconSlot?: keyof PlasmicClassArgs<C>;
363
- contentSlot: keyof PlasmicClassArgs<C>;
364
- root: keyof PlasmicClassOverrides<C>;
365
- }
366
- declare function useButton<P extends BaseButtonProps, C extends AnyPlasmicClass>(plasmicClass: C, props: P, config: ButtonConfig<C>, ref?: ButtonRef): {
367
- plasmicProps: {
368
- variants: PlasmicClassVariants<C>;
369
- args: PlasmicClassArgs<C>;
370
- overrides: PlasmicClassOverrides<C>;
371
- };
372
- };
373
-
374
305
  /*
375
306
  * Copyright 2020 Adobe. All rights reserved.
376
307
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -433,6 +364,17 @@ interface FocusableDOMProps extends DOMProps {
433
364
  excludeFromTabOrder?: boolean
434
365
  }
435
366
 
367
+ /** Any focusable element, including both HTML and SVG elements. */
368
+ interface FocusableElement extends Element, HTMLOrSVGElement {}
369
+
370
+ /** All DOM attributes supported across both HTML and SVG elements. */
371
+ interface DOMAttributes<T = FocusableElement> extends AriaAttributes, DOMAttributes$1<T> {
372
+ id?: string | undefined,
373
+ role?: AriaRole | undefined,
374
+ tabIndex?: number | undefined,
375
+ style?: CSSProperties | undefined
376
+ }
377
+
436
378
  /*
437
379
  * Copyright 2020 Adobe. All rights reserved.
438
380
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -478,6 +420,104 @@ interface InputBase {
478
420
  */
479
421
 
480
422
 
423
+ type SelectionMode = 'none' | 'single' | 'multiple';
424
+ type SelectionBehavior = 'toggle' | 'replace';
425
+ type Selection = 'all' | Set<Key>;
426
+
427
+ type FocusStrategy = 'first' | 'last';
428
+ type DisabledBehavior = 'selection' | 'all';
429
+
430
+ /*
431
+ * Copyright 2020 Adobe. All rights reserved.
432
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
433
+ * you may not use this file except in compliance with the License. You may obtain a copy
434
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
435
+ *
436
+ * Unless required by applicable law or agreed to in writing, software distributed under
437
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
438
+ * OF ANY KIND, either express or implied. See the License for the specific language
439
+ * governing permissions and limitations under the License.
440
+ */
441
+
442
+
443
+ /**
444
+ * A generic interface to access a readonly sequential
445
+ * collection of unique keyed items.
446
+ */
447
+ interface Collection<T> extends Iterable<T> {
448
+ /** The number of items in the collection. */
449
+ readonly size: number,
450
+
451
+ /** Iterate over all keys in the collection. */
452
+ getKeys(): Iterable<Key>,
453
+
454
+ /** Get an item by its key. */
455
+ getItem(key: Key): T,
456
+
457
+ /** Get an item by the index of its key. */
458
+ at(idx: number): T,
459
+
460
+ /** Get the key that comes before the given key in the collection. */
461
+ getKeyBefore(key: Key): Key | null,
462
+
463
+ /** Get the key that comes after the given key in the collection. */
464
+ getKeyAfter(key: Key): Key | null,
465
+
466
+ /** Get the first key in the collection. */
467
+ getFirstKey(): Key | null,
468
+
469
+ /** Get the last key in the collection. */
470
+ getLastKey(): Key | null
471
+ }
472
+
473
+ interface Node<T> {
474
+ /** The type of item this node represents. */
475
+ type: string,
476
+ /** A unique key for the node. */
477
+ key: Key,
478
+ /** The object value the node was created from. */
479
+ value: T,
480
+ /** The level of depth this node is at in the heirarchy. */
481
+ level: number,
482
+ /** Whether this item has children, even if not loaded yet. */
483
+ hasChildNodes: boolean,
484
+ /** The loaded children of this node. */
485
+ childNodes: Iterable<Node<T>>,
486
+ /** The rendered contents of this node (e.g. JSX). */
487
+ rendered: ReactNode,
488
+ /** A string value for this node, used for features like typeahead. */
489
+ textValue: string,
490
+ /** An accessibility label for this node. */
491
+ 'aria-label'?: string,
492
+ /** The index of this node within its parent. */
493
+ index?: number,
494
+ /** A function that should be called to wrap the rendered node. */
495
+ wrapper?: (element: ReactElement) => ReactElement,
496
+ /** The key of the parent node. */
497
+ parentKey?: Key,
498
+ /** The key of the node before this node. */
499
+ prevKey?: Key,
500
+ /** The key of the node after this node. */
501
+ nextKey?: Key,
502
+ /** Additional properties specific to a particular node type. */
503
+ props?: any,
504
+ /** @private */
505
+ shouldInvalidate?: (context: unknown) => boolean
506
+ }
507
+
508
+ /*
509
+ * Copyright 2020 Adobe. All rights reserved.
510
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
511
+ * you may not use this file except in compliance with the License. You may obtain a copy
512
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
513
+ *
514
+ * Unless required by applicable law or agreed to in writing, software distributed under
515
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
516
+ * OF ANY KIND, either express or implied. See the License for the specific language
517
+ * governing permissions and limitations under the License.
518
+ */
519
+
520
+
481
521
  // Event bubbling can be problematic in real-world applications, so the default for React Spectrum components
482
522
  // is not to propagate. This can be overridden by calling continuePropagation() on the event.
483
523
  type BaseEvent<T extends SyntheticEvent> = T & {
@@ -488,6 +528,30 @@ type BaseEvent<T extends SyntheticEvent> = T & {
488
528
 
489
529
  type KeyboardEvent = BaseEvent<KeyboardEvent$1<any>>;
490
530
 
531
+ type PointerType = 'mouse' | 'pen' | 'touch' | 'keyboard' | 'virtual';
532
+
533
+ interface PressEvent {
534
+ /** The type of press event being fired. */
535
+ type: 'pressstart' | 'pressend' | 'pressup' | 'press',
536
+ /** The pointer type that triggered the press event. */
537
+ pointerType: PointerType,
538
+ /** The target element of the press event. */
539
+ target: Element,
540
+ /** Whether the shift keyboard modifier was held during the press event. */
541
+ shiftKey: boolean,
542
+ /** Whether the ctrl keyboard modifier was held during the press event. */
543
+ ctrlKey: boolean,
544
+ /** Whether the meta keyboard modifier was held during the press event. */
545
+ metaKey: boolean,
546
+ /** Whether the alt keyboard modifier was held during the press event. */
547
+ altKey: boolean
548
+ }
549
+
550
+ interface LongPressEvent extends Omit<PressEvent, 'type'> {
551
+ /** The type of long press event being fired. */
552
+ type: 'longpressstart' | 'longpressend' | 'longpress'
553
+ }
554
+
491
555
  interface KeyboardEvents {
492
556
  /** Handler that is called when a key is pressed. */
493
557
  onKeyDown?: (e: KeyboardEvent) => void,
@@ -509,6 +573,109 @@ interface FocusableProps extends FocusEvents, KeyboardEvents {
509
573
  autoFocus?: boolean
510
574
  }
511
575
 
576
+ declare function useFocused(opts: {
577
+ isTextInput?: boolean;
578
+ }): (boolean | DOMAttributes<FocusableElement>)[];
579
+ declare function useFocusVisible(opts: {
580
+ isTextInput?: boolean;
581
+ }): (boolean | DOMAttributes<FocusableElement>)[];
582
+ declare function useFocusedWithin(opts: {
583
+ isTextInput?: boolean;
584
+ }): (boolean | DOMAttributes<FocusableElement>)[];
585
+ declare function useFocusVisibleWithin(opts: {
586
+ isTextInput?: boolean;
587
+ }): (boolean | DOMAttributes<FocusableElement>)[];
588
+ declare function useHover(): (boolean | {
589
+ onMouseEnter: () => void;
590
+ onMouseLeave: () => void;
591
+ })[];
592
+ declare function usePressed(): (boolean | {
593
+ onMouseDown: () => void;
594
+ onMouseUp: () => void;
595
+ })[];
596
+ declare const TRIGGER_TO_HOOK: {
597
+ readonly useHover: typeof useHover;
598
+ readonly useFocused: typeof useFocused;
599
+ readonly useFocusVisible: typeof useFocusVisible;
600
+ readonly useFocusedWithin: typeof useFocusedWithin;
601
+ readonly useFocusVisibleWithin: typeof useFocusVisibleWithin;
602
+ readonly usePressed: typeof usePressed;
603
+ };
604
+ declare type TriggerType = keyof typeof TRIGGER_TO_HOOK;
605
+ interface TriggerOpts {
606
+ isTextInput?: boolean;
607
+ }
608
+ /**
609
+ * Installs argment trigger. All the useTrigger calls must use hardcoded `trigger` arg,
610
+ * as it's not valid to install variable React hooks!
611
+ */
612
+ declare function useTrigger(trigger: TriggerType, opts: TriggerOpts): [boolean, React.HTMLAttributes<HTMLElement>];
613
+
614
+ declare const classNames: ClassNamesExport;
615
+
616
+ declare function setPlumeStrictMode(mode: boolean): void;
617
+ declare type VariantArgChoices<T> = T extends (infer M)[] ? M : T extends SingleChoiceArg<infer M> ? M : never;
618
+ declare type VariantArgsChoices<V> = {
619
+ [k in keyof V]-?: VariantArgChoices<V[k]>;
620
+ };
621
+ declare type DictValues<V extends Record<string, any>> = V[keyof V];
622
+ declare type DictTuples<V extends Record<string, any>> = DictValues<{
623
+ [K in keyof V]: [K, V[K]];
624
+ }>;
625
+ declare type VariantDefTuple<V> = DictTuples<VariantArgsChoices<V>>;
626
+ declare type DistributeTuple<T> = T extends [infer T1, infer T2] ? {
627
+ group: T1;
628
+ variant: T2;
629
+ } : never;
630
+ declare type VariantDef<V> = DistributeTuple<VariantDefTuple<V>>;
631
+ declare type PlasmicClass<V extends Record<string, any>, A extends Record<string, any>, O extends Record<string, any>> = {
632
+ (props: {
633
+ variants?: V;
634
+ args?: A;
635
+ overrides?: O;
636
+ }): React.ReactElement | null;
637
+ internalVariantProps: (keyof V)[];
638
+ internalArgProps: (keyof A)[];
639
+ };
640
+ declare type AnyPlasmicClass = PlasmicClass<any, any, any>;
641
+ declare type PlasmicClassVariants<C extends AnyPlasmicClass> = C extends PlasmicClass<infer V, any, any> ? V : unknown;
642
+ declare type PlasmicClassArgs<C extends AnyPlasmicClass> = C extends PlasmicClass<any, infer A, any> ? A : unknown;
643
+ declare type PlasmicClassOverrides<C extends AnyPlasmicClass> = C extends PlasmicClass<any, any, infer O> ? O : unknown;
644
+
645
+ interface CommonProps {
646
+ showStartIcon?: boolean;
647
+ showEndIcon?: boolean;
648
+ startIcon?: React.ReactNode;
649
+ endIcon?: React.ReactNode;
650
+ children?: React.ReactNode;
651
+ isDisabled?: boolean;
652
+ }
653
+ interface HtmlButtonProps extends Omit<React.ComponentProps<"button">, "ref" | "disabled"> {
654
+ }
655
+ interface HtmlAnchorProps extends Omit<React.ComponentProps<"a">, "ref" | "href"> {
656
+ link?: string;
657
+ }
658
+ declare type BaseButtonProps = CommonProps & HtmlButtonProps & HtmlAnchorProps;
659
+ declare type HtmlAnchorOnlyProps = Exclude<keyof HtmlAnchorProps, keyof HtmlButtonProps>;
660
+ declare type HtmlButtonOnlyProps = Exclude<keyof HtmlButtonProps, keyof HtmlAnchorProps>;
661
+ declare type ButtonRef = React.Ref<HTMLButtonElement | HTMLAnchorElement>;
662
+ interface ButtonConfig<C extends AnyPlasmicClass> {
663
+ showStartIconVariant: VariantDef<PlasmicClassVariants<C>>;
664
+ showEndIconVariant?: VariantDef<PlasmicClassVariants<C>>;
665
+ isDisabledVariant?: VariantDef<PlasmicClassVariants<C>>;
666
+ startIconSlot?: keyof PlasmicClassArgs<C>;
667
+ endIconSlot?: keyof PlasmicClassArgs<C>;
668
+ contentSlot: keyof PlasmicClassArgs<C>;
669
+ root: keyof PlasmicClassOverrides<C>;
670
+ }
671
+ declare function useButton<P extends BaseButtonProps, C extends AnyPlasmicClass>(plasmicClass: C, props: P, config: ButtonConfig<C>, ref?: ButtonRef): {
672
+ plasmicProps: {
673
+ variants: PlasmicClassVariants<C>;
674
+ args: PlasmicClassArgs<C>;
675
+ overrides: PlasmicClassOverrides<C>;
676
+ };
677
+ };
678
+
512
679
  /*
513
680
  * Copyright 2020 Adobe. All rights reserved.
514
681
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -1044,6 +1211,202 @@ declare function useSelectOptionGroup<P extends BaseSelectOptionGroupProps, C ex
1044
1211
  };
1045
1212
  };
1046
1213
 
1214
+ interface FocusState {
1215
+ /** Whether the collection is currently focused. */
1216
+ readonly isFocused: boolean;
1217
+ /** Sets whether the collection is focused. */
1218
+ setFocused(isFocused: boolean): void;
1219
+ /** The current focused key in the collection. */
1220
+ readonly focusedKey: Key;
1221
+ /** Whether the first or last child of the focused key should receive focus. */
1222
+ readonly childFocusStrategy: FocusStrategy;
1223
+ /** Sets the focused key, and optionally, whether the first or last child of that key should receive focus. */
1224
+ setFocusedKey(key: Key, child?: FocusStrategy): void;
1225
+ }
1226
+ interface MultipleSelectionState extends FocusState {
1227
+ /** The type of selection that is allowed in the collection. */
1228
+ readonly selectionMode: SelectionMode;
1229
+ /** The selection behavior for the collection. */
1230
+ readonly selectionBehavior: SelectionBehavior;
1231
+ /** Sets the selection behavior for the collection. */
1232
+ setSelectionBehavior(selectionBehavior: SelectionBehavior): void;
1233
+ /** Whether the collection allows empty selection. */
1234
+ readonly disallowEmptySelection: boolean;
1235
+ /** The currently selected keys in the collection. */
1236
+ readonly selectedKeys: Selection;
1237
+ /** Sets the selected keys in the collection. */
1238
+ setSelectedKeys(keys: Selection): void;
1239
+ /** The currently disabled keys in the collection. */
1240
+ readonly disabledKeys: Set<Key>;
1241
+ /** Whether `disabledKeys` applies to selection, actions, or both. */
1242
+ readonly disabledBehavior: DisabledBehavior;
1243
+ }
1244
+ interface MultipleSelectionManager extends FocusState {
1245
+ /** The type of selection that is allowed in the collection. */
1246
+ readonly selectionMode: SelectionMode;
1247
+ /** The selection behavior for the collection. */
1248
+ readonly selectionBehavior: SelectionBehavior;
1249
+ /** Whether the collection allows empty selection. */
1250
+ readonly disallowEmptySelection?: boolean;
1251
+ /** The currently selected keys in the collection. */
1252
+ readonly selectedKeys: Set<Key>;
1253
+ /** Whether the selection is empty. */
1254
+ readonly isEmpty: boolean;
1255
+ /** Whether all items in the collection are selected. */
1256
+ readonly isSelectAll: boolean;
1257
+ /** The first selected key in the collection. */
1258
+ readonly firstSelectedKey: Key | null;
1259
+ /** The last selected key in the collection. */
1260
+ readonly lastSelectedKey: Key | null;
1261
+ /** The currently disabled keys in the collection. */
1262
+ readonly disabledKeys: Set<Key>;
1263
+ /** Whether `disabledKeys` applies to selection, actions, or both. */
1264
+ readonly disabledBehavior: DisabledBehavior;
1265
+ /** Returns whether a key is selected. */
1266
+ isSelected(key: Key): boolean;
1267
+ /** Returns whether the current selection is equal to the given selection. */
1268
+ isSelectionEqual(selection: Set<Key>): boolean;
1269
+ /** Extends the selection to the given key. */
1270
+ extendSelection(toKey: Key): void;
1271
+ /** Toggles whether the given key is selected. */
1272
+ toggleSelection(key: Key): void;
1273
+ /** Replaces the selection with only the given key. */
1274
+ replaceSelection(key: Key): void;
1275
+ /** Replaces the selection with the given keys. */
1276
+ setSelectedKeys(keys: Iterable<Key>): void;
1277
+ /** Selects all items in the collection. */
1278
+ selectAll(): void;
1279
+ /** Removes all keys from the selection. */
1280
+ clearSelection(): void;
1281
+ /** Toggles between select all and an empty selection. */
1282
+ toggleSelectAll(): void;
1283
+ /**
1284
+ * Toggles, replaces, or extends selection to the given key depending
1285
+ * on the pointer event and collection's selection mode.
1286
+ */
1287
+ select(key: Key, e?: PressEvent | LongPressEvent | PointerEvent): void;
1288
+ /** Returns whether the given key can be selected. */
1289
+ canSelectItem(key: Key): boolean;
1290
+ /** Returns whether the given key is non-interactive, i.e. both selection and actions are disabled. */
1291
+ isDisabled(key: Key): boolean;
1292
+ /** Sets the selection behavior for the collection. */
1293
+ setSelectionBehavior(selectionBehavior: SelectionBehavior): void;
1294
+ }
1295
+ interface SelectionManagerOptions {
1296
+ allowsCellSelection?: boolean;
1297
+ }
1298
+ /**
1299
+ * An interface for reading and updating multiple selection state.
1300
+ */
1301
+ declare class SelectionManager implements MultipleSelectionManager {
1302
+ constructor(collection: Collection<Node<unknown>>, state: MultipleSelectionState, options?: SelectionManagerOptions);
1303
+ /**
1304
+ * The type of selection that is allowed in the collection.
1305
+ */
1306
+ get selectionMode(): SelectionMode;
1307
+ /**
1308
+ * Whether the collection allows empty selection.
1309
+ */
1310
+ get disallowEmptySelection(): boolean;
1311
+ /**
1312
+ * The selection behavior for the collection.
1313
+ */
1314
+ get selectionBehavior(): SelectionBehavior;
1315
+ /**
1316
+ * Sets the selection behavior for the collection.
1317
+ */
1318
+ setSelectionBehavior(selectionBehavior: SelectionBehavior): void;
1319
+ /**
1320
+ * Whether the collection is currently focused.
1321
+ */
1322
+ get isFocused(): boolean;
1323
+ /**
1324
+ * Sets whether the collection is focused.
1325
+ */
1326
+ setFocused(isFocused: boolean): void;
1327
+ /**
1328
+ * The current focused key in the collection.
1329
+ */
1330
+ get focusedKey(): Key;
1331
+ /** Whether the first or last child of the focused key should receive focus. */
1332
+ get childFocusStrategy(): FocusStrategy;
1333
+ /**
1334
+ * Sets the focused key.
1335
+ */
1336
+ setFocusedKey(key: Key, childFocusStrategy?: FocusStrategy): void;
1337
+ /**
1338
+ * The currently selected keys in the collection.
1339
+ */
1340
+ get selectedKeys(): Set<Key>;
1341
+ /**
1342
+ * The raw selection value for the collection.
1343
+ * Either 'all' for select all, or a set of keys.
1344
+ */
1345
+ get rawSelection(): Selection;
1346
+ /**
1347
+ * Returns whether a key is selected.
1348
+ */
1349
+ isSelected(key: Key): boolean;
1350
+ /**
1351
+ * Whether the selection is empty.
1352
+ */
1353
+ get isEmpty(): boolean;
1354
+ /**
1355
+ * Whether all items in the collection are selected.
1356
+ */
1357
+ get isSelectAll(): boolean;
1358
+ get firstSelectedKey(): Key | null;
1359
+ get lastSelectedKey(): Key | null;
1360
+ get disabledKeys(): Set<Key>;
1361
+ get disabledBehavior(): DisabledBehavior;
1362
+ /**
1363
+ * Extends the selection to the given key.
1364
+ */
1365
+ extendSelection(toKey: Key): void;
1366
+ /**
1367
+ * Toggles whether the given key is selected.
1368
+ */
1369
+ toggleSelection(key: Key): void;
1370
+ /**
1371
+ * Replaces the selection with only the given key.
1372
+ */
1373
+ replaceSelection(key: Key): void;
1374
+ /**
1375
+ * Replaces the selection with the given keys.
1376
+ */
1377
+ setSelectedKeys(keys: Iterable<Key>): void;
1378
+ /**
1379
+ * Selects all items in the collection.
1380
+ */
1381
+ selectAll(): void;
1382
+ /**
1383
+ * Removes all keys from the selection.
1384
+ */
1385
+ clearSelection(): void;
1386
+ /**
1387
+ * Toggles between select all and an empty selection.
1388
+ */
1389
+ toggleSelectAll(): void;
1390
+ select(key: Key, e?: PressEvent | LongPressEvent | PointerEvent): void;
1391
+ /**
1392
+ * Returns whether the current selection is equal to the given selection.
1393
+ */
1394
+ isSelectionEqual(selection: Set<Key>): boolean;
1395
+ canSelectItem(key: Key): boolean;
1396
+ isDisabled(key: Key): boolean;
1397
+ }
1398
+
1399
+ interface ListState<T> {
1400
+ /** A collection of items in the list. */
1401
+ collection: Collection<Node<T>>;
1402
+ /** A set of items that are disabled. */
1403
+ disabledKeys: Set<Key>;
1404
+ /** A selection manager to read and update multiple selection state. */
1405
+ selectionManager: SelectionManager;
1406
+ }
1407
+
1408
+ declare const SelectContext: React.Context<ListState<any> | undefined>;
1409
+
1047
1410
  /*
1048
1411
  * Copyright 2020 Adobe. All rights reserved.
1049
1412
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -1182,12 +1545,38 @@ declare function useTriggeredOverlay<P extends BaseTriggeredOverlayProps, C exte
1182
1545
  };
1183
1546
  };
1184
1547
 
1548
+ interface OverlayTriggerState {
1549
+ /** Whether the overlay is currently open. */
1550
+ readonly isOpen: boolean;
1551
+ /** Sets whether the overlay is open. */
1552
+ setOpen(isOpen: boolean): void;
1553
+ /** Opens the overlay. */
1554
+ open(): void;
1555
+ /** Closes the overlay. */
1556
+ close(): void;
1557
+ /** Toggles the overlay's visibility. */
1558
+ toggle(): void;
1559
+ }
1560
+
1561
+ interface TriggeredOverlayContextValue {
1562
+ triggerRef: React.RefObject<HTMLElement>;
1563
+ state: OverlayTriggerState;
1564
+ autoFocus?: boolean | FocusStrategy;
1565
+ placement?: Placement;
1566
+ overlayMatchTriggerWidth?: boolean;
1567
+ overlayMinTriggerWidth?: boolean;
1568
+ overlayWidth?: number;
1569
+ }
1570
+ declare const TriggeredOverlayContext: React.Context<TriggeredOverlayContextValue | undefined>;
1571
+
1572
+ declare type InitFunc<T> = ($props: Record<string, any>, $state: $State) => T;
1185
1573
  interface $State {
1186
1574
  [key: string]: any;
1575
+ registerInitFunc: (path: string, f: InitFunc<any>) => any;
1187
1576
  }
1188
1577
  interface $StateSpec<T> {
1189
1578
  path: string;
1190
- initFunc?: ($props: Record<string, any>, $state: $State) => T;
1579
+ initFunc?: InitFunc<T>;
1191
1580
  initVal?: T;
1192
1581
  type: "private" | "readonly" | "writable";
1193
1582
  valueProp?: string;
@@ -1204,4 +1593,4 @@ declare function generateStateOnChangeProp($state: $State, stateName: string, da
1204
1593
  */
1205
1594
  declare function generateStateValueProp($state: $State, path: (string | number)[]): any;
1206
1595
 
1207
- export { BaseButtonProps, BaseMenuButtonProps, BaseMenuGroupProps, BaseMenuItemProps, BaseMenuProps, BaseSelectOptionGroupProps, BaseSelectOptionProps, BaseSelectProps, BaseTextInputProps, BaseTriggeredOverlayProps, ButtonRef, CheckboxProps, CheckboxRef, CheckboxRefValue, DropdownMenu, Flex, HTMLElementRefOf, HtmlAnchorOnlyProps, HtmlButtonOnlyProps, MenuButtonRef, MenuButtonRefValue, MenuRef, MenuRefValue, MultiChoiceArg, PlasmicIcon, PlasmicImg, PlasmicLink, PlasmicRootProvider, PlasmicSlot, SelectOptionRef, SelectRef, SelectRefValue, SingleBooleanChoiceArg, SingleChoiceArg, Stack, StrictProps, SwitchProps, SwitchRef, SwitchRefValue, TextInputRef, TextInputRefValue, Trans, TriggeredOverlayConfig, TriggeredOverlayRef, classNames, createPlasmicElementProxy, createUseScreenVariants, deriveRenderOpts, ensureGlobalVariants, genTranslatableString, generateStateOnChangeProp, generateStateValueProp, getDataProps, hasVariant, makeFragment, omit, pick, renderPlasmicSlot, setPlumeStrictMode, useButton, useCheckbox, useVanillaDollarState as useDollarState, useIsSSR, useMenu, useMenuButton, useMenuGroup, useMenuItem, useSelect, useSelectOption, useSelectOptionGroup, useSwitch, useTextInput, useTrigger, useTriggeredOverlay, wrapWithClassName };
1596
+ export { BaseButtonProps, BaseMenuButtonProps, BaseMenuGroupProps, BaseMenuItemProps, BaseMenuProps, BaseSelectOptionGroupProps, BaseSelectOptionProps, BaseSelectProps, BaseTextInputProps, BaseTriggeredOverlayProps, ButtonRef, CheckboxProps, CheckboxRef, CheckboxRefValue, DropdownMenu, Flex, HTMLElementRefOf, HtmlAnchorOnlyProps, HtmlButtonOnlyProps, MenuButtonRef, MenuButtonRefValue, MenuRef, MenuRefValue, MultiChoiceArg, PlasmicHead, PlasmicIcon, PlasmicImg, PlasmicLink, PlasmicRootProvider, PlasmicSlot, SelectContext, SelectOptionRef, SelectRef, SelectRefValue, SingleBooleanChoiceArg, SingleChoiceArg, Stack, StrictProps, SwitchProps, SwitchRef, SwitchRefValue, TextInputRef, TextInputRefValue, Trans, TriggeredOverlayConfig, TriggeredOverlayContext, TriggeredOverlayRef, classNames, createPlasmicElementProxy, createUseScreenVariants, deriveRenderOpts, ensureGlobalVariants, genTranslatableString, generateStateOnChangeProp, generateStateValueProp, getDataProps, hasVariant, makeFragment, omit, pick, plasmicHeadMeta, renderPlasmicSlot, setPlumeStrictMode, useButton, useCheckbox, useVanillaDollarState as useDollarState, useIsSSR, useMenu, useMenuButton, useMenuGroup, useMenuItem, useSelect, useSelectOption, useSelectOptionGroup, useSwitch, useTextInput, useTrigger, useTriggeredOverlay, wrapWithClassName };
@@ -3,6 +3,7 @@ export { omit, pick } from "./common";
3
3
  export { HTMLElementRefOf, StrictProps } from "./react-utils";
4
4
  export { createPlasmicElementProxy, deriveRenderOpts, Flex, hasVariant, makeFragment, MultiChoiceArg, SingleBooleanChoiceArg, SingleChoiceArg, wrapWithClassName, } from "./render/elements";
5
5
  export { ensureGlobalVariants } from "./render/global-variants";
6
+ export { PlasmicHead, plasmicHeadMeta } from "./render/PlasmicHead";
6
7
  export { PlasmicIcon } from "./render/PlasmicIcon";
7
8
  export { PlasmicImg } from "./render/PlasmicImg";
8
9
  export { PlasmicLink } from "./render/PlasmicLink";
@@ -10,5 +11,5 @@ export { PlasmicSlot, renderPlasmicSlot } from "./render/PlasmicSlot";
10
11
  export { createUseScreenVariants } from "./render/screen-variants";
11
12
  export { PlasmicRootProvider, useIsSSR } from "./render/ssr";
12
13
  export { Stack } from "./render/Stack";
14
+ export { genTranslatableString, Trans } from "./render/translation";
13
15
  export { useTrigger } from "./render/triggers";
14
- export { Trans, genTranslatableString } from "./render/translation";