drab 2.8.4 → 2.8.6

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.
@@ -1,135 +0,0 @@
1
- import { SvelteComponent } from "svelte";
2
- export type AccordionItem = {
3
- /** text summary of the item */
4
- summary?: string;
5
- /** text content of the item */
6
- content?: string;
7
- /** controls whether the content is displayed */
8
- open?: boolean;
9
- /** any data to pass back to the parent */
10
- [key: string | number]: any;
11
- };
12
- import { type ComponentType } from "svelte";
13
- import { type SlideParams } from "svelte/transition";
14
- declare const __propDef: {
15
- props: {
16
- class?: string | undefined;
17
- id?: string | undefined;
18
- /** data to display in the accordion */ data: AccordionItem[];
19
- icon?: string | ComponentType | undefined;
20
- /** class of the `div` around each `details` element */ classDetails?: string | undefined;
21
- /** class of all the `summary` elements */ classSummary?: string | undefined;
22
- /** class of all the `div`s that wrap the `content` slot */ classContent?: string | undefined;
23
- /** class of the `div` that wraps the icon if displayed */ classIcon?: string | undefined;
24
- /** rotates the icon, slides the content, set to `false` to remove */ transition?: false | SlideParams | undefined;
25
- /** if `true`, other items close when a new one is opened */ autoClose?: boolean | undefined;
26
- };
27
- events: {
28
- [evt: string]: CustomEvent<any>;
29
- };
30
- slots: {
31
- summary: {
32
- item: AccordionItem;
33
- index: any;
34
- };
35
- icon: {
36
- item: AccordionItem;
37
- index: any;
38
- };
39
- content: {
40
- item: AccordionItem;
41
- index: any;
42
- };
43
- };
44
- };
45
- export type AccordionProps = typeof __propDef.props;
46
- export type AccordionEvents = typeof __propDef.events;
47
- export type AccordionSlots = typeof __propDef.slots;
48
- /**
49
- * ### Accordion
50
- *
51
- * Displays a list of `details` elements with helpful defaults and transitions.
52
- *
53
- * @props
54
- *
55
- * - `autoClose` - if `true`, other items close when a new one is opened
56
- * - `classContent` - class of all the `div`s that wrap the `content` slot
57
- * - `classDetails` - class of the `div` around each `details` element
58
- * - `classIcon` - class of the `div` that wraps the icon if displayed
59
- * - `classSummary` - class of all the `summary` elements
60
- * - `class`
61
- * - `data` - data to display in the accordion
62
- * - `icon`
63
- * - `id`
64
- * - `transition` - rotates the icon, slides the content, set to `false` to remove
65
- *
66
- * @slots
67
- *
68
- * | name | purpose | default value | slot props |
69
- * | --------- | ----------------------------- | -------------- | --------------- |
70
- * | `summary` | summary element | `item.summary` | `item`, `index` |
71
- * | `icon` | icon element | `icon` prop | `item`, `index` |
72
- * | `content` | content of the accordion item | `item.content` | `item`, `index` |
73
- *
74
- * @example
75
- *
76
- * ```svelte
77
- * <script lang="ts">
78
- * import { Accordion, type AccordionItem, FullscreenButton } from "drab";
79
- * import Chevron from "../../site/svg/Chevron.svelte";
80
- *
81
- * const data: AccordionItem[] = [
82
- * { summary: "Is it accessible?", content: "Yes." },
83
- * {
84
- * summary: "Is it styled?",
85
- * content: "Nope, style with global styles.",
86
- * },
87
- * {
88
- * summary: "Is it animated?",
89
- * content: "Yes, with the transition prop.",
90
- * },
91
- * {
92
- * summary: "Is it customizable?",
93
- * content: "Yes, customize with slots.",
94
- * class: "uppercase",
95
- * component: FullscreenButton,
96
- * },
97
- * { summary: "Does it work without JavaScript?", content: "Yes." },
98
- * ];
99
- * </script>
100
- *
101
- * <Accordion
102
- * {data}
103
- * icon={Chevron}
104
- * class="mb-12"
105
- * classDetails="border-b"
106
- * classSummary="flex gap-8 cursor-pointer items-center justify-between p-4 font-bold underline hover:decoration-dotted"
107
- * classContent="pb-4 px-4"
108
- * />
109
- *
110
- * <Accordion
111
- * {data}
112
- * icon={Chevron}
113
- * classDetails="border-b"
114
- * classSummary="flex gap-8 cursor-pointer items-center justify-between p-4 font-bold underline hover:decoration-dotted"
115
- * classContent="pb-4 px-4"
116
- * autoClose={false}
117
- * >
118
- * <svelte:fragment slot="summary" let:item let:index>
119
- * <span class={item.class ? item.class : ""}>
120
- * {index + 1}.
121
- * {item.summary}
122
- * </span>
123
- * </svelte:fragment>
124
- * <svelte:fragment slot="content" let:item>
125
- * <span>{item.content}</span>
126
- * {#if item.component === FullscreenButton}
127
- * <div><svelte:component this={FullscreenButton} class="btn mt-4" /></div>
128
- * {/if}
129
- * </svelte:fragment>
130
- * </Accordion>
131
- * ```
132
- */
133
- export default class Accordion extends SvelteComponent<AccordionProps, AccordionEvents, AccordionSlots> {
134
- }
135
- export {};
@@ -1,126 +0,0 @@
1
- <!--
2
- @component
3
-
4
- ### Tabs
5
-
6
- Displays tabs and the selected tab's content.
7
-
8
- @props
9
-
10
- - `classNoscript` - `noscript` class
11
- - `classTabActive` - class of the active tab's `button`
12
- - `classTabInactive` - class of all the inactive tabs' `button`s
13
- - `classTabList` - class of the `div` that wraps the `button`s
14
- - `classTabPanel` - class of `div` that wraps the slotted content
15
- - `classTab` - class of all title `button`s
16
- - `class`
17
- - `data` - provides the content for each tab
18
- - `id`
19
- - `selectedIndex` - index of selected tab, defaults to `0`
20
-
21
- @slots
22
-
23
- | name | purpose | default value | slot props |
24
- | ---------- | -------------------- | --------------- | ---------------------- |
25
- | `tab` | title of each tab | `item.tab` | `item`, `index`, `tab` |
26
- | `tabPanel` | selected tab's panel | `item.tabPanel` | `item`, `index` |
27
-
28
- @example
29
-
30
- ```svelte
31
- <script lang="ts">
32
- import { Tabs, type TabsItem, FullscreenButton } from "drab";
33
-
34
- const data: TabsItem[] = [
35
- { tab: "Tab", tabPanel: "Content" },
36
- {
37
- tab: "Another Tab",
38
- tabPanel: "Some more content",
39
- component: FullscreenButton,
40
- },
41
- ];
42
- </script>
43
-
44
- <Tabs
45
- {data}
46
- class="mb-4"
47
- classTabList="grid grid-flow-col grid-rows-1 gap-1 rounded-md bg-neutral-200 p-1"
48
- classTab="btn btn-s p-2"
49
- classTabActive="bg-white text-neutral-950 shadow"
50
- classTabInactive="bg-neutral-200 text-neutral-600"
51
- classTabPanel="py-2"
52
- />
53
-
54
- <Tabs
55
- {data}
56
- classTabList="grid grid-flow-col grid-rows-1 gap-1 rounded-md bg-neutral-200 p-1"
57
- classTab="btn btn-s p-2"
58
- classTabActive="bg-white text-neutral-950 shadow"
59
- classTabInactive="bg-neutral-200 text-neutral-600"
60
- classTabPanel="py-2"
61
- >
62
- <svelte:fragment slot="tab" let:item let:index>
63
- {index + 1}.
64
- {item.tab}
65
- </svelte:fragment>
66
- <svelte:fragment slot="tabPanel" let:item>
67
- <div>{item.tabPanel}</div>
68
- {#if item.component}
69
- <svelte:component this={item.component} class="btn mt-2" />
70
- {/if}
71
- </svelte:fragment>
72
- </Tabs>
73
- ```
74
- -->
75
-
76
- <script context="module"></script>
77
-
78
- <script>import { onMount } from "svelte";
79
- import { messageNoScript } from "../util/messages";
80
- let className = "";
81
- export { className as class };
82
- export let id = "";
83
- export let classTabList = "";
84
- export let classTab = "";
85
- export let classTabActive = "";
86
- export let classTabInactive = "";
87
- export let classNoscript = "";
88
- export let classTabPanel = "";
89
- export let data;
90
- export let selectedIndex = 0;
91
- let clientJs = false;
92
- const idPanel = "tabPanel-" + Math.random().toString().substring(2, 8);
93
- onMount(() => clientJs = true);
94
- </script>
95
-
96
- <div class={className} {id}>
97
- <div class={classTabList} role="tablist">
98
- {#each data as item, index}
99
- <button
100
- role="tab"
101
- tabindex={index === selectedIndex ? 0 : -1}
102
- aria-selected={index === selectedIndex}
103
- aria-controls={idPanel}
104
- disabled={!clientJs}
105
- class="{classTab} {selectedIndex === index
106
- ? classTabActive
107
- : ''} {selectedIndex !== index ? classTabInactive : ''}"
108
- on:click={() => (selectedIndex = index)}
109
- >
110
- <slot name="tab" {item} {index} tab={item.tab}>{item.tab}</slot>
111
- </button>
112
- {/each}
113
- </div>
114
- {#each data as item, index}
115
- {#if index === selectedIndex}
116
- <div class={classTabPanel} role="tabpanel" id={idPanel}>
117
- <slot name="tabPanel" {item} {index}>
118
- {item.tabPanel}
119
- </slot>
120
- </div>
121
- {/if}
122
- {/each}
123
- <noscript>
124
- <div class={classNoscript}>{messageNoScript}</div>
125
- </noscript>
126
- </div>
@@ -1,115 +0,0 @@
1
- import { SvelteComponent } from "svelte";
2
- export interface TabsItem {
3
- /** tab title, displayed in `button` element */
4
- tab?: string;
5
- /** slotted content, displayed once tab is clicked */
6
- tabPanel?: string;
7
- /** any data to pass back to the parent */
8
- [key: string | number]: any;
9
- }
10
- declare const __propDef: {
11
- props: {
12
- class?: string | undefined;
13
- id?: string | undefined;
14
- /** class of the `div` that wraps the `button`s */ classTabList?: string | undefined;
15
- /** class of all title `button`s */ classTab?: string | undefined;
16
- /** class of the active tab's `button` */ classTabActive?: string | undefined;
17
- /** class of all the inactive tabs' `button`s */ classTabInactive?: string | undefined;
18
- /** `noscript` class */ classNoscript?: string | undefined;
19
- /** class of `div` that wraps the slotted content */ classTabPanel?: string | undefined;
20
- /** provides the content for each tab */ data: TabsItem[];
21
- /** index of selected tab, defaults to `0` */ selectedIndex?: number | undefined;
22
- };
23
- events: {
24
- [evt: string]: CustomEvent<any>;
25
- };
26
- slots: {
27
- tab: {
28
- item: TabsItem;
29
- index: any;
30
- tab: string | undefined;
31
- };
32
- tabPanel: {
33
- item: TabsItem;
34
- index: any;
35
- };
36
- };
37
- };
38
- export type TabsProps = typeof __propDef.props;
39
- export type TabsEvents = typeof __propDef.events;
40
- export type TabsSlots = typeof __propDef.slots;
41
- /**
42
- * ### Tabs
43
- *
44
- * Displays tabs and the selected tab's content.
45
- *
46
- * @props
47
- *
48
- * - `classNoscript` - `noscript` class
49
- * - `classTabActive` - class of the active tab's `button`
50
- * - `classTabInactive` - class of all the inactive tabs' `button`s
51
- * - `classTabList` - class of the `div` that wraps the `button`s
52
- * - `classTabPanel` - class of `div` that wraps the slotted content
53
- * - `classTab` - class of all title `button`s
54
- * - `class`
55
- * - `data` - provides the content for each tab
56
- * - `id`
57
- * - `selectedIndex` - index of selected tab, defaults to `0`
58
- *
59
- * @slots
60
- *
61
- * | name | purpose | default value | slot props |
62
- * | ---------- | -------------------- | --------------- | ---------------------- |
63
- * | `tab` | title of each tab | `item.tab` | `item`, `index`, `tab` |
64
- * | `tabPanel` | selected tab's panel | `item.tabPanel` | `item`, `index` |
65
- *
66
- * @example
67
- *
68
- * ```svelte
69
- * <script lang="ts">
70
- * import { Tabs, type TabsItem, FullscreenButton } from "drab";
71
- *
72
- * const data: TabsItem[] = [
73
- * { tab: "Tab", tabPanel: "Content" },
74
- * {
75
- * tab: "Another Tab",
76
- * tabPanel: "Some more content",
77
- * component: FullscreenButton,
78
- * },
79
- * ];
80
- * </script>
81
- *
82
- * <Tabs
83
- * {data}
84
- * class="mb-4"
85
- * classTabList="grid grid-flow-col grid-rows-1 gap-1 rounded-md bg-neutral-200 p-1"
86
- * classTab="btn btn-s p-2"
87
- * classTabActive="bg-white text-neutral-950 shadow"
88
- * classTabInactive="bg-neutral-200 text-neutral-600"
89
- * classTabPanel="py-2"
90
- * />
91
- *
92
- * <Tabs
93
- * {data}
94
- * classTabList="grid grid-flow-col grid-rows-1 gap-1 rounded-md bg-neutral-200 p-1"
95
- * classTab="btn btn-s p-2"
96
- * classTabActive="bg-white text-neutral-950 shadow"
97
- * classTabInactive="bg-neutral-200 text-neutral-600"
98
- * classTabPanel="py-2"
99
- * >
100
- * <svelte:fragment slot="tab" let:item let:index>
101
- * {index + 1}.
102
- * {item.tab}
103
- * </svelte:fragment>
104
- * <svelte:fragment slot="tabPanel" let:item>
105
- * <div>{item.tabPanel}</div>
106
- * {#if item.component}
107
- * <svelte:component this={item.component} class="btn mt-2" />
108
- * {/if}
109
- * </svelte:fragment>
110
- * </Tabs>
111
- * ```
112
- */
113
- export default class Tabs extends SvelteComponent<TabsProps, TabsEvents, TabsSlots> {
114
- }
115
- export {};
@@ -1 +0,0 @@
1
- export declare const messageNoScript = "JavaScript is disabled on your device. This feature requires JavaScript for full functionality.";
@@ -1 +0,0 @@
1
- export const messageNoScript = "JavaScript is disabled on your device. This feature requires JavaScript for full functionality.";