@insymetri/styleguide 0.1.81 → 0.1.83
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/IIMenu/IIMenu.svelte +10 -2
- package/dist/IIPopover/IIPopover.svelte +21 -4
- package/dist/IIPopover/IIPopover.svelte.d.ts +11 -1
- package/dist/IIPopover/IIPopoverStories.svelte +21 -0
- package/dist/IIPopover/IIPopoverTriggerProof.svelte +18 -0
- package/dist/IIPopover/IIPopoverTriggerProof.svelte.d.ts +18 -0
- package/package.json +1 -1
|
@@ -283,7 +283,15 @@
|
|
|
283
283
|
return -1
|
|
284
284
|
}
|
|
285
285
|
|
|
286
|
-
|
|
286
|
+
// Named-utility button reset. Avoids `[all:unset]`, which in TW v4 sorts after
|
|
287
|
+
// named utilities and so wins the cascade over any layout classes a consumer
|
|
288
|
+
// passes (clobbering their `display`/padding). These named resets participate
|
|
289
|
+
// in the cascade normally and are overridable via `cn`/tailwind-merge.
|
|
290
|
+
const buttonReset = 'appearance-none bg-transparent border-0 p-0 m-0 text-inherit [font:inherit] outline-none cursor-default'
|
|
291
|
+
// Children triggers own their content layout; default to an inline-flex row so a
|
|
292
|
+
// value + caret sit on one line even when the consumer passes no display class.
|
|
293
|
+
const childrenTriggerClass = `${buttonReset} inline-flex items-center text-left`
|
|
294
|
+
const defaultTriggerClass = `${buttonReset} inline-flex items-center justify-center p-4 rounded-4 text-secondary transition-all duration-fast hover:bg-background hover:text-body data-[state=open]:bg-background data-[state=open]:text-body motion-reduce:transition-none`
|
|
287
295
|
</script>
|
|
288
296
|
|
|
289
297
|
{#snippet itemContent(item: MenuItem)}
|
|
@@ -427,7 +435,7 @@
|
|
|
427
435
|
aria-haspopup="menu"
|
|
428
436
|
aria-expanded={open}
|
|
429
437
|
data-state={open ? 'open' : 'closed'}
|
|
430
|
-
class={cn(children ?
|
|
438
|
+
class={cn(children ? childrenTriggerClass : defaultTriggerClass, triggerClass, className)}
|
|
431
439
|
onclick={toggle}
|
|
432
440
|
onkeydown={handleTriggerKeydown}
|
|
433
441
|
>
|
|
@@ -6,7 +6,15 @@
|
|
|
6
6
|
type Props = {
|
|
7
7
|
open?: boolean
|
|
8
8
|
onOpenChange?: (open: boolean) => void
|
|
9
|
-
|
|
9
|
+
/** Trigger content wrapped in the popover's own button. */
|
|
10
|
+
trigger?: Snippet
|
|
11
|
+
/**
|
|
12
|
+
* Make your own element THE trigger instead of wrapping it in a button.
|
|
13
|
+
* Spread `props` onto a single focusable element — it carries the ref,
|
|
14
|
+
* click/keydown, and popover aria, so there's one tab stop and the element's
|
|
15
|
+
* own focus styling applies. Takes precedence over `trigger`.
|
|
16
|
+
*/
|
|
17
|
+
triggerChild?: Snippet<[{props: Record<string, unknown>}]>
|
|
10
18
|
content: Snippet
|
|
11
19
|
side?: 'top' | 'right' | 'bottom' | 'left'
|
|
12
20
|
align?: 'start' | 'center' | 'end'
|
|
@@ -21,6 +29,7 @@
|
|
|
21
29
|
open = $bindable(false),
|
|
22
30
|
onOpenChange,
|
|
23
31
|
trigger,
|
|
32
|
+
triggerChild,
|
|
24
33
|
content,
|
|
25
34
|
side = 'bottom',
|
|
26
35
|
align = 'start',
|
|
@@ -36,9 +45,17 @@
|
|
|
36
45
|
</script>
|
|
37
46
|
|
|
38
47
|
<Popover.Root bind:open {onOpenChange}>
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
48
|
+
{#if triggerChild}
|
|
49
|
+
<Popover.Trigger>
|
|
50
|
+
{#snippet child({props})}
|
|
51
|
+
{@render triggerChild({props})}
|
|
52
|
+
{/snippet}
|
|
53
|
+
</Popover.Trigger>
|
|
54
|
+
{:else}
|
|
55
|
+
<Popover.Trigger class={cn('[all:unset] cursor-default', triggerClass)}>
|
|
56
|
+
{@render trigger?.()}
|
|
57
|
+
</Popover.Trigger>
|
|
58
|
+
{/if}
|
|
42
59
|
<Popover.Portal>
|
|
43
60
|
<Popover.Content
|
|
44
61
|
{side}
|
|
@@ -2,7 +2,17 @@ import type { Snippet } from 'svelte';
|
|
|
2
2
|
type Props = {
|
|
3
3
|
open?: boolean;
|
|
4
4
|
onOpenChange?: (open: boolean) => void;
|
|
5
|
-
|
|
5
|
+
/** Trigger content wrapped in the popover's own button. */
|
|
6
|
+
trigger?: Snippet;
|
|
7
|
+
/**
|
|
8
|
+
* Make your own element THE trigger instead of wrapping it in a button.
|
|
9
|
+
* Spread `props` onto a single focusable element — it carries the ref,
|
|
10
|
+
* click/keydown, and popover aria, so there's one tab stop and the element's
|
|
11
|
+
* own focus styling applies. Takes precedence over `trigger`.
|
|
12
|
+
*/
|
|
13
|
+
triggerChild?: Snippet<[{
|
|
14
|
+
props: Record<string, unknown>;
|
|
15
|
+
}]>;
|
|
6
16
|
content: Snippet;
|
|
7
17
|
side?: 'top' | 'right' | 'bottom' | 'left';
|
|
8
18
|
align?: 'start' | 'center' | 'end';
|
|
@@ -105,4 +105,25 @@
|
|
|
105
105
|
{/snippet}
|
|
106
106
|
</IIPopover>
|
|
107
107
|
</section>
|
|
108
|
+
|
|
109
|
+
<!-- Custom trigger (single tab stop) -->
|
|
110
|
+
<section>
|
|
111
|
+
<h2 class="text-default-emphasis text-primary mb-8">Custom Trigger (single tab stop)</h2>
|
|
112
|
+
<p class="text-small text-secondary mb-12">
|
|
113
|
+
Use <code>triggerChild</code> and spread <code>props</code> onto your own element so it IS the
|
|
114
|
+
trigger — one tab stop, its own focus ring, keyboard opens it. Unlike <code>trigger</code>
|
|
115
|
+
(wrapped in the popover's button), there's no extra focusable wrapper.
|
|
116
|
+
</p>
|
|
117
|
+
<IIPopover>
|
|
118
|
+
{#snippet triggerChild({props})}
|
|
119
|
+
<IIButton {...props} variant="secondary" size="sm">Open Popover</IIButton>
|
|
120
|
+
{/snippet}
|
|
121
|
+
{#snippet content()}
|
|
122
|
+
<div class="flex flex-col gap-8 w-200 p-12">
|
|
123
|
+
<p class="text-small-emphasis text-body">Single-trigger popover</p>
|
|
124
|
+
<p class="text-small text-secondary">The button above is the only tab stop.</p>
|
|
125
|
+
</div>
|
|
126
|
+
{/snippet}
|
|
127
|
+
</IIPopover>
|
|
128
|
+
</section>
|
|
108
129
|
</div>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import IIPopover from './IIPopover.svelte'
|
|
3
|
+
import {IIButton} from '../IIButton'
|
|
4
|
+
|
|
5
|
+
// Fixture for the play test: `triggerChild` spreads `props` onto the IIButton
|
|
6
|
+
// so it IS the trigger (one tab stop, its own focus ring, keyboard opens).
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<IIPopover>
|
|
10
|
+
{#snippet triggerChild({props})}
|
|
11
|
+
<IIButton {...props} variant="secondary">Open</IIButton>
|
|
12
|
+
{/snippet}
|
|
13
|
+
{#snippet content()}
|
|
14
|
+
<div class="p-12 w-200">
|
|
15
|
+
<p class="text-small text-secondary">Inside the popover.</p>
|
|
16
|
+
</div>
|
|
17
|
+
{/snippet}
|
|
18
|
+
</IIPopover>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
2
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
3
|
+
$$bindings?: Bindings;
|
|
4
|
+
} & Exports;
|
|
5
|
+
(internal: unknown, props: {
|
|
6
|
+
$$events?: Events;
|
|
7
|
+
$$slots?: Slots;
|
|
8
|
+
}): Exports & {
|
|
9
|
+
$set?: any;
|
|
10
|
+
$on?: any;
|
|
11
|
+
};
|
|
12
|
+
z_$$bindings?: Bindings;
|
|
13
|
+
}
|
|
14
|
+
declare const IIPopoverTriggerProof: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
15
|
+
[evt: string]: CustomEvent<any>;
|
|
16
|
+
}, {}, {}, string>;
|
|
17
|
+
type IIPopoverTriggerProof = InstanceType<typeof IIPopoverTriggerProof>;
|
|
18
|
+
export default IIPopoverTriggerProof;
|