twintrinsic 0.0.1
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/LICENSE +674 -0
- package/README.md +150 -0
- package/dist/App/App.svelte +54 -0
- package/dist/App/App.svelte.d.ts +65 -0
- package/dist/Section.svelte +25 -0
- package/dist/Section.svelte.d.ts +34 -0
- package/dist/actions/clickOutside.d.ts +9 -0
- package/dist/actions/clickOutside.js +19 -0
- package/dist/actions/index.d.ts +1 -0
- package/dist/actions/index.js +1 -0
- package/dist/components/Accordion/Accordion.svelte +75 -0
- package/dist/components/Accordion/Accordion.svelte.d.ts +39 -0
- package/dist/components/Accordion/AccordionItem.svelte +150 -0
- package/dist/components/Accordion/AccordionItem.svelte.d.ts +30 -0
- package/dist/components/App/App.story.md +8 -0
- package/dist/components/App/App.story.svelte +170 -0
- package/dist/components/App/App.story.svelte.d.ts +22 -0
- package/dist/components/App/App.svelte +77 -0
- package/dist/components/App/App.svelte.d.ts +66 -0
- package/dist/components/App/Split.svelte +346 -0
- package/dist/components/App/Split.svelte.d.ts +54 -0
- package/dist/components/App/index.d.ts +2 -0
- package/dist/components/App/index.js +3 -0
- package/dist/components/AppHeader/AppHeader.svelte +439 -0
- package/dist/components/AppHeader/AppHeader.svelte.d.ts +24 -0
- package/dist/components/Avatar/Avatar.svelte +300 -0
- package/dist/components/Avatar/Avatar.svelte.d.ts +48 -0
- package/dist/components/Avatar/AvatarGroup.svelte +185 -0
- package/dist/components/Avatar/AvatarGroup.svelte.d.ts +46 -0
- package/dist/components/Badge/Badge.svelte +186 -0
- package/dist/components/Badge/Badge.svelte.d.ts +51 -0
- package/dist/components/BottomBar/BottomBar.svelte +146 -0
- package/dist/components/BottomBar/BottomBar.svelte.d.ts +38 -0
- package/dist/components/Breadcrumb/Breadcrumb.svelte +77 -0
- package/dist/components/Breadcrumb/Breadcrumb.svelte.d.ts +42 -0
- package/dist/components/Breadcrumb/BreadcrumbItem.svelte +171 -0
- package/dist/components/Breadcrumb/BreadcrumbItem.svelte.d.ts +38 -0
- package/dist/components/Button/Button.svelte +252 -0
- package/dist/components/Button/Button.svelte.d.ts +80 -0
- package/dist/components/Button/ButtonGroup.svelte +127 -0
- package/dist/components/Button/ButtonGroup.svelte.d.ts +44 -0
- package/dist/components/Card/Card.svelte +152 -0
- package/dist/components/Card/Card.svelte.d.ts +55 -0
- package/dist/components/Carousel/Carousel.svelte +461 -0
- package/dist/components/Carousel/Carousel.svelte.d.ts +79 -0
- package/dist/components/Carousel/CarouselItem.svelte +149 -0
- package/dist/components/Carousel/CarouselItem.svelte.d.ts +35 -0
- package/dist/components/Chip/Chip.svelte +288 -0
- package/dist/components/Chip/Chip.svelte.d.ts +71 -0
- package/dist/components/Chip/ChipGroup.svelte +190 -0
- package/dist/components/Chip/ChipGroup.svelte.d.ts +71 -0
- package/dist/components/CodeBlock/CodeBlock.svelte +356 -0
- package/dist/components/CodeBlock/CodeBlock.svelte.d.ts +44 -0
- package/dist/components/CodeBlock/index.d.ts +1 -0
- package/dist/components/CodeBlock/index.js +1 -0
- package/dist/components/CodeBlockSpeed/CodeBlockSpeed.svelte +145 -0
- package/dist/components/CodeBlockSpeed/CodeBlockSpeed.svelte.d.ts +44 -0
- package/dist/components/CodeEditor/CodeEditor.svelte +229 -0
- package/dist/components/CodeEditor/CodeEditor.svelte.d.ts +23 -0
- package/dist/components/Combobox/Combobox.svelte +279 -0
- package/dist/components/Combobox/Combobox.svelte.d.ts +34 -0
- package/dist/components/Container/Container.svelte +45 -0
- package/dist/components/Container/Container.svelte.d.ts +36 -0
- package/dist/components/DataTable/DataTable.svelte +879 -0
- package/dist/components/DataTable/DataTable.svelte.d.ts +102 -0
- package/dist/components/Form/AutoComplete.svelte +357 -0
- package/dist/components/Form/AutoComplete.svelte.d.ts +73 -0
- package/dist/components/Form/Calendar.svelte +429 -0
- package/dist/components/Form/Calendar.svelte.d.ts +53 -0
- package/dist/components/Form/Checkbox.svelte +196 -0
- package/dist/components/Form/Checkbox.svelte.d.ts +50 -0
- package/dist/components/Form/ColorPicker.svelte +396 -0
- package/dist/components/Form/ColorPicker.svelte.d.ts +43 -0
- package/dist/components/Form/Combobox.svelte +645 -0
- package/dist/components/Form/Combobox.svelte.d.ts +93 -0
- package/dist/components/Form/Dropdown.svelte +773 -0
- package/dist/components/Form/Dropdown.svelte.d.ts +81 -0
- package/dist/components/Form/FileUpload.svelte +796 -0
- package/dist/components/Form/FileUpload.svelte.d.ts +78 -0
- package/dist/components/Form/FloatLabel.svelte +245 -0
- package/dist/components/Form/FloatLabel.svelte.d.ts +44 -0
- package/dist/components/Form/Form.svelte +281 -0
- package/dist/components/Form/Form.svelte.d.ts +54 -0
- package/dist/components/Form/FormField.svelte +218 -0
- package/dist/components/Form/FormField.svelte.d.ts +47 -0
- package/dist/components/Form/Input.svelte +340 -0
- package/dist/components/Form/Input.svelte.d.ts +79 -0
- package/dist/components/Form/InputSwitch.svelte +189 -0
- package/dist/components/Form/InputSwitch.svelte.d.ts +46 -0
- package/dist/components/Form/InvalidState.svelte +97 -0
- package/dist/components/Form/InvalidState.svelte.d.ts +37 -0
- package/dist/components/Form/Knob.svelte +537 -0
- package/dist/components/Form/Knob.svelte.d.ts +78 -0
- package/dist/components/Form/ListInput.svelte +469 -0
- package/dist/components/Form/ListInput.svelte.d.ts +70 -0
- package/dist/components/Form/Listbox.svelte +513 -0
- package/dist/components/Form/Listbox.svelte.d.ts +74 -0
- package/dist/components/Form/NumberInput.svelte +452 -0
- package/dist/components/Form/NumberInput.svelte.d.ts +82 -0
- package/dist/components/Form/Radio.svelte +192 -0
- package/dist/components/Form/Radio.svelte.d.ts +53 -0
- package/dist/components/Form/RadioGroup.svelte +155 -0
- package/dist/components/Form/RadioGroup.svelte.d.ts +48 -0
- package/dist/components/Form/Rating.svelte +380 -0
- package/dist/components/Form/Rating.svelte.d.ts +64 -0
- package/dist/components/Form/Select.svelte +436 -0
- package/dist/components/Form/Select.svelte.d.ts +49 -0
- package/dist/components/Form/SelectGroup.svelte +34 -0
- package/dist/components/Form/SelectGroup.svelte.d.ts +33 -0
- package/dist/components/Form/Slider.svelte +622 -0
- package/dist/components/Form/Slider.svelte.d.ts +73 -0
- package/dist/components/Form/Switch.svelte +192 -0
- package/dist/components/Form/Switch.svelte.d.ts +46 -0
- package/dist/components/Form/TextInput.svelte +274 -0
- package/dist/components/Form/TextInput.svelte.d.ts +74 -0
- package/dist/components/Form/Textarea.svelte +207 -0
- package/dist/components/Form/Textarea.svelte.d.ts +62 -0
- package/dist/components/Icon/Icon.svelte +140 -0
- package/dist/components/Icon/Icon.svelte.d.ts +25 -0
- package/dist/components/Icon/index.d.ts +1 -0
- package/dist/components/Icon/index.js +1 -0
- package/dist/components/Lazy/Lazy.svelte +158 -0
- package/dist/components/Lazy/Lazy.svelte.d.ts +42 -0
- package/dist/components/Masonry/Masonry.svelte +299 -0
- package/dist/components/Masonry/Masonry.svelte.d.ts +55 -0
- package/dist/components/Menu/Menu/Menu.svelte +65 -0
- package/dist/components/Menu/Menu/Menu.svelte.d.ts +17 -0
- package/dist/components/Menu/Menu/MenuItem.svelte +90 -0
- package/dist/components/Menu/Menu/MenuItem.svelte.d.ts +27 -0
- package/dist/components/Modal/Modal.svelte +334 -0
- package/dist/components/Modal/Modal.svelte.d.ts +55 -0
- package/dist/components/Panel/Card.svelte +141 -0
- package/dist/components/Panel/Card.svelte.d.ts +52 -0
- package/dist/components/Panel/Hero/Hero.story.md +9 -0
- package/dist/components/Panel/Hero/Hero.story.svelte +49 -0
- package/dist/components/Panel/Hero/Hero.story.svelte.d.ts +21 -0
- package/dist/components/Panel/Hero/Hero.svelte +24 -0
- package/dist/components/Panel/Hero/Hero.svelte.d.ts +32 -0
- package/dist/components/Panel/LazyPanel.svelte +110 -0
- package/dist/components/Panel/LazyPanel.svelte.d.ts +46 -0
- package/dist/components/Panel/Panel.svelte +205 -0
- package/dist/components/Panel/Panel.svelte.d.ts +23 -0
- package/dist/components/Progress/Progress.svelte +220 -0
- package/dist/components/Progress/Progress.svelte.d.ts +61 -0
- package/dist/components/Separator/Separator.svelte +109 -0
- package/dist/components/Separator/Separator.svelte.d.ts +35 -0
- package/dist/components/Sidebar/Sidebar.svelte +213 -0
- package/dist/components/Sidebar/Sidebar.svelte.d.ts +60 -0
- package/dist/components/Skeleton/Skeleton.svelte +170 -0
- package/dist/components/Skeleton/Skeleton.svelte.d.ts +48 -0
- package/dist/components/Stepper/Stepper.svelte +111 -0
- package/dist/components/Stepper/Stepper.svelte.d.ts +54 -0
- package/dist/components/Stepper/StepperStep.svelte +369 -0
- package/dist/components/Stepper/StepperStep.svelte.d.ts +63 -0
- package/dist/components/Table/Table.svelte +167 -0
- package/dist/components/Table/Table.svelte.d.ts +56 -0
- package/dist/components/Table/TableBody.svelte +41 -0
- package/dist/components/Table/TableBody.svelte.d.ts +33 -0
- package/dist/components/Table/TableCell.svelte +76 -0
- package/dist/components/Table/TableCell.svelte.d.ts +36 -0
- package/dist/components/Table/TableHead.svelte +41 -0
- package/dist/components/Table/TableHead.svelte.d.ts +32 -0
- package/dist/components/Table/TableHeader.svelte +148 -0
- package/dist/components/Table/TableHeader.svelte.d.ts +42 -0
- package/dist/components/Table/TableRow.svelte +99 -0
- package/dist/components/Table/TableRow.svelte.d.ts +40 -0
- package/dist/components/Tabs/Tab.svelte +145 -0
- package/dist/components/Tabs/Tab.svelte.d.ts +36 -0
- package/dist/components/Tabs/TabList.svelte +60 -0
- package/dist/components/Tabs/TabList.svelte.d.ts +32 -0
- package/dist/components/Tabs/TabPanel.svelte +118 -0
- package/dist/components/Tabs/TabPanel.svelte.d.ts +38 -0
- package/dist/components/Tabs/Tabs.svelte +287 -0
- package/dist/components/Tabs/Tabs.svelte.d.ts +50 -0
- package/dist/components/Tag/Tag.svelte +260 -0
- package/dist/components/Tag/Tag.svelte.d.ts +54 -0
- package/dist/components/Tag/TagGroup.svelte +147 -0
- package/dist/components/Tag/TagGroup.svelte.d.ts +62 -0
- package/dist/components/ThemeToggle/ThemeToggle.svelte +93 -0
- package/dist/components/ThemeToggle/ThemeToggle.svelte.d.ts +12 -0
- package/dist/components/Timeline/Timeline.svelte +144 -0
- package/dist/components/Timeline/Timeline.svelte.d.ts +48 -0
- package/dist/components/Timeline/TimelineItem.svelte +391 -0
- package/dist/components/Timeline/TimelineItem.svelte.d.ts +63 -0
- package/dist/components/Toast/Toast.svelte +313 -0
- package/dist/components/Toast/Toast.svelte.d.ts +44 -0
- package/dist/components/Toast/toastStore.d.ts +40 -0
- package/dist/components/Toast/toastStore.js +293 -0
- package/dist/components/Tooltip/Tooltip.svelte +282 -0
- package/dist/components/Tooltip/Tooltip.svelte.d.ts +55 -0
- package/dist/components/Tree/Tree.svelte +129 -0
- package/dist/components/Tree/Tree.svelte.d.ts +61 -0
- package/dist/components/Tree/TreeNode.svelte +332 -0
- package/dist/components/Tree/TreeNode.svelte.d.ts +55 -0
- package/dist/components/icons/TwintrinsicLogo.svelte +73 -0
- package/dist/components/icons/TwintrinsicLogo.svelte.d.ts +17 -0
- package/dist/components/icons/twintrinsic-source.svg +73 -0
- package/dist/components/icons/twintrinsic.svg +38 -0
- package/dist/docs/EventsTable.svelte +86 -0
- package/dist/docs/EventsTable.svelte.d.ts +27 -0
- package/dist/docs/PropsTable.svelte +103 -0
- package/dist/docs/PropsTable.svelte.d.ts +28 -0
- package/dist/docs/index.d.ts +2 -0
- package/dist/docs/index.js +2 -0
- package/dist/helpers/detectLanguage.d.ts +6 -0
- package/dist/helpers/detectLanguage.js +60 -0
- package/dist/helpers/index.d.ts +1 -0
- package/dist/helpers/index.js +1 -0
- package/dist/index.d.ts +86 -0
- package/dist/index.js +94 -0
- package/dist/twintrinsic.css +347 -0
- package/package.json +98 -0
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { HstSvelte as Histoire } from "@histoire/plugin-svelte"
|
|
3
|
+
export let Hst: Histoire
|
|
4
|
+
import App from "./App.svelte"
|
|
5
|
+
|
|
6
|
+
let appName = "Twintrinsic Histoire App"
|
|
7
|
+
let mainContent = `Lorem ipsum dolor sit amet consectetur adipisicing elit. Veniam hic ipsa, quia labore assumenda quo aperiam! Harum, reiciendis nihil ad nostrum temporibus in et, nulla, facilis cumque itaque maxime laboriosam. Lorem ipsum dolor sit amet consectetur adipisicing elit. Praesentium sequi in maiores eum modi veniam porro quas! Dolore magnam nulla explicabo itaque. Cupiditate, quidem! Adipisci iusto cum odit magni consequuntur.
|
|
8
|
+
Porro veritatis culpa odio vel ullam excepturi amet? Repudiandae dignissimos ullam beatae unde cum inventore, recusandae dolore delectus quaerat reprehenderit doloribus officia, magnam asperiores neque expedita maxime eum, cumque voluptatibus.
|
|
9
|
+
Et ipsa facere numquam. Nulla perspiciatis repellendus distinctio temporibus, rerum a, odit corporis beatae qui sequi suscipit voluptatum quibusdam voluptatem laborum dolores consectetur! Laboriosam totam quaerat ab, exercitationem doloribus sunt.
|
|
10
|
+
Lorem ipsum dolor sit amet consectetur adipisicing elit. Possimus ullam, a similique autem dolorem esse voluptatibus repudiandae! Ipsam est ea accusamus? Dolore iusto amet, hic in nam odio necessitatibus? Odio.
|
|
11
|
+
Excepturi aut, facilis, voluptas assumenda, ullam saepe deserunt delectus dicta recusandae natus error nisi libero esse optio odit voluptatibus accusamus molestias sunt non doloribus placeat. Aut neque a nemo fugiat?
|
|
12
|
+
Harum error corrupti nobis quam laborum a beatae quibusdam minima aliquam ad ipsa, quo, veniam quos fuga earum, hic aspernatur exercitationem esse iure eum expedita! Officia aperiam laboriosam reiciendis consequatur!
|
|
13
|
+
Fuga inventore adipisci culpa laborum doloribus cum corrupti non impedit iste distinctio unde modi aut atque quam tenetur nam veniam aliquam est iure laudantium quos, perspiciatis magnam a fugiat. Fugit?
|
|
14
|
+
Rerum molestiae qui accusamus molestias incidunt debitis ut nobis delectus facere amet, inventore repellendus laboriosam magnam assumenda officiis optio error voluptates eum nisi sequi est id! Cum repellat magni rem.
|
|
15
|
+
Quibusdam doloribus laudantium culpa totam vel est deserunt perspiciatis labore, saepe quasi laboriosam, reiciendis, pariatur quas? Veritatis facere ad autem obcaecati? Tempore cumque nisi beatae dolor sint blanditiis necessitatibus corrupti.
|
|
16
|
+
Velit necessitatibus amet fugit quaerat placeat? Doloribus nam ducimus beatae, adipisci officiis aut quo, cupiditate quas mollitia eveniet dolore omnis quam, fuga odit voluptas sunt ex ea molestiae harum labore.
|
|
17
|
+
Necessitatibus magnam officiis natus voluptatem in, modi praesentium vero vitae beatae a quasi consequatur doloribus omnis deserunt quibusdam soluta similique corporis tenetur dicta consectetur at doloremque aspernatur. Accusamus, quos culpa.
|
|
18
|
+
Quis veritatis consequatur, error voluptates eos odio deserunt iste illo tempore? Exercitationem aut dolor id quia eos provident nobis laborum, illum porro sunt asperiores magnam, voluptas voluptatibus! Eveniet, neque enim.
|
|
19
|
+
Odio non reiciendis enim velit? Dicta numquam cumque quidem culpa quia dolore non fugit. Autem quibusdam, vitae aspernatur maiores consectetur commodi voluptas adipisci asperiores voluptatum, nemo, quam dolor? Eaque, explicabo!
|
|
20
|
+
Magni, aperiam rerum iste saepe voluptatum, amet numquam neque consequuntur, nihil laudantium eos? Quis nulla ex molestiae vero officia illo, voluptas aut repudiandae mollitia nostrum eveniet temporibus dolor officiis at!
|
|
21
|
+
Modi perferendis mollitia autem minima debitis quae sint adipisci. Iste, eius! In ab nam, aperiam reiciendis exercitationem libero quo deleniti blanditiis consequuntur aut dolores. Sint placeat blanditiis perspiciatis nisi et.
|
|
22
|
+
Sunt similique voluptatibus pariatur totam iste quaerat delectus modi voluptatem laudantium tempore numquam maiores doloribus harum excepturi blanditiis, sint fuga optio deleniti nemo molestiae incidunt. Ea esse quis nam facilis.
|
|
23
|
+
Vero illum amet enim, nisi quia cupiditate labore. Sequi neque alias ipsum perferendis quas blanditiis incidunt, vel quaerat reprehenderit corporis natus repellat ipsam fuga nisi cupiditate. Ducimus voluptatum hic perspiciatis?
|
|
24
|
+
Asperiores dolore distinctio unde vitae, doloremque esse doloribus delectus dignissimos nostrum velit natus vel at maiores a? Ipsam excepturi, beatae quis impedit modi aspernatur eius eos voluptas ab, magnam sint.
|
|
25
|
+
Itaque vitae dignissimos ex natus neque illo rerum quidem est at consequuntur fugiat excepturi, id expedita alias vero? Deserunt dolor eum temporibus! Voluptatum ipsam quidem, numquam necessitatibus aliquid rerum ullam.
|
|
26
|
+
Asperiores odit esse voluptate eveniet hic, autem quos repellat! Ex mollitia cupiditate atque esse deleniti repudiandae neque alias nesciunt aperiam consectetur magnam magni quis, consequuntur ea architecto? Omnis, aspernatur cum!
|
|
27
|
+
Doloremque officiis quia fugit deserunt necessitatibus aliquid laboriosam velit esse ipsam? Nam doloremque magni esse praesentium odio quasi inventore! Aspernatur veniam sed doloribus harum temporibus voluptatem iusto amet vero tempora?
|
|
28
|
+
Odit incidunt nemo blanditiis ratione tenetur harum sequi quidem. Minima, sunt sed voluptas nam inventore a obcaecati asperiores, maiores nesciunt aliquam, magnam iste molestias aperiam tenetur corrupti perspiciatis accusantium officia.
|
|
29
|
+
Maxime dolorem praesentium assumenda facere beatae non obcaecati iste architecto magni alias, culpa temporibus a dolorum tenetur doloribus modi itaque quod distinctio earum suscipit quibusdam et. Sunt voluptatibus est et!
|
|
30
|
+
Quis eum non tenetur eius velit. Nobis debitis, molestias, a quia aliquid sequi sapiente non aut beatae itaque animi, magnam incidunt mollitia ipsum accusamus quis eos eveniet ducimus iste ipsa.
|
|
31
|
+
Aliquam ipsam placeat sint est, quam magni labore aspernatur asperiores! Voluptates ratione quam animi totam ad. Ducimus fugit alias a excepturi architecto voluptas, laboriosam repudiandae nemo aliquam voluptatem tempora nihil!
|
|
32
|
+
Nemo laboriosam, impedit quasi, inventore quis, perspiciatis illum quod nam cum consequuntur officiis? Ducimus, excepturi? Aut velit, odio mollitia, non quae placeat magni consequuntur recusandae pariatur nihil quia perferendis veniam?
|
|
33
|
+
Consectetur porro, possimus vel obcaecati numquam iste a ut unde est odit eos molestiae accusantium autem ea nam harum, quasi deleniti illum? Dignissimos, praesentium repellendus iste quam officiis soluta tempore.
|
|
34
|
+
Debitis eius dolore, ex ratione fugiat est aspernatur? Qui, eos dicta! Molestiae dolorem quae, nihil delectus illum vero dolor explicabo, pariatur praesentium fugit iusto ullam reiciendis veritatis, eius saepe dolore.
|
|
35
|
+
Dicta sit placeat doloribus tempora, veniam aperiam nam doloremque. Aspernatur sed accusamus beatae quae corrupti officia possimus at ad amet, adipisci cupiditate reiciendis tenetur, magni sit totam nemo animi quisquam.
|
|
36
|
+
Deserunt numquam deleniti doloremque quae odit ipsa perspiciatis, voluptatibus cum eos facilis accusamus asperiores omnis recusandae unde ratione officiis quas similique reiciendis aspernatur eligendi expedita molestiae! Atque veniam aperiam dolor?
|
|
37
|
+
Expedita earum vitae pariatur delectus eveniet, voluptates natus mollitia adipisci aperiam eligendi, reiciendis soluta nisi officiis eum. Officia numquam possimus, alias suscipit iusto dicta soluta quidem mollitia in sed doloremque?
|
|
38
|
+
Veniam optio quae iusto dolore perspiciatis exercitationem, sint sit repudiandae illo vero ut atque doloremque, consectetur numquam ratione nam nisi fuga dignissimos soluta sunt praesentium iure maiores? Illo, excepturi corrupti?
|
|
39
|
+
Illo voluptatibus eos sed iusto voluptatem amet aliquam beatae culpa possimus earum vel maxime nihil quod necessitatibus quasi laborum accusamus quam labore nostrum, ea pariatur distinctio. Laboriosam numquam quod rerum.
|
|
40
|
+
Magnam excepturi quo non explicabo dignissimos, cupiditate nostrum esse officiis quisquam id molestiae eveniet incidunt provident dolorem error eius quidem reprehenderit illum quae vel consequatur debitis iusto! Aliquam, ea repellendus.
|
|
41
|
+
Velit veritatis inventore ut corporis qui vero, rem blanditiis, nihil magni odit excepturi atque, quisquam animi. Vero atque sapiente possimus quis magnam aperiam, earum deserunt fugiat quas omnis est aspernatur! Lorem ipsum dolor sit amet consectetur adipisicing elit. Vel est nemo fugiat delectus perferendis adipisci maiores optio cupiditate hic ipsam dignissimos in quasi ea, minima, ut, reprehenderit quos tempora inventore.`
|
|
42
|
+
let menuContent =
|
|
43
|
+
"Lorem ipsum dolor sit amet consectetur adipisicing elit. Vel est nemo fugiat delectus perferendis adipisci maiores optio cupiditate hic ipsam dignissimos in quasi ea, minima, ut, reprehenderit quos tempora inventore."
|
|
44
|
+
let headerContent =
|
|
45
|
+
"Lorem ipsum dolor sit amet consectetur adipisicing elit. Vel est nemo fugiat delectus perferendis adipisci maiores optio cupiditate hic ipsam dignissimos in quasi ea, minima, ut, reprehenderit quos tempora inventore."
|
|
46
|
+
let rightContent =
|
|
47
|
+
"Lorem ipsum dolor sit amet consectetur adipisicing elit. Vel est nemo fugiat delectus perferendis adipisci maiores optio cupiditate hic ipsam dignissimos in quasi ea, minima, ut, reprehenderit quos tempora inventore."
|
|
48
|
+
let leftContent =
|
|
49
|
+
"Lorem ipsum dolor sit amet consectetur adipisicing elit. Vel est nemo fugiat delectus perferendis adipisci maiores optio cupiditate hic ipsam dignissimos in quasi ea, minima, ut, reprehenderit quos tempora inventore."
|
|
50
|
+
let footerContent =
|
|
51
|
+
"Lorem ipsum dolor sit amet consectetur adipisicing elit. Vel est nemo fugiat delectus perferendis adipisci maiores optio cupiditate hic ipsam dignissimos in quasi ea, minima, ut, reprehenderit quos tempora inventore."
|
|
52
|
+
let darkMode = false
|
|
53
|
+
let menu = {
|
|
54
|
+
"Hide Left Panel": () => {
|
|
55
|
+
leftContent = ""
|
|
56
|
+
},
|
|
57
|
+
"Show Left Panel": () => {
|
|
58
|
+
leftContent =
|
|
59
|
+
"Lorem ipsum dolor sit amet consectetur adipisicing elit. Vel est nemo fugiat delectus perferendis adipisci maiores optio cupiditate hic ipsam dignissimos in quasi ea, minima, ut, reprehenderit quos tempora inventore."
|
|
60
|
+
},
|
|
61
|
+
"Hide Right Panel": () => {
|
|
62
|
+
rightContent = ""
|
|
63
|
+
},
|
|
64
|
+
"Show Right Panel": () => {
|
|
65
|
+
rightContent =
|
|
66
|
+
"Lorem ipsum dolor sit amet consectetur adipisicing elit. Vel est nemo fugiat delectus perferendis adipisci maiores optio cupiditate hic ipsam dignissimos in quasi ea, minima, ut, reprehenderit quos tempora inventore."
|
|
67
|
+
},
|
|
68
|
+
"Hide Header": () => {
|
|
69
|
+
headerContent = ""
|
|
70
|
+
},
|
|
71
|
+
"Show Header": () => {
|
|
72
|
+
headerContent =
|
|
73
|
+
"Lorem ipsum dolor sit amet consectetur adipisicing elit. Vel est nemo fugiat delectus perferendis adipisci maiores optio cupiditate hic ipsam dignissimos in quasi ea, minima, ut, reprehenderit quos tempora inventore."
|
|
74
|
+
},
|
|
75
|
+
"Hide Footer": () => {
|
|
76
|
+
footerContent = ""
|
|
77
|
+
},
|
|
78
|
+
"Show Footer": () => {
|
|
79
|
+
footerContent =
|
|
80
|
+
"Lorem ipsum dolor sit amet consectetur adipisicing elit. Vel est nemo fugiat delectus perferendis adipisci maiores optio cupiditate hic ipsam dignissimos in quasi ea, minima, ut, reprehenderit quos tempora inventore."
|
|
81
|
+
},
|
|
82
|
+
"Hide Menu": () => {
|
|
83
|
+
menuContent = ""
|
|
84
|
+
},
|
|
85
|
+
"Show Menu": () => {
|
|
86
|
+
menuContent =
|
|
87
|
+
"Lorem ipsum dolor sit amet consectetur adipisicing elit. Vel est nemo fugiat delectus perferendis adipisci maiores optio cupiditate hic ipsam dignissimos in quasi ea, minima, ut, reprehenderit quos tempora inventore."
|
|
88
|
+
},
|
|
89
|
+
"Hide Main": () => {
|
|
90
|
+
mainContent = ""
|
|
91
|
+
},
|
|
92
|
+
}
|
|
93
|
+
</script>
|
|
94
|
+
|
|
95
|
+
<Hst.Story title="App/App" layout={{ type: 'single' }} icon="lucide:layout">
|
|
96
|
+
<svelte:fragment slot="controls">
|
|
97
|
+
<Hst.Text bind:value={appName} title="App Name" />
|
|
98
|
+
<!-- <Hst.Checkbox bind:value={darkMode} title="Dark Mode" /> -->
|
|
99
|
+
<Hst.Text bind:value={menuContent} title="Menu Content" />
|
|
100
|
+
<Hst.Text bind:value={leftContent} title="Left Content" />
|
|
101
|
+
<Hst.Text bind:value={rightContent} title="Right Content" />
|
|
102
|
+
<Hst.Text bind:value={mainContent} title="Main Content" />
|
|
103
|
+
<Hst.Text bind:value={headerContent} title="Header Content" />
|
|
104
|
+
</svelte:fragment>
|
|
105
|
+
|
|
106
|
+
<Hst.Variant title="Light Mode" source="<App>{mainContent}</App>">
|
|
107
|
+
<App {appName}
|
|
108
|
+
>{window.matchMedia('(prefers-color-scheme: dark)').matches} {darkMode} {mainContent}</App
|
|
109
|
+
>
|
|
110
|
+
</Hst.Variant>
|
|
111
|
+
|
|
112
|
+
<Hst.Variant title="Dark Mode" source="<App>{mainContent}</App>">
|
|
113
|
+
<div class="dark">
|
|
114
|
+
<App {appName}
|
|
115
|
+
>{window.matchMedia('(prefers-color-scheme: dark)').matches} {darkMode} {mainContent}</App
|
|
116
|
+
>
|
|
117
|
+
</div>
|
|
118
|
+
</Hst.Variant>
|
|
119
|
+
|
|
120
|
+
<Hst.Variant title="Left Panel" source="<App>{mainContent}</App>">
|
|
121
|
+
<App {appName}>
|
|
122
|
+
<div slot="leftPanel">
|
|
123
|
+
{leftContent}
|
|
124
|
+
</div>
|
|
125
|
+
{mainContent}
|
|
126
|
+
</App>
|
|
127
|
+
</Hst.Variant>
|
|
128
|
+
|
|
129
|
+
<Hst.Variant title="Right Panel" source="<App>{mainContent}</App>">
|
|
130
|
+
<App {appName}>
|
|
131
|
+
{mainContent}
|
|
132
|
+
<div slot="rightPanel">
|
|
133
|
+
{rightContent}
|
|
134
|
+
</div>
|
|
135
|
+
</App>
|
|
136
|
+
</Hst.Variant>
|
|
137
|
+
|
|
138
|
+
<Hst.Variant title="Both Panels" source="<App>{mainContent}</App>">
|
|
139
|
+
<App {appName}>
|
|
140
|
+
<div slot="leftPanel">
|
|
141
|
+
{leftContent}
|
|
142
|
+
</div>
|
|
143
|
+
{mainContent}
|
|
144
|
+
<div slot="rightPanel">
|
|
145
|
+
{rightContent}
|
|
146
|
+
</div>
|
|
147
|
+
</App>
|
|
148
|
+
</Hst.Variant>
|
|
149
|
+
|
|
150
|
+
<Hst.Variant title="Header with Both Panels" source="<App>{mainContent}</App>">
|
|
151
|
+
<App {appName}>
|
|
152
|
+
<div slot="header">
|
|
153
|
+
{headerContent}
|
|
154
|
+
</div>
|
|
155
|
+
<div slot="menu" {menu}>
|
|
156
|
+
{menuContent}
|
|
157
|
+
</div>
|
|
158
|
+
<div slot="leftPanel">
|
|
159
|
+
{leftContent}
|
|
160
|
+
</div>
|
|
161
|
+
{mainContent}
|
|
162
|
+
<div slot="rightPanel">
|
|
163
|
+
{rightContent}
|
|
164
|
+
</div>
|
|
165
|
+
<div slot="footer">
|
|
166
|
+
{footerContent}
|
|
167
|
+
</div>
|
|
168
|
+
</App>
|
|
169
|
+
</Hst.Variant>
|
|
170
|
+
</Hst.Story>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { HstSvelte as Histoire } from "@histoire/plugin-svelte";
|
|
2
|
+
import App from "./App.svelte";
|
|
3
|
+
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> {
|
|
4
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
5
|
+
$$bindings?: Bindings;
|
|
6
|
+
} & Exports;
|
|
7
|
+
(internal: unknown, props: Props & {
|
|
8
|
+
$$events?: Events;
|
|
9
|
+
$$slots?: Slots;
|
|
10
|
+
}): Exports & {
|
|
11
|
+
$set?: any;
|
|
12
|
+
$on?: any;
|
|
13
|
+
};
|
|
14
|
+
z_$$bindings?: Bindings;
|
|
15
|
+
}
|
|
16
|
+
declare const App: $$__sveltets_2_IsomorphicComponent<{
|
|
17
|
+
Hst: Histoire;
|
|
18
|
+
}, {
|
|
19
|
+
[evt: string]: CustomEvent<any>;
|
|
20
|
+
}, {}, {}, string>;
|
|
21
|
+
type App = InstanceType<typeof App>;
|
|
22
|
+
export default App;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { setContext } from "svelte"
|
|
3
|
+
|
|
4
|
+
const {
|
|
5
|
+
darkMode = false,
|
|
6
|
+
appName = "Twintrinsic App",
|
|
7
|
+
leftPanelWidth = "300px",
|
|
8
|
+
rightPanelWidth = "300px",
|
|
9
|
+
} = $props()
|
|
10
|
+
|
|
11
|
+
$effect(() => {
|
|
12
|
+
setContext("appDarkMode", {
|
|
13
|
+
getDarkMode: () => darkMode,
|
|
14
|
+
})
|
|
15
|
+
})
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<svelte:head>
|
|
19
|
+
<title>{appName}</title>
|
|
20
|
+
</svelte:head>
|
|
21
|
+
<!-- <svelte:body class="{darkMode ? "dark" : "light"}"/> -->
|
|
22
|
+
<div class='app bg-element-100 dark:bg-dark dark:text-light min-h-screen' data-theme style="--left-panel-width: {leftPanelWidth}; --right-panel-width: {rightPanelWidth};">
|
|
23
|
+
{#if $$slots.menu}
|
|
24
|
+
<div class="appMenu">
|
|
25
|
+
<slot name="menu"/>
|
|
26
|
+
</div>
|
|
27
|
+
{/if}
|
|
28
|
+
{#if $$slots.header}
|
|
29
|
+
<div class="appHeader">
|
|
30
|
+
<slot name="header"/>
|
|
31
|
+
</div>
|
|
32
|
+
{/if}
|
|
33
|
+
<div class="appWrapper w-full flex flex-col sm:flex-row flex-wrap sm:flex-nowrap py-4 grow">
|
|
34
|
+
{#if $$slots.leftPanel}
|
|
35
|
+
<div class="appLeftPanel shrink-0 px-4">
|
|
36
|
+
<div class="sticky top-0 p-4 w-full h-full">
|
|
37
|
+
<slot name="leftPanel"/>
|
|
38
|
+
</div>
|
|
39
|
+
</div>
|
|
40
|
+
{/if}
|
|
41
|
+
<main role="main" class="appMain w-full grow pt-1 px-3">
|
|
42
|
+
<slot/>
|
|
43
|
+
</main>
|
|
44
|
+
{#if $$slots.rightPanel}
|
|
45
|
+
<div class="appRightPanel shrink-0 px-2">
|
|
46
|
+
<!-- fixed-width -->
|
|
47
|
+
<div class="flex sm:flex-col px-2">
|
|
48
|
+
<slot name="rightPanel"/>
|
|
49
|
+
</div>
|
|
50
|
+
</div>
|
|
51
|
+
{/if}
|
|
52
|
+
</div>
|
|
53
|
+
{#if $$slots.footer}
|
|
54
|
+
<footer class="bg-black mt-auto">
|
|
55
|
+
<slot name="footer"/>
|
|
56
|
+
</footer>
|
|
57
|
+
{/if}
|
|
58
|
+
</div>
|
|
59
|
+
|
|
60
|
+
<style>
|
|
61
|
+
@reference '../../twintrinsic.css';
|
|
62
|
+
|
|
63
|
+
.appLeftPanel {
|
|
64
|
+
width: var(--left-panel-width);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.appRightPanel {
|
|
68
|
+
width: var(--right-panel-width);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
@media (max-width: 640px) {
|
|
72
|
+
.appLeftPanel,
|
|
73
|
+
.appRightPanel {
|
|
74
|
+
width: 100%;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
</style>
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
export default App;
|
|
2
|
+
type App = SvelteComponent<$$__sveltets_2_PropsWithChildren<$$ComponentProps, {
|
|
3
|
+
menu: {};
|
|
4
|
+
header: {};
|
|
5
|
+
leftPanel: {};
|
|
6
|
+
default: {};
|
|
7
|
+
rightPanel: {};
|
|
8
|
+
footer: {};
|
|
9
|
+
}>, {
|
|
10
|
+
[evt: string]: CustomEvent<any>;
|
|
11
|
+
}, {
|
|
12
|
+
menu: {};
|
|
13
|
+
header: {};
|
|
14
|
+
leftPanel: {};
|
|
15
|
+
default: {};
|
|
16
|
+
rightPanel: {};
|
|
17
|
+
footer: {};
|
|
18
|
+
}> & {
|
|
19
|
+
$$bindings?: "" | undefined;
|
|
20
|
+
};
|
|
21
|
+
declare const App: $$__sveltets_2_IsomorphicComponent<$$__sveltets_2_PropsWithChildren<{
|
|
22
|
+
darkMode?: boolean;
|
|
23
|
+
appName?: string;
|
|
24
|
+
leftPanelWidth?: string;
|
|
25
|
+
rightPanelWidth?: string;
|
|
26
|
+
}, {
|
|
27
|
+
menu: {};
|
|
28
|
+
header: {};
|
|
29
|
+
leftPanel: {};
|
|
30
|
+
default: {};
|
|
31
|
+
rightPanel: {};
|
|
32
|
+
footer: {};
|
|
33
|
+
}>, {
|
|
34
|
+
[evt: string]: CustomEvent<any>;
|
|
35
|
+
}, {
|
|
36
|
+
menu: {};
|
|
37
|
+
header: {};
|
|
38
|
+
leftPanel: {};
|
|
39
|
+
default: {};
|
|
40
|
+
rightPanel: {};
|
|
41
|
+
footer: {};
|
|
42
|
+
}, {}, "">;
|
|
43
|
+
type $$ComponentProps = {
|
|
44
|
+
darkMode?: boolean;
|
|
45
|
+
appName?: string;
|
|
46
|
+
leftPanelWidth?: string;
|
|
47
|
+
rightPanelWidth?: string;
|
|
48
|
+
};
|
|
49
|
+
type $$__sveltets_2_PropsWithChildren<Props, Slots> = Props & (Slots extends {
|
|
50
|
+
default: any;
|
|
51
|
+
} ? Props extends Record<string, never> ? any : {
|
|
52
|
+
children?: any;
|
|
53
|
+
} : {});
|
|
54
|
+
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> {
|
|
55
|
+
new (options: import("svelte").ComponentConstructorOptions<Props>): import("svelte").SvelteComponent<Props, Events, Slots> & {
|
|
56
|
+
$$bindings?: Bindings;
|
|
57
|
+
} & Exports;
|
|
58
|
+
(internal: unknown, props: Props & {
|
|
59
|
+
$$events?: Events;
|
|
60
|
+
$$slots?: Slots;
|
|
61
|
+
}): Exports & {
|
|
62
|
+
$set?: any;
|
|
63
|
+
$on?: any;
|
|
64
|
+
};
|
|
65
|
+
z_$$bindings?: Bindings;
|
|
66
|
+
}
|
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
@component
|
|
3
|
+
Split - A component for creating resizable split panels in an IDE-style layout.
|
|
4
|
+
Supports horizontal or vertical splitting with draggable dividers and keyboard controls.
|
|
5
|
+
|
|
6
|
+
Usage:
|
|
7
|
+
```svelte
|
|
8
|
+
<Split>
|
|
9
|
+
<div slot="first">First panel content</div>
|
|
10
|
+
<div slot="second">Second panel content</div>
|
|
11
|
+
</Split>
|
|
12
|
+
|
|
13
|
+
<Split direction="vertical" initialSize={30} minSize={20} maxSize={80}>
|
|
14
|
+
<div slot="first">Top panel</div>
|
|
15
|
+
<div slot="second">Bottom panel</div>
|
|
16
|
+
</Split>
|
|
17
|
+
```
|
|
18
|
+
-->
|
|
19
|
+
<script>
|
|
20
|
+
import { onMount } from "svelte"
|
|
21
|
+
|
|
22
|
+
const {
|
|
23
|
+
/** @type {string} - Additional CSS classes */
|
|
24
|
+
class: className = "",
|
|
25
|
+
|
|
26
|
+
/** @type {string} - HTML id for accessibility */
|
|
27
|
+
id = crypto.randomUUID(),
|
|
28
|
+
|
|
29
|
+
/** @type {string} - Split direction (horizontal or vertical) */
|
|
30
|
+
direction = "horizontal",
|
|
31
|
+
|
|
32
|
+
/** @type {number} - Initial size of the first panel in percentage (0-100) */
|
|
33
|
+
initialSize = 50,
|
|
34
|
+
|
|
35
|
+
/** @type {number} - Minimum size of the first panel in percentage */
|
|
36
|
+
minSize = 10,
|
|
37
|
+
|
|
38
|
+
/** @type {number} - Maximum size of the first panel in percentage */
|
|
39
|
+
maxSize = 90,
|
|
40
|
+
|
|
41
|
+
/** @type {boolean} - Whether the split is resizable */
|
|
42
|
+
resizable = true,
|
|
43
|
+
|
|
44
|
+
/** @type {boolean} - Whether to collapse the first panel */
|
|
45
|
+
collapseFirst = false,
|
|
46
|
+
|
|
47
|
+
/** @type {boolean} - Whether to collapse the second panel */
|
|
48
|
+
collapseSecond = false,
|
|
49
|
+
|
|
50
|
+
/** @type {number} - Size of the divider in pixels */
|
|
51
|
+
dividerSize = 4,
|
|
52
|
+
|
|
53
|
+
/** @type {string} - ARIA label for the divider */
|
|
54
|
+
dividerAriaLabel,
|
|
55
|
+
|
|
56
|
+
/** @type {(event: CustomEvent) => void} - Resize event handler */
|
|
57
|
+
onresize,
|
|
58
|
+
|
|
59
|
+
first,
|
|
60
|
+
second,
|
|
61
|
+
} = $props()
|
|
62
|
+
|
|
63
|
+
// Component state
|
|
64
|
+
let size = $state(initialSize)
|
|
65
|
+
let isDragging = $state(false)
|
|
66
|
+
let containerElement = $state()
|
|
67
|
+
let firstPanelElement = $state()
|
|
68
|
+
let secondPanelElement = $state()
|
|
69
|
+
let dividerElement = $state()
|
|
70
|
+
let startPosition = $state(0)
|
|
71
|
+
let startSize = $state(0)
|
|
72
|
+
let containerSize = $state(0)
|
|
73
|
+
let resizeObserver = $state()
|
|
74
|
+
|
|
75
|
+
// Computed values
|
|
76
|
+
const isHorizontal = $derived(direction === "horizontal")
|
|
77
|
+
const isVertical = $derived(direction === "vertical")
|
|
78
|
+
const effectiveSize = $derived(collapseFirst ? 0 : collapseSecond ? 100 : size)
|
|
79
|
+
|
|
80
|
+
// Divider aria label
|
|
81
|
+
const dividerLabel = $derived(
|
|
82
|
+
dividerAriaLabel ||
|
|
83
|
+
`${isHorizontal ? "Horizontal" : "Vertical"} resizer. Use arrow keys to resize.`
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Starts dragging the divider
|
|
88
|
+
* @param {MouseEvent|TouchEvent} event - Mouse or touch event
|
|
89
|
+
*/
|
|
90
|
+
function startDrag(event) {
|
|
91
|
+
if (!resizable || collapseFirst || collapseSecond) return
|
|
92
|
+
|
|
93
|
+
isDragging = true
|
|
94
|
+
|
|
95
|
+
// Get starting position
|
|
96
|
+
startPosition = isHorizontal
|
|
97
|
+
? event.type === "touchstart"
|
|
98
|
+
? event.touches[0].clientX
|
|
99
|
+
: event.clientX
|
|
100
|
+
: event.type === "touchstart"
|
|
101
|
+
? event.touches[0].clientY
|
|
102
|
+
: event.clientY
|
|
103
|
+
|
|
104
|
+
startSize = size
|
|
105
|
+
|
|
106
|
+
// Get container size
|
|
107
|
+
const rect = containerElement.getBoundingClientRect()
|
|
108
|
+
containerSize = isHorizontal ? rect.width : rect.height
|
|
109
|
+
|
|
110
|
+
// Add event listeners for drag
|
|
111
|
+
if (event.type === "mousedown") {
|
|
112
|
+
document.addEventListener("mousemove", handleDrag)
|
|
113
|
+
document.addEventListener("mouseup", stopDrag)
|
|
114
|
+
} else if (event.type === "touchstart") {
|
|
115
|
+
document.addEventListener("touchmove", handleDrag, { passive: false })
|
|
116
|
+
document.addEventListener("touchend", stopDrag)
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Prevent default to avoid text selection
|
|
120
|
+
event.preventDefault()
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Handles dragging the divider
|
|
125
|
+
* @param {MouseEvent|TouchEvent} event - Mouse or touch event
|
|
126
|
+
*/
|
|
127
|
+
function handleDrag(event) {
|
|
128
|
+
if (!isDragging) return
|
|
129
|
+
|
|
130
|
+
// Get current position
|
|
131
|
+
const currentPosition = isHorizontal
|
|
132
|
+
? event.type === "touchmove"
|
|
133
|
+
? event.touches[0].clientX
|
|
134
|
+
: event.clientX
|
|
135
|
+
: event.type === "touchmove"
|
|
136
|
+
? event.touches[0].clientY
|
|
137
|
+
: event.clientY
|
|
138
|
+
|
|
139
|
+
// Calculate delta and new size
|
|
140
|
+
const delta = currentPosition - startPosition
|
|
141
|
+
const deltaPercent = (delta / containerSize) * 100
|
|
142
|
+
let newSize = startSize + deltaPercent
|
|
143
|
+
|
|
144
|
+
// Constrain to min/max
|
|
145
|
+
newSize = Math.max(minSize, Math.min(maxSize, newSize))
|
|
146
|
+
|
|
147
|
+
// Update size
|
|
148
|
+
size = newSize
|
|
149
|
+
|
|
150
|
+
// Dispatch resize event
|
|
151
|
+
onresize?.(new CustomEvent("resize", { detail: { size } }))
|
|
152
|
+
|
|
153
|
+
// Prevent default to avoid scrolling on touch devices
|
|
154
|
+
event.preventDefault()
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Stops dragging the divider
|
|
159
|
+
*/
|
|
160
|
+
function stopDrag() {
|
|
161
|
+
if (!isDragging) return
|
|
162
|
+
|
|
163
|
+
isDragging = false
|
|
164
|
+
|
|
165
|
+
// Remove event listeners
|
|
166
|
+
document.removeEventListener("mousemove", handleDrag)
|
|
167
|
+
document.removeEventListener("mouseup", stopDrag)
|
|
168
|
+
document.removeEventListener("touchmove", handleDrag)
|
|
169
|
+
document.removeEventListener("touchend", stopDrag)
|
|
170
|
+
|
|
171
|
+
// Dispatch resize end event
|
|
172
|
+
onresize?.(new CustomEvent("resizeend", { detail: { size } }))
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Handles keyboard navigation for resizing
|
|
177
|
+
* @param {KeyboardEvent} event - Keydown event
|
|
178
|
+
*/
|
|
179
|
+
function handleKeydown(event) {
|
|
180
|
+
if (!resizable || collapseFirst || collapseSecond) return
|
|
181
|
+
|
|
182
|
+
let newSize = size
|
|
183
|
+
const step = event.shiftKey ? 10 : 1
|
|
184
|
+
|
|
185
|
+
switch (event.key) {
|
|
186
|
+
case "ArrowLeft":
|
|
187
|
+
if (isHorizontal) newSize -= step
|
|
188
|
+
break
|
|
189
|
+
case "ArrowRight":
|
|
190
|
+
if (isHorizontal) newSize += step
|
|
191
|
+
break
|
|
192
|
+
case "ArrowUp":
|
|
193
|
+
if (isVertical) newSize -= step
|
|
194
|
+
break
|
|
195
|
+
case "ArrowDown":
|
|
196
|
+
if (isVertical) newSize += step
|
|
197
|
+
break
|
|
198
|
+
case "Home":
|
|
199
|
+
newSize = minSize
|
|
200
|
+
break
|
|
201
|
+
case "End":
|
|
202
|
+
newSize = maxSize
|
|
203
|
+
break
|
|
204
|
+
default:
|
|
205
|
+
return
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// Constrain to min/max
|
|
209
|
+
newSize = Math.max(minSize, Math.min(maxSize, newSize))
|
|
210
|
+
|
|
211
|
+
// Update size if changed
|
|
212
|
+
if (newSize !== size) {
|
|
213
|
+
size = newSize
|
|
214
|
+
onresize?.(new CustomEvent("resize", { detail: { size } }))
|
|
215
|
+
event.preventDefault()
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// Clean up event listeners on unmount
|
|
220
|
+
onMount(() => {
|
|
221
|
+
return () => {
|
|
222
|
+
document.removeEventListener("mousemove", handleDrag)
|
|
223
|
+
document.removeEventListener("mouseup", stopDrag)
|
|
224
|
+
document.removeEventListener("touchmove", handleDrag)
|
|
225
|
+
document.removeEventListener("touchend", stopDrag)
|
|
226
|
+
}
|
|
227
|
+
})
|
|
228
|
+
</script>
|
|
229
|
+
|
|
230
|
+
<div
|
|
231
|
+
{id}
|
|
232
|
+
class="
|
|
233
|
+
split
|
|
234
|
+
split-{direction}
|
|
235
|
+
{isDragging ? 'split-dragging' : ''}
|
|
236
|
+
{collapseFirst ? 'split-collapse-first' : ''}
|
|
237
|
+
{collapseSecond ? 'split-collapse-second' : ''}
|
|
238
|
+
{className}
|
|
239
|
+
"
|
|
240
|
+
bind:this={containerElement}
|
|
241
|
+
>
|
|
242
|
+
<div
|
|
243
|
+
class="split-panel split-first"
|
|
244
|
+
style="
|
|
245
|
+
{isHorizontal ? `width: ${effectiveSize}%` : `height: ${effectiveSize}%`};
|
|
246
|
+
{collapseFirst ? 'display: none' : ''}
|
|
247
|
+
"
|
|
248
|
+
bind:this={firstPanelElement}
|
|
249
|
+
>
|
|
250
|
+
{@render first?.()}
|
|
251
|
+
</div>
|
|
252
|
+
|
|
253
|
+
{#if !collapseFirst && !collapseSecond}
|
|
254
|
+
<div
|
|
255
|
+
class="
|
|
256
|
+
split-divider
|
|
257
|
+
{resizable ? 'split-divider-resizable' : ''}
|
|
258
|
+
"
|
|
259
|
+
style="
|
|
260
|
+
{isHorizontal ? `width: ${dividerSize}px` : `height: ${dividerSize}px`};
|
|
261
|
+
"
|
|
262
|
+
role={resizable ? 'separator' : undefined}
|
|
263
|
+
tabindex={resizable ? 0 : undefined}
|
|
264
|
+
aria-label={resizable ? dividerLabel : undefined}
|
|
265
|
+
aria-valuenow={resizable ? size : undefined}
|
|
266
|
+
aria-valuemin={resizable ? minSize : undefined}
|
|
267
|
+
aria-valuemax={resizable ? maxSize : undefined}
|
|
268
|
+
onmousedown={startDrag}
|
|
269
|
+
ontouchstart={startDrag}
|
|
270
|
+
onkeydown={handleKeydown}
|
|
271
|
+
bind:this={dividerElement}
|
|
272
|
+
>
|
|
273
|
+
<div class="split-divider-handle"></div>
|
|
274
|
+
</div>
|
|
275
|
+
{/if}
|
|
276
|
+
|
|
277
|
+
<div
|
|
278
|
+
class="split-panel split-second"
|
|
279
|
+
style="
|
|
280
|
+
{isHorizontal ? `width: ${100 - effectiveSize}%` : `height: ${100 - effectiveSize}%`};
|
|
281
|
+
{collapseSecond ? 'display: none' : ''}
|
|
282
|
+
"
|
|
283
|
+
bind:this={secondPanelElement}
|
|
284
|
+
>
|
|
285
|
+
{@render second?.()}
|
|
286
|
+
</div>
|
|
287
|
+
</div>
|
|
288
|
+
|
|
289
|
+
<style>
|
|
290
|
+
@reference "../../twintrinsic.css";
|
|
291
|
+
|
|
292
|
+
.split {
|
|
293
|
+
@apply flex w-full h-full overflow-hidden;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
.split-horizontal {
|
|
297
|
+
@apply flex-row;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
.split-vertical {
|
|
301
|
+
@apply flex-col;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
.split-panel {
|
|
305
|
+
@apply overflow-auto;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
.split-divider {
|
|
309
|
+
@apply flex-shrink-0 bg-border dark:bg-border;
|
|
310
|
+
@apply z-10;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
.split-divider-resizable {
|
|
314
|
+
@apply cursor-col-resize hover:bg-primary-300 dark:hover:bg-primary-700;
|
|
315
|
+
@apply focus:outline-none focus:bg-primary-300 dark:focus:bg-primary-700;
|
|
316
|
+
@apply transition-colors duration-150;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
.split-vertical .split-divider-resizable {
|
|
320
|
+
@apply cursor-row-resize;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
.split-divider-handle {
|
|
324
|
+
@apply absolute;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
.split-horizontal .split-divider-handle {
|
|
328
|
+
@apply top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2;
|
|
329
|
+
@apply w-1 h-8 rounded-full;
|
|
330
|
+
@apply bg-border dark:bg-border;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
.split-vertical .split-divider-handle {
|
|
334
|
+
@apply top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2;
|
|
335
|
+
@apply w-8 h-1 rounded-full;
|
|
336
|
+
@apply bg-border dark:bg-border;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
.split-dragging {
|
|
340
|
+
@apply select-none;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
.split-dragging .split-divider {
|
|
344
|
+
@apply bg-primary-300 dark:bg-primary-700;
|
|
345
|
+
}
|
|
346
|
+
</style>
|