@torpor/ui 0.3.7 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +83 -7
- package/dist/Accordion/Accordion.torp +43 -165
- package/dist/Accordion/AccordionContent.torp +6 -6
- package/dist/Accordion/AccordionHeader.torp +7 -11
- package/dist/Accordion/AccordionItem.torp +24 -24
- package/dist/Accordion/AccordionTrigger.torp +17 -8
- package/dist/Accordion/AccordionTypes.ts +6 -6
- package/dist/Accordion/index.d.ts +23 -25
- package/dist/Accordion/index.js +6 -22
- package/dist/Breadcrumb/Breadcrumb.torp +12 -10
- package/dist/Breadcrumb/BreadcrumbItem.torp +6 -6
- package/dist/Breadcrumb/BreadcrumbList.torp +21 -0
- package/dist/Breadcrumb/BreadcrumbSeparator.torp +4 -4
- package/dist/Breadcrumb/index.d.ts +39 -15
- package/dist/Breadcrumb/index.js +5 -14
- package/dist/Calendar/Calendar.torp +163 -156
- package/dist/Calendar/CalendarDay.torp +91 -45
- package/dist/Calendar/CalendarDayHeader.torp +36 -0
- package/dist/Calendar/CalendarGrid.torp +104 -0
- package/dist/Calendar/CalendarGridHeader.torp +43 -0
- package/dist/Calendar/CalendarHeader.torp +48 -0
- package/dist/Calendar/CalendarHeaderTrigger.torp +54 -0
- package/dist/Calendar/CalendarTypes.ts +25 -4
- package/dist/Calendar/buildDays.ts +54 -0
- package/dist/Calendar/index.d.ts +191 -5
- package/dist/Calendar/index.js +8 -10
- package/dist/Carousel/Carousel.torp +180 -0
- package/dist/Carousel/CarouselIndicators.torp +65 -0
- package/dist/Carousel/CarouselNext.torp +43 -0
- package/dist/Carousel/CarouselPrevious.torp +44 -0
- package/dist/Carousel/CarouselSlide.torp +57 -0
- package/dist/Carousel/CarouselTypes.ts +28 -0
- package/dist/Carousel/index.d.ts +147 -0
- package/dist/Carousel/index.js +6 -0
- package/dist/Charts/BarChart.torp +70 -0
- package/dist/Charts/Chart.torp +120 -0
- package/dist/Charts/ChartBars.torp +78 -0
- package/dist/Charts/ChartColumns.torp +66 -0
- package/dist/Charts/ChartGrid.torp +54 -0
- package/dist/Charts/ChartLines.torp +60 -0
- package/dist/Charts/ChartTypes.ts +25 -0
- package/dist/Charts/ChartXAxis.torp +83 -0
- package/dist/Charts/ChartYAxis.torp +105 -0
- package/dist/Charts/ColumnChart.torp +70 -0
- package/dist/{Chart → Charts}/GridLines.torp +7 -4
- package/dist/Charts/LineChart.torp +73 -0
- package/dist/{Chart → Charts}/PieChart.torp +14 -20
- package/dist/{Chart → Charts}/ScatterChart.torp +45 -38
- package/dist/{Chart → Charts}/SparkLine.torp +16 -19
- package/dist/{Chart → Charts}/XAxis.torp +18 -12
- package/dist/{Chart → Charts}/YAxis.torp +15 -9
- package/dist/Charts/index.d.ts +469 -0
- package/dist/Charts/index.js +17 -0
- package/dist/ColorPicker/ColorPalette.torp +154 -0
- package/dist/ColorPicker/ColorPicker.torp +157 -0
- package/dist/ColorPicker/index.d.ts +85 -0
- package/dist/ColorPicker/index.js +3 -0
- package/dist/ComboBox/ComboBox.torp +205 -0
- package/dist/ComboBox/ComboBoxContent.torp +112 -0
- package/dist/ComboBox/ComboBoxInput.torp +145 -0
- package/dist/ComboBox/ComboBoxTrigger.torp +49 -0
- package/dist/ComboBox/ComboBoxTypes.ts +39 -0
- package/dist/ComboBox/index.d.ts +152 -0
- package/dist/ComboBox/index.js +6 -0
- package/dist/CommandPalette/CommandPalette.torp +220 -0
- package/dist/CommandPalette/CommandTypes.ts +14 -0
- package/dist/CommandPalette/index.d.ts +45 -0
- package/dist/CommandPalette/index.js +2 -0
- package/dist/Contextual/Contextual.torp +39 -52
- package/dist/Contextual/ContextualContent.torp +29 -73
- package/dist/Contextual/ContextualHover.torp +112 -0
- package/dist/Contextual/ContextualTrigger.torp +31 -42
- package/dist/Contextual/ContextualTypes.ts +5 -18
- package/dist/Contextual/index.d.ts +44 -27
- package/dist/Contextual/index.js +5 -14
- package/dist/DataGrid/DataGrid.torp +496 -0
- package/dist/DataGrid/DataGridTypes.ts +25 -0
- package/dist/DataGrid/index.d.ts +90 -0
- package/dist/DataGrid/index.js +3 -0
- package/dist/DataGrid/sortRows.ts +32 -0
- package/dist/DatePicker/DatePicker.torp +222 -0
- package/dist/DatePicker/DatePickerHeader.torp +20 -0
- package/dist/DatePicker/index.d.ts +55 -0
- package/dist/DatePicker/index.js +2 -0
- package/dist/DateRangePicker/DateRangePicker.torp +311 -0
- package/dist/DateRangePicker/DateRangePickerDay.torp +137 -0
- package/dist/DateRangePicker/DateRangePickerTypes.ts +21 -0
- package/dist/DateRangePicker/index.d.ts +76 -0
- package/dist/DateRangePicker/index.js +3 -0
- package/dist/Dialog/Dialog.torp +33 -30
- package/dist/Dialog/DialogBody.torp +5 -9
- package/dist/Dialog/DialogButton.torp +14 -11
- package/dist/Dialog/DialogFooter.torp +3 -7
- package/dist/Dialog/DialogHeader.torp +6 -10
- package/dist/Dialog/DialogTypes.ts +2 -2
- package/dist/Dialog/index.d.ts +28 -26
- package/dist/Dialog/index.js +6 -22
- package/dist/Disclosure/Disclosure.torp +18 -18
- package/dist/Disclosure/DisclosureContent.torp +5 -6
- package/dist/Disclosure/DisclosureHeader.torp +7 -11
- package/dist/Disclosure/DisclosureTrigger.torp +4 -5
- package/dist/Disclosure/DisclosureTypes.ts +1 -1
- package/dist/Disclosure/index.d.ts +14 -16
- package/dist/Disclosure/index.js +5 -18
- package/dist/Drawer/Drawer.torp +21 -51
- package/dist/Drawer/DrawerContent.torp +67 -13
- package/dist/Drawer/DrawerOverlay.torp +4 -4
- package/dist/Drawer/DrawerTrigger.torp +16 -4
- package/dist/Drawer/DrawerTypes.ts +4 -1
- package/dist/Drawer/index.d.ts +16 -20
- package/dist/Drawer/index.js +5 -18
- package/dist/FocusGroup/FocusGroup.torp +70 -0
- package/dist/FocusGroup/FocusGroupButton.torp +59 -0
- package/dist/FocusGroup/FocusGroupTypes.ts +14 -0
- package/dist/FocusGroup/index.d.ts +44 -0
- package/dist/FocusGroup/index.js +3 -0
- package/dist/Form/CheckBox.torp +28 -20
- package/dist/Form/Field.torp +17 -17
- package/dist/Form/File.torp +31 -22
- package/dist/Form/FileDrop.torp +187 -0
- package/dist/Form/Form.torp +24 -22
- package/dist/Form/FormTypes.ts +2 -0
- package/dist/Form/FormValues.torp +37 -0
- package/dist/Form/Hidden.torp +4 -12
- package/dist/Form/Input.torp +38 -32
- package/dist/Form/Label.torp +3 -3
- package/dist/Form/Message.torp +13 -5
- package/dist/Form/MessageSummary.torp +39 -0
- package/dist/Form/Option.torp +11 -7
- package/dist/Form/Select.torp +32 -28
- package/dist/Form/TextArea.torp +35 -31
- package/dist/Form/Toggle.torp +109 -0
- package/dist/Form/index.d.ts +198 -77
- package/dist/Form/index.js +16 -46
- package/dist/ListBox/ListBox.torp +374 -0
- package/dist/ListBox/ListBoxItem.torp +131 -0
- package/dist/ListBox/ListBoxSeparator.torp +29 -0
- package/dist/ListBox/ListBoxTypes.ts +41 -0
- package/dist/ListBox/LoadedListBoxItems.torp +41 -0
- package/dist/ListBox/index.d.ts +136 -0
- package/dist/ListBox/index.js +4 -0
- package/dist/MaskedInput/MaskedInput.torp +143 -0
- package/dist/MaskedInput/index.d.ts +52 -0
- package/dist/MaskedInput/index.js +2 -0
- package/dist/Menu/Menu.torp +90 -70
- package/dist/Menu/MenuButton.torp +17 -10
- package/dist/Menu/MenuCheck.torp +22 -18
- package/dist/Menu/MenuGroup.torp +4 -4
- package/dist/Menu/MenuIndicator.torp +5 -13
- package/dist/Menu/MenuPopout.torp +20 -50
- package/dist/Menu/MenuPopoutContent.torp +15 -66
- package/dist/Menu/MenuPopoutTrigger.torp +19 -100
- package/dist/Menu/MenuRadio.torp +25 -26
- package/dist/Menu/MenuRadioGroup.torp +25 -68
- package/dist/Menu/MenuSeparator.torp +3 -2
- package/dist/Menu/MenuTypes.ts +12 -21
- package/dist/Menu/index.d.ts +45 -51
- package/dist/Menu/index.js +12 -46
- package/dist/MenuBar/MenuBar.torp +31 -83
- package/dist/MenuBar/MenuBarItem.torp +34 -55
- package/dist/MenuBar/MenuBarItemContent.torp +15 -101
- package/dist/MenuBar/MenuBarItemTrigger.torp +20 -55
- package/dist/MenuBar/MenuBarTypes.ts +13 -12
- package/dist/MenuBar/index.d.ts +17 -19
- package/dist/MenuBar/index.js +5 -18
- package/dist/Modal/Modal.torp +28 -48
- package/dist/Modal/ModalContent.torp +21 -44
- package/dist/Modal/ModalOverlay.torp +4 -4
- package/dist/Modal/ModalTrigger.torp +16 -32
- package/dist/Modal/ModalTypes.ts +6 -17
- package/dist/Modal/index.d.ts +17 -29
- package/dist/Modal/index.js +29 -28
- package/dist/Modal/index.js.map +1 -1
- package/dist/Modal/showPrompt.ts +2 -2
- package/dist/NavMenu/NavMenu.torp +22 -104
- package/dist/NavMenu/NavMenuButton.torp +10 -8
- package/dist/NavMenu/NavMenuElement.torp +6 -7
- package/dist/NavMenu/NavMenuGroup.torp +5 -5
- package/dist/NavMenu/NavMenuGroupHeader.torp +5 -8
- package/dist/NavMenu/NavMenuLink.torp +7 -10
- package/dist/NavMenu/NavMenuPopout.torp +16 -61
- package/dist/NavMenu/NavMenuPopoutContent.torp +14 -73
- package/dist/NavMenu/NavMenuPopoutTrigger.torp +47 -0
- package/dist/NavMenu/NavMenuSeparator.torp +3 -6
- package/dist/NavMenu/NavMenuTypes.ts +6 -15
- package/dist/NavMenu/index.d.ts +55 -55
- package/dist/NavMenu/index.js +11 -42
- package/dist/Notification/Notification.torp +12 -24
- package/dist/Notification/NotificationClose.torp +6 -3
- package/dist/Notification/NotificationContainer.torp +3 -7
- package/dist/Notification/NotificationContent.torp +3 -7
- package/dist/Notification/NotificationTypes.ts +1 -1
- package/dist/Notification/index.d.ts +15 -12
- package/dist/Notification/index.js +22 -32
- package/dist/Notification/index.js.map +1 -1
- package/dist/NumberInput/NumberInput.torp +255 -0
- package/dist/NumberInput/index.d.ts +44 -0
- package/dist/NumberInput/index.js +2 -0
- package/dist/Pagination/Pagination.torp +152 -0
- package/dist/Pagination/PaginationItem.torp +137 -0
- package/dist/Pagination/PaginationTypes.ts +22 -0
- package/dist/Pagination/buildPages.ts +61 -0
- package/dist/Pagination/index.d.ts +63 -0
- package/dist/Pagination/index.js +3 -0
- package/dist/Popover/Popover.torp +39 -52
- package/dist/Popover/PopoverContent.torp +27 -76
- package/dist/Popover/PopoverHover.torp +90 -0
- package/dist/Popover/PopoverTrigger.torp +17 -40
- package/dist/Popover/PopoverTypes.ts +5 -18
- package/dist/Popover/index.d.ts +40 -25
- package/dist/Popover/index.js +18 -18
- package/dist/Popover/index.js.map +1 -1
- package/dist/Progress/Progress.torp +88 -0
- package/dist/Progress/index.d.ts +37 -0
- package/dist/Progress/index.js +2 -0
- package/dist/Rating/Rating.torp +225 -0
- package/dist/Rating/index.d.ts +44 -0
- package/dist/Rating/index.js +2 -0
- package/dist/SegmentedControl/SegmentedControl.torp +233 -0
- package/dist/SegmentedControl/SegmentedControlTypes.ts +26 -0
- package/dist/SegmentedControl/SegmentedItem.torp +78 -0
- package/dist/SegmentedControl/index.d.ts +74 -0
- package/dist/SegmentedControl/index.js +3 -0
- package/dist/SelectBox/SelectBox.torp +190 -0
- package/dist/SelectBox/SelectBoxContent.torp +107 -0
- package/dist/SelectBox/SelectBoxTrigger.torp +141 -0
- package/dist/SelectBox/SelectBoxTypes.ts +33 -0
- package/dist/SelectBox/index.d.ts +112 -0
- package/dist/SelectBox/index.js +5 -0
- package/dist/Slider/Slider.torp +248 -0
- package/dist/Slider/index.d.ts +45 -0
- package/dist/Slider/index.js +2 -0
- package/dist/Splitter/Splitter.torp +156 -0
- package/dist/Splitter/SplitterHandle.torp +161 -0
- package/dist/Splitter/SplitterPane.torp +63 -0
- package/dist/Splitter/SplitterTypes.ts +31 -0
- package/dist/Splitter/index.d.ts +103 -0
- package/dist/Splitter/index.js +4 -0
- package/dist/Stepper/Stepper.torp +146 -0
- package/dist/Stepper/StepperMarker.torp +24 -0
- package/dist/Stepper/StepperNext.torp +44 -0
- package/dist/Stepper/StepperPrevious.torp +44 -0
- package/dist/Stepper/StepperStep.torp +90 -0
- package/dist/Stepper/StepperTypes.ts +30 -0
- package/dist/Stepper/index.d.ts +149 -0
- package/dist/Stepper/index.js +6 -0
- package/dist/TabGroup/TabContent.torp +6 -6
- package/dist/TabGroup/TabGroup.torp +97 -113
- package/dist/TabGroup/TabGroupTypes.ts +3 -3
- package/dist/TabGroup/TabHeader.torp +23 -19
- package/dist/TabGroup/TabList.torp +8 -21
- package/dist/TabGroup/TabTrigger.torp +6 -7
- package/dist/TabGroup/index.d.ts +26 -26
- package/dist/TabGroup/index.js +6 -22
- package/dist/TagInput/TagInput.torp +378 -0
- package/dist/TagInput/index.d.ts +48 -0
- package/dist/TagInput/index.js +2 -0
- package/dist/TimePicker/TimePicker.torp +462 -0
- package/dist/TimePicker/index.d.ts +53 -0
- package/dist/TimePicker/index.js +2 -0
- package/dist/ToolBar/ToolBar.torp +117 -0
- package/dist/ToolBar/ToolBarButton.torp +56 -0
- package/dist/ToolBar/ToolBarElement.torp +51 -0
- package/dist/ToolBar/ToolBarPopout.torp +45 -0
- package/dist/ToolBar/ToolBarPopoutContent.torp +34 -0
- package/dist/ToolBar/ToolBarPopoutTrigger.torp +47 -0
- package/dist/ToolBar/ToolBarSeparator.torp +21 -0
- package/dist/ToolBar/ToolBarTypes.ts +28 -0
- package/dist/ToolBar/index.d.ts +210 -0
- package/dist/ToolBar/index.js +8 -0
- package/dist/Tree/Tree.torp +395 -0
- package/dist/Tree/TreeItem.torp +176 -0
- package/dist/Tree/TreeItemChildren.torp +60 -0
- package/dist/Tree/TreeItemContent.torp +46 -0
- package/dist/Tree/TreeItemLabel.torp +94 -0
- package/dist/Tree/TreeItemTrigger.torp +78 -0
- package/dist/Tree/TreeLoadedChildren.torp +122 -0
- package/dist/Tree/TreeTypes.ts +63 -0
- package/dist/Tree/index.d.ts +262 -0
- package/dist/Tree/index.js +7 -0
- package/dist/icons/ChevronDoubleLeft.torp +19 -0
- package/dist/icons/ChevronDoubleRight.torp +19 -0
- package/dist/icons/index.d.ts +61 -1
- package/dist/icons/index.js +17 -58
- package/dist/loader-DEeG5vFY.js +44 -0
- package/dist/loader-DEeG5vFY.js.map +1 -0
- package/dist/motion/index.d.ts +12 -8
- package/dist/motion/index.d.ts.map +1 -0
- package/dist/motion/index.js +72 -88
- package/dist/motion/index.js.map +1 -1
- package/dist/mount/draggable.ts +63 -0
- package/dist/mount/dropTarget.ts +108 -0
- package/dist/mount/hoverTrigger.ts +1 -1
- package/dist/utils/$handle.ts +23 -0
- package/dist/utils/LoadedItems.torp +47 -0
- package/dist/utils/PopoutClickTrigger.torp +99 -0
- package/dist/utils/PopoutTypes.ts +82 -0
- package/dist/utils/SubmenuPopout.torp +89 -0
- package/dist/utils/SubmenuPopoutContent.torp +87 -0
- package/dist/utils/SubmenuPopoutTrigger.torp +160 -0
- package/dist/utils/chartColors.ts +13 -13
- package/dist/utils/chartLayout.ts +143 -0
- package/dist/utils/chartUtils.ts +1 -1
- package/dist/utils/colorUtils.ts +103 -0
- package/dist/utils/createItemGroup.ts +152 -0
- package/dist/utils/dateUtils.ts +8 -7
- package/dist/utils/documentEvents.ts +4 -4
- package/dist/utils/dragState.ts +86 -0
- package/dist/utils/focusGroup.ts +204 -0
- package/dist/utils/focusItem.ts +44 -0
- package/dist/utils/formField.ts +70 -0
- package/dist/utils/hoverOpen.ts +50 -0
- package/dist/utils/hoverReveal.ts +194 -0
- package/dist/utils/loader.ts +113 -0
- package/dist/utils/maskUtils.ts +98 -0
- package/dist/utils/popoutContent.ts +137 -0
- package/dist/utils/reorderList.ts +52 -0
- package/package.json +116 -25
- package/dist/Accordion/index.js.map +0 -1
- package/dist/Breadcrumb/index.js.map +0 -1
- package/dist/Calendar/index.js.map +0 -1
- package/dist/Chart/BarChart.torp +0 -159
- package/dist/Chart/LineChart.torp +0 -196
- package/dist/Chart/index.d.ts +0 -220
- package/dist/Chart/index.js +0 -34
- package/dist/Chart/index.js.map +0 -1
- package/dist/Contextual/index.js.map +0 -1
- package/dist/Dialog/index.js.map +0 -1
- package/dist/Disclosure/index.js.map +0 -1
- package/dist/Drawer/index.js.map +0 -1
- package/dist/Form/index.js.map +0 -1
- package/dist/Menu/index.js.map +0 -1
- package/dist/MenuBar/index.js.map +0 -1
- package/dist/NavMenu/NavMenuPopoutButton.torp +0 -129
- package/dist/NavMenu/index.js.map +0 -1
- package/dist/TabGroup/index.js.map +0 -1
- package/dist/icons/index.js.map +0 -1
- package/dist/index.d.ts +0 -19
- package/dist/metafile-esm.json +0 -1
- package/dist/motion/fade.ts +0 -16
- package/dist/motion/grow.ts +0 -23
- package/dist/motion/measure.ts +0 -28
- package/dist/motion/slide.ts +0 -45
- package/dist/mount/index.d.ts +0 -2
- package/dist/utils/index.d.ts +0 -2
- /package/dist/{Chart → Charts}/DataSeries.ts +0 -0
package/dist/icons/index.d.ts
CHANGED
|
@@ -177,6 +177,66 @@ declare function Check(
|
|
|
177
177
|
|
|
178
178
|
|
|
179
179
|
|
|
180
|
+
type IconProps } from "./IconTypes";
|
|
181
|
+
|
|
182
|
+
export default function ChevronDoubleLeft($props: IconProps | undefined) {
|
|
183
|
+
@render {
|
|
184
|
+
<svg
|
|
185
|
+
{$props?.id}
|
|
186
|
+
class={["torp-icon", $props?.class]}
|
|
187
|
+
{$props?.style}
|
|
188
|
+
viewBox="0 0 100 100"
|
|
189
|
+
stroke-linejoin="round"
|
|
190
|
+
stroke-width="12"
|
|
191
|
+
>
|
|
192
|
+
<g>
|
|
193
|
+
<path fill="none" d="M90,10 L50,50 L90,90"></path>
|
|
194
|
+
<path fill="none" d="M50,10 L10,50 L50,90"></path>
|
|
195
|
+
</g>
|
|
196
|
+
</svg>
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
declare function ChevronDoubleLeft(
|
|
201
|
+
$parent: ParentNode,
|
|
202
|
+
$anchor: Node | null,
|
|
203
|
+
$props: IconProps | undefined,
|
|
204
|
+
$context?: Record<PropertyKey, any>,
|
|
205
|
+
$slots?: Record<string, SlotRender>,
|
|
206
|
+
): void;
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
type IconProps } from "./IconTypes";
|
|
211
|
+
|
|
212
|
+
export default function ChevronDoubleRight($props: IconProps | undefined) {
|
|
213
|
+
@render {
|
|
214
|
+
<svg
|
|
215
|
+
{$props?.id}
|
|
216
|
+
class={["torp-icon", $props?.class]}
|
|
217
|
+
{$props?.style}
|
|
218
|
+
viewBox="0 0 100 100"
|
|
219
|
+
stroke-linejoin="round"
|
|
220
|
+
stroke-width="12"
|
|
221
|
+
>
|
|
222
|
+
<g>
|
|
223
|
+
<path d="M10,10 L50,50 L10,90" fill="none" />
|
|
224
|
+
<path d="M50,10 L90,50 L50,90" fill="none" />
|
|
225
|
+
</g>
|
|
226
|
+
</svg>
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
declare function ChevronDoubleRight(
|
|
231
|
+
$parent: ParentNode,
|
|
232
|
+
$anchor: Node | null,
|
|
233
|
+
$props: IconProps | undefined,
|
|
234
|
+
$context?: Record<PropertyKey, any>,
|
|
235
|
+
$slots?: Record<string, SlotRender>,
|
|
236
|
+
): void;
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
|
|
180
240
|
type IconProps } from "./IconTypes";
|
|
181
241
|
|
|
182
242
|
export default function ChevronDown($props: IconProps | undefined) {
|
|
@@ -410,4 +470,4 @@ declare function Plus(
|
|
|
410
470
|
$slots?: Record<string, SlotRender>,
|
|
411
471
|
): void;
|
|
412
472
|
|
|
413
|
-
export { ArrowDown, ArrowLeft, ArrowRight, ArrowUp, Bars, Check, ChevronDown, ChevronLeft, ChevronRight, ChevronUp, Cross, Loading, Minus, Plus };
|
|
473
|
+
export { ArrowDown, ArrowLeft, ArrowRight, ArrowUp, Bars, Check, ChevronDoubleLeft, ChevronDoubleRight, ChevronDown, ChevronLeft, ChevronRight, ChevronUp, Cross, Loading, Minus, Plus };
|
package/dist/icons/index.js
CHANGED
|
@@ -1,58 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
import
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
import
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
// src/icons/ChevronDown.torp
|
|
20
|
-
import ChevronDown_default from "./ChevronDown.torp";
|
|
21
|
-
|
|
22
|
-
// src/icons/ChevronLeft.torp
|
|
23
|
-
import ChevronLeft_default from "./ChevronLeft.torp";
|
|
24
|
-
|
|
25
|
-
// src/icons/ChevronRight.torp
|
|
26
|
-
import ChevronRight_default from "./ChevronRight.torp";
|
|
27
|
-
|
|
28
|
-
// src/icons/ChevronUp.torp
|
|
29
|
-
import ChevronUp_default from "./ChevronUp.torp";
|
|
30
|
-
|
|
31
|
-
// src/icons/Cross.torp
|
|
32
|
-
import Cross_default from "./Cross.torp";
|
|
33
|
-
|
|
34
|
-
// src/icons/Loading.torp
|
|
35
|
-
import Loading_default from "./Loading.torp";
|
|
36
|
-
|
|
37
|
-
// src/icons/Minus.torp
|
|
38
|
-
import Minus_default from "./Minus.torp";
|
|
39
|
-
|
|
40
|
-
// src/icons/Plus.torp
|
|
41
|
-
import Plus_default from "./Plus.torp";
|
|
42
|
-
export {
|
|
43
|
-
ArrowDown_default as ArrowDown,
|
|
44
|
-
ArrowLeft_default as ArrowLeft,
|
|
45
|
-
ArrowRight_default as ArrowRight,
|
|
46
|
-
ArrowUp_default as ArrowUp,
|
|
47
|
-
Bars_default as Bars,
|
|
48
|
-
Check_default as Check,
|
|
49
|
-
ChevronDown_default as ChevronDown,
|
|
50
|
-
ChevronLeft_default as ChevronLeft,
|
|
51
|
-
ChevronRight_default as ChevronRight,
|
|
52
|
-
ChevronUp_default as ChevronUp,
|
|
53
|
-
Cross_default as Cross,
|
|
54
|
-
Loading_default as Loading,
|
|
55
|
-
Minus_default as Minus,
|
|
56
|
-
Plus_default as Plus
|
|
57
|
-
};
|
|
58
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import ArrowDown from "./ArrowDown.torp";
|
|
2
|
+
import ArrowLeft from "./ArrowLeft.torp";
|
|
3
|
+
import ArrowRight from "./ArrowRight.torp";
|
|
4
|
+
import ArrowUp from "./ArrowUp.torp";
|
|
5
|
+
import Bars from "./Bars.torp";
|
|
6
|
+
import Check from "./Check.torp";
|
|
7
|
+
import ChevronDoubleLeft from "./ChevronDoubleLeft.torp";
|
|
8
|
+
import ChevronDoubleRight from "./ChevronDoubleRight.torp";
|
|
9
|
+
import ChevronDown from "./ChevronDown.torp";
|
|
10
|
+
import ChevronLeft from "./ChevronLeft.torp";
|
|
11
|
+
import ChevronRight from "./ChevronRight.torp";
|
|
12
|
+
import ChevronUp from "./ChevronUp.torp";
|
|
13
|
+
import Cross from "./Cross.torp";
|
|
14
|
+
import Loading from "./Loading.torp";
|
|
15
|
+
import Minus from "./Minus.torp";
|
|
16
|
+
import Plus from "./Plus.torp";
|
|
17
|
+
export { ArrowDown, ArrowLeft, ArrowRight, ArrowUp, Bars, Check, ChevronDoubleLeft, ChevronDoubleRight, ChevronDown, ChevronLeft, ChevronRight, ChevronUp, Cross, Loading, Minus, Plus };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { $async, $watch } from "@torpor/view";
|
|
2
|
+
//#region src/utils/loader.ts
|
|
3
|
+
/** Wraps a bare array in a LoadResult so consumers always get the same shape */
|
|
4
|
+
function normalizeLoadResult(result) {
|
|
5
|
+
return Array.isArray(result) ? { items: result } : result;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Shared loading state for components that read items from a network loader
|
|
9
|
+
* (DataGrid, ComboBox auto-complete etc). Read the returned state's `items`
|
|
10
|
+
* or `result` inside an `@await` boundary: while a fetch is pending the read
|
|
11
|
+
* suspends, and when dependencies read inside `getRequest` change the fetch
|
|
12
|
+
* re-runs.
|
|
13
|
+
*
|
|
14
|
+
* For lazy loading (fetch only once some condition is met), gate the whole
|
|
15
|
+
* rendering of the region that reads this loader behind that condition
|
|
16
|
+
* (`@if`), so the `@await` boundary -- and with it the first fetch --
|
|
17
|
+
* comes into existence when the condition flips.
|
|
18
|
+
*
|
|
19
|
+
* ```
|
|
20
|
+
* let $load = createItemLoader({
|
|
21
|
+
* load: $props.load,
|
|
22
|
+
* getRequest: () => ({ searchText: $state.searchText }),
|
|
23
|
+
* });
|
|
24
|
+
* @await { ...$load.items... } with { <span>Loading…</span> }
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
function createItemLoader(options) {
|
|
28
|
+
return $watch({
|
|
29
|
+
get result() {
|
|
30
|
+
return $async(() => {
|
|
31
|
+
const promise = Promise.resolve(options.load(options.getRequest())).then(normalizeLoadResult);
|
|
32
|
+
promise.then((r) => options.onload?.(r), () => {});
|
|
33
|
+
return promise;
|
|
34
|
+
});
|
|
35
|
+
},
|
|
36
|
+
get items() {
|
|
37
|
+
return this.result?.items ?? [];
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
//#endregion
|
|
42
|
+
export { normalizeLoadResult as n, createItemLoader as t };
|
|
43
|
+
|
|
44
|
+
//# sourceMappingURL=loader-DEeG5vFY.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader-DEeG5vFY.js","names":[],"sources":["../src/utils/loader.ts"],"sourcesContent":["import { $async, $watch } from \"@torpor/view\";\n\n/**\n * Shared contract for loading data from the network, used by components that\n * can take either static data or a loader function (DataGrid now, ComboBox\n * auto-complete and others later).\n *\n * A loader receives a request object describing what to fetch -- paging,\n * search text and sorting are standard; components extend it with their own\n * fields -- plus an AbortSignal so stale requests can be cancelled.\n */\n\n/** The base shape of a load request. Components extend this with their own fields. */\nexport interface LoadRequest {\n\t/** 1-based page number to load */\n\tpage?: number;\n\t/** Number of items per page */\n\tpageSize?: number;\n\t/** Search or filter text entered by the user */\n\tsearchText?: string;\n\t/** The field to sort by */\n\tsortBy?: string;\n\t/** The direction to sort in */\n\tsortDirection?: \"asc\" | \"desc\";\n}\n\n/**\n * The result of a load: the items for the current request, and optionally\n * the total count (needed for paged components to show a pager).\n */\nexport interface LoadResult<T = any> {\n\titems: T[];\n\t/** The total number of items across all pages, if known */\n\ttotal?: number;\n}\n\n/**\n * Reads data for a request. May return a promise or a plain result, and may\n * return just an array of items when no total is available.\n */\nexport type Loader<T = any, TRequest extends LoadRequest = LoadRequest> = (\n\trequest: TRequest,\n\tsignal?: AbortSignal,\n) => Promise<LoadResult<T> | T[]> | LoadResult<T> | T[];\n\n/** Wraps a bare array in a LoadResult so consumers always get the same shape */\nexport function normalizeLoadResult<T>(result: LoadResult<T> | T[]): LoadResult<T> {\n\treturn Array.isArray(result) ? { items: result } : result;\n}\n\nexport interface ItemLoaderOptions<T = any, TRequest extends LoadRequest = LoadRequest> {\n\t/** The loader function to fetch items */\n\tload: Loader<T, TRequest>;\n\t/**\n\t * Builds the request for the current fetch. Called inside the async\n\t * getter, so reads of reactive state here re-fetch when they change.\n\t */\n\tgetRequest: () => TRequest;\n\t/** Called after each successful load with the normalized result */\n\tonload?: (result: LoadResult<T>) => void;\n}\n\n/** Reactive loading state returned by createItemLoader */\nexport interface ItemLoaderState<T = any> {\n\t/** The full result of the current load; suspends while a fetch is pending */\n\treadonly result: LoadResult<T> | undefined;\n\t/** The loaded items; suspends while a fetch is pending */\n\treadonly items: T[];\n}\n\n/**\n * Shared loading state for components that read items from a network loader\n * (DataGrid, ComboBox auto-complete etc). Read the returned state's `items`\n * or `result` inside an `@await` boundary: while a fetch is pending the read\n * suspends, and when dependencies read inside `getRequest` change the fetch\n * re-runs.\n *\n * For lazy loading (fetch only once some condition is met), gate the whole\n * rendering of the region that reads this loader behind that condition\n * (`@if`), so the `@await` boundary -- and with it the first fetch --\n * comes into existence when the condition flips.\n *\n * ```\n * let $load = createItemLoader({\n * \tload: $props.load,\n * \tgetRequest: () => ({ searchText: $state.searchText }),\n * });\n * @await { ...$load.items... } with { <span>Loading…</span> }\n * ```\n */\nexport function createItemLoader<T = any, TRequest extends LoadRequest = LoadRequest>(\n\toptions: ItemLoaderOptions<T, TRequest>,\n): ItemLoaderState<T> {\n\treturn $watch({\n\t\tget result(): LoadResult<T> | undefined {\n\t\t\treturn $async(() => {\n\t\t\t\tconst promise = Promise.resolve(options.load(options.getRequest())).then(\n\t\t\t\t\tnormalizeLoadResult,\n\t\t\t\t);\n\t\t\t\t// Report successful loads to the consumer; failures surface\n\t\t\t\t// through the component's error boundary, not this chain\n\t\t\t\tpromise.then(\n\t\t\t\t\t(r) => options.onload?.(r),\n\t\t\t\t\t() => {},\n\t\t\t\t);\n\t\t\t\treturn promise as Promise<LoadResult<T>>;\n\t\t\t});\n\t\t},\n\t\tget items(): T[] {\n\t\t\treturn this.result?.items ?? [];\n\t\t},\n\t});\n}\n"],"mappings":";;;AA8CA,SAAgB,oBAAuB,QAA4C;CAClF,OAAO,MAAM,QAAQ,MAAM,IAAI,EAAE,OAAO,OAAO,IAAI;AACpD;;;;;;;;;;;;;;;;;;;;;AA0CA,SAAgB,iBACf,SACqB;CACrB,OAAO,OAAO;EACb,IAAI,SAAoC;GACvC,OAAO,aAAa;IACnB,MAAM,UAAU,QAAQ,QAAQ,QAAQ,KAAK,QAAQ,WAAW,CAAC,CAAC,CAAC,CAAC,KACnE,mBACD;IAGA,QAAQ,MACN,MAAM,QAAQ,SAAS,CAAC,SACnB,CAAC,CACR;IACA,OAAO;GACR,CAAC;EACF;EACA,IAAI,QAAa;GAChB,OAAO,KAAK,QAAQ,SAAS,CAAC;EAC/B;CACD,CAAC;AACF"}
|
package/dist/motion/index.d.ts
CHANGED
|
@@ -1,19 +1,23 @@
|
|
|
1
|
-
import { Animation } from
|
|
2
|
-
|
|
1
|
+
import { Animation } from "@torpor/view";
|
|
2
|
+
//#region src/motion/fade.d.ts
|
|
3
3
|
declare function fade(_el: HTMLElement, options?: number | KeyframeAnimationOptions): Animation;
|
|
4
|
-
|
|
4
|
+
//#endregion
|
|
5
|
+
//#region src/motion/grow.d.ts
|
|
5
6
|
declare function grow(el: HTMLElement, options?: number | KeyframeAnimationOptions): Animation;
|
|
6
|
-
|
|
7
|
+
//#endregion
|
|
8
|
+
//#region src/motion/measure.d.ts
|
|
7
9
|
/**
|
|
8
10
|
* Measures an element before it is added to the DOM
|
|
9
11
|
* @param el The element to measure
|
|
10
12
|
* @param fn The function to use to get the desired measurement (e.g. el.offsetHeight)
|
|
11
13
|
*/
|
|
12
|
-
declare function measure(el: HTMLElement, fn: (
|
|
13
|
-
|
|
14
|
+
declare function measure(el: HTMLElement, fn: (_el: HTMLElement) => number): number;
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/motion/slide.d.ts
|
|
14
17
|
interface Options extends KeyframeAnimationOptions {
|
|
15
|
-
|
|
18
|
+
side: "left" | "right" | "top" | "bottom";
|
|
16
19
|
}
|
|
17
20
|
declare function slide(el: HTMLElement, options?: Options): Animation;
|
|
18
|
-
|
|
21
|
+
//#endregion
|
|
19
22
|
export { fade, grow, measure, slide };
|
|
23
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/motion/fade.ts","../../src/motion/grow.ts","../../src/motion/measure.ts","../../src/motion/slide.ts"],"mappings":";;iBAEwB,KACvB,KAAK,aACL,mBAAmB,2BACjB;;;iBCFqB,KACvB,IAAI,aACJ,mBAAmB,2BACjB;;;;;;;;iBCDqB,QAAQ,IAAI,aAAa,KAAK,KAAK;;;UCFjD,gBAAgB;EACzB;;iBAGuB,MAAM,IAAI,aAAa,UAAU,UAAU"}
|
package/dist/motion/index.js
CHANGED
|
@@ -1,97 +1,81 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/motion/fade.ts
|
|
2
2
|
function fade(_el, options) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
{
|
|
8
|
-
opacity: 1
|
|
9
|
-
}
|
|
10
|
-
];
|
|
11
|
-
return { keyframes, options };
|
|
3
|
+
return {
|
|
4
|
+
keyframes: [{ opacity: 0 }, { opacity: 1 }],
|
|
5
|
+
options
|
|
6
|
+
};
|
|
12
7
|
}
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
//#endregion
|
|
9
|
+
//#region src/motion/measure.ts
|
|
10
|
+
/**
|
|
11
|
+
* Measures an element before it is added to the DOM
|
|
12
|
+
* @param el The element to measure
|
|
13
|
+
* @param fn The function to use to get the desired measurement (e.g. el.offsetHeight)
|
|
14
|
+
*/
|
|
15
15
|
function measure(el, fn) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
16
|
+
let oldVisibility = el.style.visibility;
|
|
17
|
+
let oldPosition = el.style.position;
|
|
18
|
+
let oldParent = el.parentNode;
|
|
19
|
+
let oldBefore = el.nextSibling;
|
|
20
|
+
el.style.visibility = "hidden";
|
|
21
|
+
el.style.position = "absolute";
|
|
22
|
+
document.body.appendChild(el);
|
|
23
|
+
let result = fn(el);
|
|
24
|
+
el.parentNode.removeChild(el);
|
|
25
|
+
if (oldParent !== null) {
|
|
26
|
+
oldParent.insertBefore(el, oldBefore);
|
|
27
|
+
el.style.visibility = oldVisibility;
|
|
28
|
+
el.style.position = oldPosition;
|
|
29
|
+
}
|
|
30
|
+
return result;
|
|
31
31
|
}
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
//#endregion
|
|
33
|
+
//#region src/motion/grow.ts
|
|
34
34
|
function grow(el, options) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
height: height + "px"
|
|
47
|
-
}
|
|
48
|
-
];
|
|
49
|
-
return { keyframes, options };
|
|
35
|
+
return {
|
|
36
|
+
keyframes: [{
|
|
37
|
+
height: "0px",
|
|
38
|
+
overflow: "hidden",
|
|
39
|
+
paddingTop: "0px",
|
|
40
|
+
paddingBottom: "0px",
|
|
41
|
+
marginTop: "0px",
|
|
42
|
+
marginBottom: "0px"
|
|
43
|
+
}, { height: measure(el, (el) => el.clientHeight) + "px" }],
|
|
44
|
+
options
|
|
45
|
+
};
|
|
50
46
|
}
|
|
51
|
-
|
|
52
|
-
|
|
47
|
+
//#endregion
|
|
48
|
+
//#region src/motion/slide.ts
|
|
53
49
|
function slide(el, options) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
el.style.bottom = "0px";
|
|
82
|
-
const height = measure(el, (el2) => el2.offsetHeight);
|
|
83
|
-
const keyframes = [
|
|
84
|
-
{ transform: `translateY(${height}px)` },
|
|
85
|
-
{ transform: "translateY(0px)" }
|
|
86
|
-
];
|
|
87
|
-
return { keyframes, options };
|
|
88
|
-
}
|
|
89
|
-
}
|
|
50
|
+
el.style.position = "fixed";
|
|
51
|
+
switch (options?.side ?? "left") {
|
|
52
|
+
case "left":
|
|
53
|
+
el.style.left = "0px";
|
|
54
|
+
return {
|
|
55
|
+
keyframes: [{ transform: `translateX(-${measure(el, (el) => el.offsetWidth)}px)` }, { transform: "translateX(0px)" }],
|
|
56
|
+
options
|
|
57
|
+
};
|
|
58
|
+
case "top":
|
|
59
|
+
el.style.top = "0px";
|
|
60
|
+
return {
|
|
61
|
+
keyframes: [{ transform: `translateY(-${measure(el, (el) => el.offsetHeight)}px)` }, { transform: "translateY(0px)" }],
|
|
62
|
+
options
|
|
63
|
+
};
|
|
64
|
+
case "right":
|
|
65
|
+
el.style.right = "0px";
|
|
66
|
+
return {
|
|
67
|
+
keyframes: [{ transform: `translateX(${measure(el, (el) => el.offsetWidth)}px)` }, { transform: "translateX(0px)" }],
|
|
68
|
+
options
|
|
69
|
+
};
|
|
70
|
+
case "bottom":
|
|
71
|
+
el.style.bottom = "0px";
|
|
72
|
+
return {
|
|
73
|
+
keyframes: [{ transform: `translateY(${measure(el, (el) => el.offsetHeight)}px)` }, { transform: "translateY(0px)" }],
|
|
74
|
+
options
|
|
75
|
+
};
|
|
76
|
+
}
|
|
90
77
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
measure,
|
|
95
|
-
slide
|
|
96
|
-
};
|
|
78
|
+
//#endregion
|
|
79
|
+
export { fade, grow, measure, slide };
|
|
80
|
+
|
|
97
81
|
//# sourceMappingURL=index.js.map
|
package/dist/motion/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/motion/fade.ts","../../src/motion/measure.ts","../../src/motion/grow.ts","../../src/motion/slide.ts"],"sourcesContent":["import { type Animation } from \"@torpor/view\";\n\nexport default function fade(\n\t_el: HTMLElement,\n\toptions?: number | KeyframeAnimationOptions,\n): Animation {\n\tconst keyframes = [\n\t\t{\n\t\t\topacity: 0,\n\t\t},\n\t\t{\n\t\t\topacity: 1,\n\t\t},\n\t];\n\treturn { keyframes, options };\n}\n","/**\n * Measures an element before it is added to the DOM\n * @param el The element to measure\n * @param fn The function to use to get the desired measurement (e.g. el.offsetHeight)\n */\nexport default function measure(el: HTMLElement, fn: (
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/motion/fade.ts","../../src/motion/measure.ts","../../src/motion/grow.ts","../../src/motion/slide.ts"],"sourcesContent":["import { type Animation } from \"@torpor/view\";\n\nexport default function fade(\n\t_el: HTMLElement,\n\toptions?: number | KeyframeAnimationOptions,\n): Animation {\n\tconst keyframes = [\n\t\t{\n\t\t\topacity: 0,\n\t\t},\n\t\t{\n\t\t\topacity: 1,\n\t\t},\n\t];\n\treturn { keyframes, options };\n}\n","/**\n * Measures an element before it is added to the DOM\n * @param el The element to measure\n * @param fn The function to use to get the desired measurement (e.g. el.offsetHeight)\n */\nexport default function measure(el: HTMLElement, fn: (_el: HTMLElement) => number): number {\n\t// From https://stackoverflow.com/a/46707458\n\tlet oldVisibility = el.style.visibility;\n\tlet oldPosition = el.style.position;\n\n\tlet oldParent = el.parentNode;\n\tlet oldBefore = el.nextSibling;\n\n\tel.style.visibility = \"hidden\";\n\tel.style.position = \"absolute\";\n\n\tdocument.body.appendChild(el);\n\tlet result = fn(el);\n\tel.parentNode!.removeChild(el);\n\n\tif (oldParent !== null) {\n\t\toldParent.insertBefore(el, oldBefore);\n\t\tel.style.visibility = oldVisibility;\n\t\tel.style.position = oldPosition;\n\t}\n\n\treturn result;\n}\n","import { type Animation } from \"@torpor/view\";\nimport measure from \"./measure\";\n\nexport default function grow(\n\tel: HTMLElement,\n\toptions?: number | KeyframeAnimationOptions,\n): Animation {\n\tconst height = measure(el, (el) => el.clientHeight);\n\tconst keyframes = [\n\t\t{\n\t\t\theight: \"0px\",\n\t\t\toverflow: \"hidden\",\n\t\t\tpaddingTop: \"0px\",\n\t\t\tpaddingBottom: \"0px\",\n\t\t\tmarginTop: \"0px\",\n\t\t\tmarginBottom: \"0px\",\n\t\t},\n\t\t{\n\t\t\theight: height + \"px\",\n\t\t},\n\t];\n\treturn { keyframes, options };\n}\n","import { type Animation } from \"@torpor/view\";\nimport measure from \"./measure\";\n\ninterface Options extends KeyframeAnimationOptions {\n\tside: \"left\" | \"right\" | \"top\" | \"bottom\";\n}\n\nexport default function slide(el: HTMLElement, options?: Options): Animation {\n\tel.style.position = \"fixed\";\n\tswitch (options?.side ?? \"left\") {\n\t\tcase \"left\": {\n\t\t\tel.style.left = \"0px\";\n\t\t\tconst width = measure(el, (el) => el.offsetWidth);\n\t\t\tconst keyframes = [\n\t\t\t\t{ transform: `translateX(-${width}px)` },\n\t\t\t\t{ transform: \"translateX(0px)\" },\n\t\t\t];\n\t\t\treturn { keyframes, options };\n\t\t}\n\t\tcase \"top\": {\n\t\t\tel.style.top = \"0px\";\n\t\t\tconst height = measure(el, (el) => el.offsetHeight);\n\t\t\tconst keyframes = [\n\t\t\t\t{ transform: `translateY(-${height}px)` },\n\t\t\t\t{ transform: \"translateY(0px)\" },\n\t\t\t];\n\t\t\treturn { keyframes, options };\n\t\t}\n\t\tcase \"right\": {\n\t\t\tel.style.right = \"0px\";\n\t\t\tconst width = measure(el, (el) => el.offsetWidth);\n\t\t\tconst keyframes = [{ transform: `translateX(${width}px)` }, { transform: \"translateX(0px)\" }];\n\t\t\treturn { keyframes, options };\n\t\t}\n\t\tcase \"bottom\": {\n\t\t\tel.style.bottom = \"0px\";\n\t\t\tconst height = measure(el, (el) => el.offsetHeight);\n\t\t\tconst keyframes = [\n\t\t\t\t{ transform: `translateY(${height}px)` },\n\t\t\t\t{ transform: \"translateY(0px)\" },\n\t\t\t];\n\t\t\treturn { keyframes, options };\n\t\t}\n\t}\n}\n"],"mappings":";AAEA,SAAwB,KACvB,KACA,SACY;CASZ,OAAO;EAAE,WAAA,CAPR,EACC,SAAS,EACV,GACA,EACC,SAAS,EACV,CAEgB;EAAG;CAAQ;AAC7B;;;;;;;;ACVA,SAAwB,QAAQ,IAAiB,IAA0C;CAE1F,IAAI,gBAAgB,GAAG,MAAM;CAC7B,IAAI,cAAc,GAAG,MAAM;CAE3B,IAAI,YAAY,GAAG;CACnB,IAAI,YAAY,GAAG;CAEnB,GAAG,MAAM,aAAa;CACtB,GAAG,MAAM,WAAW;CAEpB,SAAS,KAAK,YAAY,EAAE;CAC5B,IAAI,SAAS,GAAG,EAAE;CAClB,GAAG,WAAY,YAAY,EAAE;CAE7B,IAAI,cAAc,MAAM;EACvB,UAAU,aAAa,IAAI,SAAS;EACpC,GAAG,MAAM,aAAa;EACtB,GAAG,MAAM,WAAW;CACrB;CAEA,OAAO;AACR;;;ACxBA,SAAwB,KACvB,IACA,SACY;CAeZ,OAAO;EAAE,WAAA,CAZR;GACC,QAAQ;GACR,UAAU;GACV,YAAY;GACZ,eAAe;GACf,WAAW;GACX,cAAc;EACf,GACA,EACC,QAXa,QAAQ,KAAK,OAAO,GAAG,YAWvB,IAAI,KAClB,CAEgB;EAAG;CAAQ;AAC7B;;;ACfA,SAAwB,MAAM,IAAiB,SAA8B;CAC5E,GAAG,MAAM,WAAW;CACpB,QAAQ,SAAS,QAAQ,QAAzB;EACC,KAAK;GACJ,GAAG,MAAM,OAAO;GAMhB,OAAO;IAAE,WAAA,CAHR,EAAE,WAAW,eAFA,QAAQ,KAAK,OAAO,GAAG,WAEJ,EAAE,KAAK,GACvC,EAAE,WAAW,kBAAkB,CAEf;IAAG;GAAQ;EAE7B,KAAK;GACJ,GAAG,MAAM,MAAM;GAMf,OAAO;IAAE,WAAA,CAHR,EAAE,WAAW,eAFC,QAAQ,KAAK,OAAO,GAAG,YAEJ,EAAE,KAAK,GACxC,EAAE,WAAW,kBAAkB,CAEf;IAAG;GAAQ;EAE7B,KAAK;GACJ,GAAG,MAAM,QAAQ;GAGjB,OAAO;IAAE,WAAA,CADU,EAAE,WAAW,cADlB,QAAQ,KAAK,OAAO,GAAG,WACa,EAAE,KAAK,GAAG,EAAE,WAAW,kBAAkB,CAC1E;IAAG;GAAQ;EAE7B,KAAK;GACJ,GAAG,MAAM,SAAS;GAMlB,OAAO;IAAE,WAAA,CAHR,EAAE,WAAW,cAFC,QAAQ,KAAK,OAAO,GAAG,YAEL,EAAE,KAAK,GACvC,EAAE,WAAW,kBAAkB,CAEf;IAAG;GAAQ;CAE9B;AACD"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { beginDrag, endDrag, writeDragType } from "../utils/dragState";
|
|
2
|
+
|
|
3
|
+
interface DraggableOptions {
|
|
4
|
+
/** High-level kind for drop targets to filter on */
|
|
5
|
+
kind?: string;
|
|
6
|
+
/** Payload handed to the drop target that receives this drag */
|
|
7
|
+
data?: any;
|
|
8
|
+
/**
|
|
9
|
+
* Called when a drag starts; returning false cancels the drag entirely
|
|
10
|
+
* (useful for drags-in-progress controls, readonly flags etc)
|
|
11
|
+
*/
|
|
12
|
+
onstart?: (e: DragEvent) => boolean | void;
|
|
13
|
+
/** Called when the drag finishes, whether it was dropped or cancelled */
|
|
14
|
+
onend?: (e: DragEvent) => void;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Makes an element draggable via the native HTML5 drag & drop API.
|
|
19
|
+
*
|
|
20
|
+
* ```
|
|
21
|
+
* <li onmount={(el) => draggable(el, { kind: "list-item", data: item })}>
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* Pairs with dropTarget, which receives `{ kind, data }` for accepted
|
|
25
|
+
* drops. The tracked drag is always cleaned up on dragend, so handlers
|
|
26
|
+
* don't leak between drags.
|
|
27
|
+
*/
|
|
28
|
+
export default function draggable(node: HTMLElement, options: DraggableOptions): () => void {
|
|
29
|
+
let started = false;
|
|
30
|
+
|
|
31
|
+
function handleStart(e: DragEvent) {
|
|
32
|
+
if (options.onstart?.(e) === false) {
|
|
33
|
+
e.preventDefault();
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const info = beginDrag(options.kind ?? "", options.data);
|
|
37
|
+
writeDragType(e, info.id);
|
|
38
|
+
if (e.dataTransfer) {
|
|
39
|
+
e.dataTransfer.effectAllowed = "move";
|
|
40
|
+
}
|
|
41
|
+
started = true;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function handleEnd(e: DragEvent) {
|
|
45
|
+
if (started) {
|
|
46
|
+
started = false;
|
|
47
|
+
endDrag();
|
|
48
|
+
options.onend?.(e);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
node.addEventListener("dragstart", handleStart);
|
|
53
|
+
node.addEventListener("dragend", handleEnd);
|
|
54
|
+
|
|
55
|
+
return () => {
|
|
56
|
+
node.removeEventListener("dragstart", handleStart);
|
|
57
|
+
node.removeEventListener("dragend", handleEnd);
|
|
58
|
+
if (started) {
|
|
59
|
+
started = false;
|
|
60
|
+
endDrag();
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { type DragInfo, resolveDrag } from "../utils/dragState";
|
|
2
|
+
|
|
3
|
+
interface DropTargetOptions {
|
|
4
|
+
/** Filters incoming drags; only accepted kinds receive over/drop calls */
|
|
5
|
+
accepts?: (info: DragInfo) => boolean;
|
|
6
|
+
/** The cursor effect shown while hovering (default "move") */
|
|
7
|
+
effect?: "move" | "copy" | "link";
|
|
8
|
+
/** Called continuously while an accepted drag hovers the target */
|
|
9
|
+
onover?: (info: DragInfo, e: DragEvent) => void;
|
|
10
|
+
/** Called once when hovering starts */
|
|
11
|
+
onenter?: (info: DragInfo, e: DragEvent) => void;
|
|
12
|
+
/** Called once when hovering ends */
|
|
13
|
+
onleave?: () => void;
|
|
14
|
+
/** Called when an accepted drag is dropped; returning false rejects it */
|
|
15
|
+
ondrop?: (info: DragInfo, e: DragEvent) => boolean | void;
|
|
16
|
+
/** Class applied while an accepted drag hovers the target */
|
|
17
|
+
dragClass?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Turns an element into a drop target for native HTML5 drags.
|
|
22
|
+
*
|
|
23
|
+
* ```
|
|
24
|
+
* <div
|
|
25
|
+
* class="panel"
|
|
26
|
+
* onmount={(el) =>
|
|
27
|
+
* dropTarget(el, {
|
|
28
|
+
* accepts: (info) => info.kind === "list-item",
|
|
29
|
+
* dragClass: "dropping",
|
|
30
|
+
* ondrop: (info) => addItem(info.data),
|
|
31
|
+
* })
|
|
32
|
+
* }
|
|
33
|
+
* />
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* Handles the tedious parts of the platform API -- preventing the browser's
|
|
37
|
+
* default navigation, resolving the tracked drag, effect negotiation --
|
|
38
|
+
* so components only express what they accept and what happens on drop.
|
|
39
|
+
*/
|
|
40
|
+
export default function dropTarget(node: HTMLElement, options: DropTargetOptions): () => void {
|
|
41
|
+
let hoverClassApplied = false;
|
|
42
|
+
|
|
43
|
+
function accepts(info: DragInfo | undefined): info is DragInfo {
|
|
44
|
+
return !!info && (!options.accepts || options.accepts(info));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function applyHover() {
|
|
48
|
+
if (!hoverClassApplied && options.dragClass) {
|
|
49
|
+
hoverClassApplied = true;
|
|
50
|
+
node.classList.add(options.dragClass);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function removeHover() {
|
|
55
|
+
if (hoverClassApplied) {
|
|
56
|
+
hoverClassApplied = false;
|
|
57
|
+
node.classList.remove(options.dragClass!);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function handleOver(e: DragEvent) {
|
|
62
|
+
const info = resolveDrag(e);
|
|
63
|
+
if (!accepts(info)) return;
|
|
64
|
+
|
|
65
|
+
e.preventDefault();
|
|
66
|
+
if (e.dataTransfer) {
|
|
67
|
+
e.dataTransfer.dropEffect = options.effect ?? "move";
|
|
68
|
+
}
|
|
69
|
+
applyHover();
|
|
70
|
+
options.onover?.(info!, e);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function handleEnter(e: DragEvent) {
|
|
74
|
+
const info = resolveDrag(e);
|
|
75
|
+
if (!accepts(info)) return;
|
|
76
|
+
applyHover();
|
|
77
|
+
options.onenter?.(info!, e);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function handleLeave(e: DragEvent) {
|
|
81
|
+
const related = e.relatedTarget as Node | null;
|
|
82
|
+
if (related && node.contains(related)) return;
|
|
83
|
+
removeHover();
|
|
84
|
+
options.onleave?.();
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function handleDrop(e: DragEvent) {
|
|
88
|
+
e.preventDefault();
|
|
89
|
+
removeHover();
|
|
90
|
+
|
|
91
|
+
const info = resolveDrag(e);
|
|
92
|
+
if (!accepts(info)) return;
|
|
93
|
+
options.ondrop?.(info!, e);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
node.addEventListener("dragover", handleOver);
|
|
97
|
+
node.addEventListener("dragenter", handleEnter);
|
|
98
|
+
node.addEventListener("dragleave", handleLeave);
|
|
99
|
+
node.addEventListener("drop", handleDrop);
|
|
100
|
+
|
|
101
|
+
return () => {
|
|
102
|
+
removeHover();
|
|
103
|
+
node.removeEventListener("dragover", handleOver);
|
|
104
|
+
node.removeEventListener("dragenter", handleEnter);
|
|
105
|
+
node.removeEventListener("dragleave", handleLeave);
|
|
106
|
+
node.removeEventListener("drop", handleDrop);
|
|
107
|
+
};
|
|
108
|
+
}
|
|
@@ -10,7 +10,7 @@ export default function hoverTrigger(node: HTMLElement, options: HoverTriggerOpt
|
|
|
10
10
|
const hoverDelay = options.hoverDelay || 1000;
|
|
11
11
|
const touchDelay = options.touchDelay || 1000;
|
|
12
12
|
|
|
13
|
-
let interval:
|
|
13
|
+
let interval: ReturnType<typeof setTimeout> | undefined;
|
|
14
14
|
|
|
15
15
|
// Add click event handlers to the node
|
|
16
16
|
node.addEventListener("mouseenter", handleMouseEnter);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { $run } from "@torpor/view";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Runs a function once on subscription and re-runs it whenever any reactive
|
|
5
|
+
* state it read changes. The callback receives a `first` flag that is `true`
|
|
6
|
+
* on the initial run and `false` on every subsequent (change-driven) run, so
|
|
7
|
+
* callers can distinguish setup from "react to a change" without maintaining
|
|
8
|
+
* their own `firstChange` flag.
|
|
9
|
+
*
|
|
10
|
+
* This is a small helper over `$run` kept in @torpor/ui for its components;
|
|
11
|
+
* library authors can copy it if they need the same pattern.
|
|
12
|
+
*
|
|
13
|
+
* @param fn The function to run, receiving a `first` flag. May return a
|
|
14
|
+
* cleanup function.
|
|
15
|
+
*/
|
|
16
|
+
export default function $handle(fn: (first: boolean) => void | (() => void)): void {
|
|
17
|
+
let firstRun = true;
|
|
18
|
+
$run(() => {
|
|
19
|
+
const first = firstRun;
|
|
20
|
+
firstRun = false;
|
|
21
|
+
return fn(first);
|
|
22
|
+
});
|
|
23
|
+
}
|