@torpor/ui 0.3.5 → 0.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Chart/BarChart.torp +159 -0
- package/dist/Chart/DataSeries.ts +5 -0
- package/dist/Chart/GridLines.torp +62 -0
- package/dist/Chart/LineChart.torp +196 -0
- package/dist/Chart/PieChart.torp +145 -0
- package/dist/Chart/ScatterChart.torp +215 -0
- package/dist/Chart/SparkLine.torp +71 -0
- package/dist/Chart/XAxis.torp +60 -0
- package/dist/Chart/YAxis.torp +41 -0
- package/dist/Chart/index.d.ts +220 -0
- package/dist/Chart/index.js +34 -0
- package/dist/Chart/index.js.map +1 -0
- package/dist/Form/TextArea.torp +3 -0
- package/dist/Form/index.d.ts +2 -0
- package/dist/metafile-esm.json +1 -1
- package/dist/utils/chartColors.ts +17 -0
- package/dist/utils/chartUtils.ts +71 -0
- package/package.json +10 -3
- package/CHANGELOG.md +0 -344
- package/scripts/postbuild.ts +0 -127
- package/src/Accordion/Accordion.torp +0 -230
- package/src/Accordion/AccordionContent.torp +0 -46
- package/src/Accordion/AccordionHeader.torp +0 -45
- package/src/Accordion/AccordionItem.torp +0 -101
- package/src/Accordion/AccordionTrigger.torp +0 -70
- package/src/Accordion/AccordionTypes.ts +0 -36
- package/src/Accordion/index.ts +0 -7
- package/src/Breadcrumb/Breadcrumb.torp +0 -45
- package/src/Breadcrumb/BreadcrumbItem.torp +0 -30
- package/src/Breadcrumb/BreadcrumbSeparator.torp +0 -27
- package/src/Breadcrumb/index.ts +0 -5
- package/src/Calendar/Calendar.torp +0 -277
- package/src/Calendar/CalendarDay.torp +0 -78
- package/src/Calendar/CalendarTypes.ts +0 -22
- package/src/Calendar/index.ts +0 -4
- package/src/Contextual/Contextual.torp +0 -129
- package/src/Contextual/ContextualContent.torp +0 -112
- package/src/Contextual/ContextualTrigger.torp +0 -70
- package/src/Contextual/ContextualTypes.ts +0 -30
- package/src/Contextual/index.ts +0 -5
- package/src/Dialog/Dialog.torp +0 -136
- package/src/Dialog/DialogBody.torp +0 -44
- package/src/Dialog/DialogButton.torp +0 -66
- package/src/Dialog/DialogFooter.torp +0 -25
- package/src/Dialog/DialogHeader.torp +0 -45
- package/src/Dialog/DialogTypes.ts +0 -17
- package/src/Dialog/index.ts +0 -7
- package/src/Disclosure/Disclosure.torp +0 -82
- package/src/Disclosure/DisclosureContent.torp +0 -46
- package/src/Disclosure/DisclosureHeader.torp +0 -45
- package/src/Disclosure/DisclosureTrigger.torp +0 -47
- package/src/Disclosure/DisclosureTypes.ts +0 -13
- package/src/Disclosure/index.ts +0 -6
- package/src/Drawer/Drawer.torp +0 -127
- package/src/Drawer/DrawerContent.torp +0 -83
- package/src/Drawer/DrawerOverlay.torp +0 -42
- package/src/Drawer/DrawerTrigger.torp +0 -39
- package/src/Drawer/DrawerTypes.ts +0 -24
- package/src/Drawer/index.ts +0 -6
- package/src/Form/CheckBox.torp +0 -94
- package/src/Form/Field.torp +0 -95
- package/src/Form/File.torp +0 -102
- package/src/Form/Form.torp +0 -147
- package/src/Form/FormTypes.ts +0 -35
- package/src/Form/Hidden.torp +0 -25
- package/src/Form/Input.torp +0 -112
- package/src/Form/Label.torp +0 -35
- package/src/Form/Message.torp +0 -39
- package/src/Form/Option.torp +0 -28
- package/src/Form/Select.torp +0 -101
- package/src/Form/StandardSchemaV1.ts +0 -70
- package/src/Form/TextArea.torp +0 -105
- package/src/Form/index.ts +0 -13
- package/src/Menu/Menu.torp +0 -174
- package/src/Menu/MenuButton.torp +0 -74
- package/src/Menu/MenuCheck.torp +0 -89
- package/src/Menu/MenuGroup.torp +0 -31
- package/src/Menu/MenuIndicator.torp +0 -40
- package/src/Menu/MenuPopout.torp +0 -83
- package/src/Menu/MenuPopoutContent.torp +0 -84
- package/src/Menu/MenuPopoutTrigger.torp +0 -128
- package/src/Menu/MenuRadio.torp +0 -103
- package/src/Menu/MenuRadioGroup.torp +0 -109
- package/src/Menu/MenuSeparator.torp +0 -26
- package/src/Menu/MenuTypes.ts +0 -60
- package/src/Menu/index.ts +0 -25
- package/src/MenuBar/MenuBar.torp +0 -162
- package/src/MenuBar/MenuBarItem.torp +0 -116
- package/src/MenuBar/MenuBarItemContent.torp +0 -119
- package/src/MenuBar/MenuBarItemTrigger.torp +0 -99
- package/src/MenuBar/MenuBarTypes.ts +0 -36
- package/src/MenuBar/index.ts +0 -6
- package/src/Modal/Modal.torp +0 -122
- package/src/Modal/ModalContent.torp +0 -81
- package/src/Modal/ModalOverlay.torp +0 -42
- package/src/Modal/ModalTrigger.torp +0 -54
- package/src/Modal/ModalTypes.ts +0 -22
- package/src/Modal/index.ts +0 -10
- package/src/Modal/showModal.ts +0 -19
- package/src/Modal/showPrompt.ts +0 -23
- package/src/NavMenu/NavMenu.torp +0 -190
- package/src/NavMenu/NavMenuButton.torp +0 -55
- package/src/NavMenu/NavMenuElement.torp +0 -55
- package/src/NavMenu/NavMenuGroup.torp +0 -41
- package/src/NavMenu/NavMenuGroupHeader.torp +0 -41
- package/src/NavMenu/NavMenuLink.torp +0 -60
- package/src/NavMenu/NavMenuPopout.torp +0 -89
- package/src/NavMenu/NavMenuPopoutButton.torp +0 -129
- package/src/NavMenu/NavMenuPopoutContent.torp +0 -92
- package/src/NavMenu/NavMenuSeparator.torp +0 -24
- package/src/NavMenu/NavMenuTypes.ts +0 -32
- package/src/NavMenu/index.ts +0 -23
- package/src/Notification/Notification.torp +0 -71
- package/src/Notification/NotificationClose.torp +0 -39
- package/src/Notification/NotificationContainer.torp +0 -26
- package/src/Notification/NotificationContent.torp +0 -25
- package/src/Notification/NotificationTypes.ts +0 -5
- package/src/Notification/index.ts +0 -13
- package/src/Notification/showNotification.ts +0 -30
- package/src/Popover/Popover.torp +0 -129
- package/src/Popover/PopoverContent.torp +0 -117
- package/src/Popover/PopoverTrigger.torp +0 -62
- package/src/Popover/PopoverTypes.ts +0 -30
- package/src/Popover/index.ts +0 -6
- package/src/Popover/showPopover.ts +0 -24
- package/src/Slider/Slider.torp +0 -84
- package/src/Slider/index.ts +0 -3
- package/src/TabGroup/TabContent.torp +0 -49
- package/src/TabGroup/TabGroup.torp +0 -250
- package/src/TabGroup/TabGroupTypes.ts +0 -44
- package/src/TabGroup/TabHeader.torp +0 -81
- package/src/TabGroup/TabList.torp +0 -61
- package/src/TabGroup/TabTrigger.torp +0 -76
- package/src/TabGroup/index.ts +0 -7
- package/src/ambient.d.ts +0 -7
- package/src/icons/ArrowDown.torp +0 -18
- package/src/icons/ArrowLeft.torp +0 -18
- package/src/icons/ArrowRight.torp +0 -18
- package/src/icons/ArrowUp.torp +0 -18
- package/src/icons/Bars.torp +0 -20
- package/src/icons/Check.torp +0 -18
- package/src/icons/ChevronDown.torp +0 -18
- package/src/icons/ChevronLeft.torp +0 -18
- package/src/icons/ChevronRight.torp +0 -18
- package/src/icons/ChevronUp.torp +0 -18
- package/src/icons/Cross.torp +0 -19
- package/src/icons/IconTypes.ts +0 -10
- package/src/icons/Loading.torp +0 -19
- package/src/icons/Minus.torp +0 -18
- package/src/icons/Plus.torp +0 -19
- package/src/icons/index.ts +0 -31
- package/src/motion/fade.ts +0 -16
- package/src/motion/grow.ts +0 -23
- package/src/motion/index.ts +0 -6
- package/src/motion/measure.ts +0 -28
- package/src/motion/slide.ts +0 -45
- package/src/mount/clickPopover.ts +0 -51
- package/src/mount/contextPopover.ts +0 -51
- package/src/mount/disableScroll.ts +0 -28
- package/src/mount/hoverPopover.ts +0 -58
- package/src/mount/hoverTrigger.ts +0 -59
- package/src/mount/trapFocus.ts +0 -58
- package/src/utils/dateUtils.ts +0 -244
- package/src/utils/documentEvents.ts +0 -17
- package/src/utils/getId.ts +0 -6
- package/src/utils/getScrollParent.ts +0 -22
- package/src/utils/setContextPosition.ts +0 -31
- package/src/utils/setPopoverPosition.ts +0 -142
- package/test/Accordion/accessibility.test.ts +0 -59
- package/test/Accordion/components/AccordionAccessibility.torp +0 -44
- package/test/Accordion/components/AccordionKeyboard.torp +0 -32
- package/test/Accordion/components/AccordionList.torp +0 -23
- package/test/Accordion/components/AccordionMultiple.torp +0 -32
- package/test/Accordion/components/AccordionSingle.torp +0 -32
- package/test/Accordion/for-items.test.ts +0 -52
- package/test/Accordion/keyboard.test.ts +0 -64
- package/test/Accordion/multiple-item-toggle.test.ts +0 -32
- package/test/Accordion/multiple-item-value.test.ts +0 -17
- package/test/Accordion/single-item-toggle.test.ts +0 -31
- package/test/Accordion/single-item-value.test.ts +0 -17
- package/test/Breadcrumb/accessibility.test.ts +0 -29
- package/test/Breadcrumb/basic.test.ts +0 -17
- package/test/Breadcrumb/components/BreadcrumbTest.torp +0 -15
- package/test/Calendar/components/CalendarTest.torp +0 -9
- package/test/Calendar/default.test.ts +0 -18
- package/test/Dialog/accessibility-alert.test.ts +0 -40
- package/test/Dialog/accessibility-modal.test.ts +0 -52
- package/test/Dialog/components/DialogAccessibility.torp +0 -25
- package/test/Dialog/components/DialogFunction.torp +0 -36
- package/test/Dialog/components/DialogModal.torp +0 -30
- package/test/Dialog/components/DialogVariable.torp +0 -33
- package/test/Dialog/function.test.ts +0 -26
- package/test/Dialog/variable.test.ts +0 -27
- package/test/Disclosure/accessibility.test.ts +0 -31
- package/test/Disclosure/components/DisclosureTest.torp +0 -17
- package/test/Disclosure/default.test.ts +0 -15
- package/test/Disclosure/toggle.test.ts +0 -20
- package/test/Form/components/FieldTest.torp +0 -25
- package/test/Form/components/FormTest.torp +0 -31
- package/test/Form/components/InputTest.torp +0 -9
- package/test/Form/field.test.ts +0 -34
- package/test/Form/form.test.ts +0 -34
- package/test/Form/input.test.ts +0 -19
- package/test/Menu/accessibility.test.ts +0 -83
- package/test/Menu/basic.test.ts +0 -58
- package/test/Menu/components/MenuAccessibility.torp +0 -59
- package/test/Menu/components/MenuBasic.torp +0 -58
- package/test/MenuBar/accessibility.test.ts +0 -87
- package/test/MenuBar/basic.test.ts +0 -22
- package/test/MenuBar/components/MenuBarAccessibility.torp +0 -34
- package/test/MenuBar/components/MenuBarBasic.torp +0 -25
- package/test/NavMenu/accessibility.test.ts +0 -97
- package/test/NavMenu/basic.test.ts +0 -22
- package/test/NavMenu/components/NavMenuAccessibility.torp +0 -35
- package/test/NavMenu/components/NavMenuBasic.torp +0 -28
- package/test/Notification/accessibility.test.ts +0 -21
- package/test/Notification/components/CustomNotification.torp +0 -14
- package/test/Notification/components/NotificationAccessibility.torp +0 -14
- package/test/Notification/components/NotificationFunction.torp +0 -17
- package/test/Notification/components/NotificationVariable.torp +0 -22
- package/test/Notification/function.test.ts +0 -25
- package/test/Notification/variable.test.ts +0 -25
- package/test/Popover/components/CustomDialog.torp +0 -25
- package/test/Popover/components/PopoverFunction.torp +0 -37
- package/test/Popover/components/PopoverTrigger.torp +0 -36
- package/test/Popover/components/PopoverVariable.torp +0 -40
- package/test/Popover/function.test.ts +0 -21
- package/test/Popover/trigger.test.ts +0 -27
- package/test/Popover/variable.test.ts +0 -27
- package/test/TabGroup/accessibility.test.ts +0 -67
- package/test/TabGroup/components/TabGroupAccessibility.torp +0 -28
- package/test/TabGroup/components/TabGroupKeyboard.torp +0 -28
- package/test/TabGroup/components/TabGroupList.torp +0 -26
- package/test/TabGroup/components/TabGroupTrigger.torp +0 -28
- package/test/TabGroup/for-items.test.ts +0 -52
- package/test/TabGroup/item-trigger.test.ts +0 -33
- package/test/TabGroup/item-value.test.ts +0 -17
- package/test/TabGroup/keyboard.test.ts +0 -72
- package/tsconfig.json +0 -4
- package/tsup.config.ts +0 -37
- package/vitest.config.ts +0 -12
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { type IconProps } from "./IconTypes";
|
|
2
|
-
|
|
3
|
-
export default function ChevronRight($props: IconProps | undefined) {
|
|
4
|
-
@render {
|
|
5
|
-
<svg
|
|
6
|
-
{$props?.id}
|
|
7
|
-
class={["torp-icon", $props?.class]}
|
|
8
|
-
{$props?.style}
|
|
9
|
-
viewBox="0 0 100 100"
|
|
10
|
-
stroke-linejoin="round"
|
|
11
|
-
stroke-width="12"
|
|
12
|
-
>
|
|
13
|
-
<g>
|
|
14
|
-
<path d="M30,10 L70,50 L30,90" fill="none" />
|
|
15
|
-
</g>
|
|
16
|
-
</svg>
|
|
17
|
-
}
|
|
18
|
-
}
|
package/src/icons/ChevronUp.torp
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { type IconProps } from "./IconTypes";
|
|
2
|
-
|
|
3
|
-
export default function ChevronUp($props: IconProps | undefined) {
|
|
4
|
-
@render {
|
|
5
|
-
<svg
|
|
6
|
-
{$props?.id}
|
|
7
|
-
class={["torp-icon", $props?.class]}
|
|
8
|
-
{$props?.style}
|
|
9
|
-
viewBox="0 0 100 100"
|
|
10
|
-
stroke-linejoin="round"
|
|
11
|
-
stroke-width="12"
|
|
12
|
-
>
|
|
13
|
-
<g>
|
|
14
|
-
<path d="M10,70 L50,30 L90,70" fill="none" />
|
|
15
|
-
</g>
|
|
16
|
-
</svg>
|
|
17
|
-
}
|
|
18
|
-
}
|
package/src/icons/Cross.torp
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { type IconProps } from "./IconTypes";
|
|
2
|
-
|
|
3
|
-
export default function Cross($props: IconProps | undefined) {
|
|
4
|
-
@render {
|
|
5
|
-
<svg
|
|
6
|
-
{$props?.id}
|
|
7
|
-
class={["torp-icon", $props?.class]}
|
|
8
|
-
{$props?.style}
|
|
9
|
-
viewBox="0 0 100 100"
|
|
10
|
-
stroke-linejoin="round"
|
|
11
|
-
stroke-width="12"
|
|
12
|
-
>
|
|
13
|
-
<g>
|
|
14
|
-
<path d="M15,15 L85,85" />
|
|
15
|
-
<path d="M15,85 L85,15" />
|
|
16
|
-
</g>
|
|
17
|
-
</svg>
|
|
18
|
-
}
|
|
19
|
-
}
|
package/src/icons/IconTypes.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { ClassValue, StyleValue } from "@torpor/view";
|
|
2
|
-
|
|
3
|
-
export interface IconProps {
|
|
4
|
-
/** An ID for the svg element */
|
|
5
|
-
id?: string;
|
|
6
|
-
/** Classes for the svg element */
|
|
7
|
-
class?: ClassValue;
|
|
8
|
-
/** Styles for the root element */
|
|
9
|
-
style?: StyleValue;
|
|
10
|
-
}
|
package/src/icons/Loading.torp
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { type IconProps } from "./IconTypes";
|
|
2
|
-
|
|
3
|
-
export default function Loading($props: IconProps | undefined) {
|
|
4
|
-
@render {
|
|
5
|
-
<svg
|
|
6
|
-
{$props?.id}
|
|
7
|
-
class={["torp-icon", $props?.class]}
|
|
8
|
-
{$props?.style}
|
|
9
|
-
viewBox="0 0 100 100"
|
|
10
|
-
stroke-linejoin="round"
|
|
11
|
-
stroke-width="20"
|
|
12
|
-
>
|
|
13
|
-
<g>
|
|
14
|
-
<circle cx="50" cy="50" r="40" fill="none" opacity="0.3" />
|
|
15
|
-
<path d="M 22 22 A 40 40 0 0 1 78 22" fill="none" />
|
|
16
|
-
</g>
|
|
17
|
-
</svg>
|
|
18
|
-
}
|
|
19
|
-
}
|
package/src/icons/Minus.torp
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { type IconProps } from "./IconTypes";
|
|
2
|
-
|
|
3
|
-
export default function Minus($props: IconProps | undefined) {
|
|
4
|
-
@render {
|
|
5
|
-
<svg
|
|
6
|
-
{$props?.id}
|
|
7
|
-
class={["torp-icon", $props?.class]}
|
|
8
|
-
{$props?.style}
|
|
9
|
-
viewBox="0 0 100 100"
|
|
10
|
-
stroke-linejoin="round"
|
|
11
|
-
stroke-width="12"
|
|
12
|
-
>
|
|
13
|
-
<g>
|
|
14
|
-
<path d="M10,50 L90,50" />
|
|
15
|
-
</g>
|
|
16
|
-
</svg>
|
|
17
|
-
}
|
|
18
|
-
}
|
package/src/icons/Plus.torp
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { type IconProps } from "./IconTypes";
|
|
2
|
-
|
|
3
|
-
export default function Plus($props: IconProps | undefined) {
|
|
4
|
-
@render {
|
|
5
|
-
<svg
|
|
6
|
-
{$props?.id}
|
|
7
|
-
class={["torp-icon", $props?.class]}
|
|
8
|
-
{$props?.style}
|
|
9
|
-
viewBox="0 0 100 100"
|
|
10
|
-
stroke-linejoin="round"
|
|
11
|
-
stroke-width="12"
|
|
12
|
-
>
|
|
13
|
-
<g>
|
|
14
|
-
<path d="M50,10 L50,90" />
|
|
15
|
-
<path d="M10,50 L90,50" />
|
|
16
|
-
</g>
|
|
17
|
-
</svg>
|
|
18
|
-
}
|
|
19
|
-
}
|
package/src/icons/index.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
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 ChevronDown from "./ChevronDown.torp";
|
|
8
|
-
import ChevronLeft from "./ChevronLeft.torp";
|
|
9
|
-
import ChevronRight from "./ChevronRight.torp";
|
|
10
|
-
import ChevronUp from "./ChevronUp.torp";
|
|
11
|
-
import Cross from "./Cross.torp";
|
|
12
|
-
import Loading from "./Loading.torp";
|
|
13
|
-
import Minus from "./Minus.torp";
|
|
14
|
-
import Plus from "./Plus.torp";
|
|
15
|
-
|
|
16
|
-
export {
|
|
17
|
-
ArrowDown,
|
|
18
|
-
ArrowLeft,
|
|
19
|
-
ArrowRight,
|
|
20
|
-
ArrowUp,
|
|
21
|
-
Bars,
|
|
22
|
-
Check,
|
|
23
|
-
ChevronDown,
|
|
24
|
-
ChevronLeft,
|
|
25
|
-
ChevronRight,
|
|
26
|
-
ChevronUp,
|
|
27
|
-
Cross,
|
|
28
|
-
Loading,
|
|
29
|
-
Minus,
|
|
30
|
-
Plus,
|
|
31
|
-
};
|
package/src/motion/fade.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { type Animation } from "@torpor/view";
|
|
2
|
-
|
|
3
|
-
export default function fade(
|
|
4
|
-
_el: HTMLElement,
|
|
5
|
-
options?: number | KeyframeAnimationOptions,
|
|
6
|
-
): Animation {
|
|
7
|
-
const keyframes = [
|
|
8
|
-
{
|
|
9
|
-
opacity: 0,
|
|
10
|
-
},
|
|
11
|
-
{
|
|
12
|
-
opacity: 1,
|
|
13
|
-
},
|
|
14
|
-
];
|
|
15
|
-
return { keyframes, options };
|
|
16
|
-
}
|
package/src/motion/grow.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { type Animation } from "@torpor/view";
|
|
2
|
-
import measure from "./measure";
|
|
3
|
-
|
|
4
|
-
export default function grow(
|
|
5
|
-
el: HTMLElement,
|
|
6
|
-
options?: number | KeyframeAnimationOptions,
|
|
7
|
-
): Animation {
|
|
8
|
-
const height = measure(el, (el) => el.clientHeight);
|
|
9
|
-
const keyframes = [
|
|
10
|
-
{
|
|
11
|
-
height: "0px",
|
|
12
|
-
overflow: "hidden",
|
|
13
|
-
paddingTop: "0px",
|
|
14
|
-
paddingBottom: "0px",
|
|
15
|
-
marginTop: "0px",
|
|
16
|
-
marginBottom: "0px",
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
height: height + "px",
|
|
20
|
-
},
|
|
21
|
-
];
|
|
22
|
-
return { keyframes, options };
|
|
23
|
-
}
|
package/src/motion/index.ts
DELETED
package/src/motion/measure.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Measures an element before it is added to the DOM
|
|
3
|
-
* @param el The element to measure
|
|
4
|
-
* @param fn The function to use to get the desired measurement (e.g. el.offsetHeight)
|
|
5
|
-
*/
|
|
6
|
-
export default function measure(el: HTMLElement, fn: (_: HTMLElement) => number): number {
|
|
7
|
-
// From https://stackoverflow.com/a/46707458
|
|
8
|
-
let oldVisibility = el.style.visibility;
|
|
9
|
-
let oldPosition = el.style.position;
|
|
10
|
-
|
|
11
|
-
let oldParent = el.parentNode;
|
|
12
|
-
let oldBefore = el.nextSibling;
|
|
13
|
-
|
|
14
|
-
el.style.visibility = "hidden";
|
|
15
|
-
el.style.position = "absolute";
|
|
16
|
-
|
|
17
|
-
document.body.appendChild(el);
|
|
18
|
-
let result = fn(el);
|
|
19
|
-
el.parentNode!.removeChild(el);
|
|
20
|
-
|
|
21
|
-
if (oldParent !== null) {
|
|
22
|
-
oldParent.insertBefore(el, oldBefore);
|
|
23
|
-
el.style.visibility = oldVisibility;
|
|
24
|
-
el.style.position = oldPosition;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return result;
|
|
28
|
-
}
|
package/src/motion/slide.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { type Animation } from "@torpor/view";
|
|
2
|
-
import measure from "./measure";
|
|
3
|
-
|
|
4
|
-
interface Options extends KeyframeAnimationOptions {
|
|
5
|
-
side: "left" | "right" | "top" | "bottom";
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export default function slide(el: HTMLElement, options?: Options): Animation {
|
|
9
|
-
let position = options?.side ?? "left";
|
|
10
|
-
switch (position) {
|
|
11
|
-
case "left": {
|
|
12
|
-
el.style.left = "0px";
|
|
13
|
-
const width = measure(el, (el) => el.offsetWidth);
|
|
14
|
-
const keyframes = [
|
|
15
|
-
{ transform: `translateX(-${width}px)` },
|
|
16
|
-
{ transform: "translateX(0px)" },
|
|
17
|
-
];
|
|
18
|
-
return { keyframes, options };
|
|
19
|
-
}
|
|
20
|
-
case "top": {
|
|
21
|
-
el.style.top = "0px";
|
|
22
|
-
const height = measure(el, (el) => el.offsetHeight);
|
|
23
|
-
const keyframes = [
|
|
24
|
-
{ transform: `translateY(-${height}px)` },
|
|
25
|
-
{ transform: "translateY(0px)" },
|
|
26
|
-
];
|
|
27
|
-
return { keyframes, options };
|
|
28
|
-
}
|
|
29
|
-
case "right": {
|
|
30
|
-
el.style.right = "0px";
|
|
31
|
-
const width = measure(el, (el) => el.offsetWidth);
|
|
32
|
-
const keyframes = [{ transform: `translateX(${width}px)` }, { transform: "translateX(0px)" }];
|
|
33
|
-
return { keyframes, options };
|
|
34
|
-
}
|
|
35
|
-
case "bottom": {
|
|
36
|
-
el.style.bottom = "0px";
|
|
37
|
-
const height = measure(el, (el) => el.offsetHeight);
|
|
38
|
-
const keyframes = [
|
|
39
|
-
{ transform: `translateY(${height}px)` },
|
|
40
|
-
{ transform: "translateY(0px)" },
|
|
41
|
-
];
|
|
42
|
-
return { keyframes, options };
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
//import type { Component } from "@torpor/view";
|
|
2
|
-
//import showPopover from "../Modal/showModal";
|
|
3
|
-
//
|
|
4
|
-
//interface ClickPopoverOptions {
|
|
5
|
-
// popover: Component;
|
|
6
|
-
// props?: Record<PropertyKey, any>;
|
|
7
|
-
//}
|
|
8
|
-
//
|
|
9
|
-
///**
|
|
10
|
-
// * A mount directive for showing a popover when an element is clicked.
|
|
11
|
-
// * @param node The element to show the popover for
|
|
12
|
-
// * @param options Options for showing the popover, consisting of the popover component and any props
|
|
13
|
-
// */
|
|
14
|
-
//export default function clickPopover(node: HTMLElement, options: ClickPopoverOptions) {
|
|
15
|
-
// const { popover, props } = options;
|
|
16
|
-
//
|
|
17
|
-
// // Add a click event handler to the node
|
|
18
|
-
// node.addEventListener("click", handleClick);
|
|
19
|
-
//
|
|
20
|
-
// function handleClick(e: MouseEvent) {
|
|
21
|
-
// e.preventDefault();
|
|
22
|
-
// show();
|
|
23
|
-
// }
|
|
24
|
-
//
|
|
25
|
-
// let div: HTMLDivElement;
|
|
26
|
-
//
|
|
27
|
-
// function show() {
|
|
28
|
-
// // Show the popover in a div
|
|
29
|
-
// if (div) {
|
|
30
|
-
// document.body.removeChild(div);
|
|
31
|
-
// }
|
|
32
|
-
// div = document.createElement("div");
|
|
33
|
-
// document.body.appendChild(div);
|
|
34
|
-
//
|
|
35
|
-
// showPopover(popover, node, props, div);
|
|
36
|
-
// }
|
|
37
|
-
//
|
|
38
|
-
// return {
|
|
39
|
-
// destroy(): void {
|
|
40
|
-
// // Remove the event listener from the node on destroy
|
|
41
|
-
// node.removeEventListener("click", handleClick);
|
|
42
|
-
//
|
|
43
|
-
// // Remove the div we added
|
|
44
|
-
// // TODO: Should we do this in more places?
|
|
45
|
-
// if (div) {
|
|
46
|
-
// document.body.removeChild(div);
|
|
47
|
-
// }
|
|
48
|
-
// },
|
|
49
|
-
// };
|
|
50
|
-
//}
|
|
51
|
-
//
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
//import type { Component } from "@torpor/view";
|
|
2
|
-
//import showPopover from "../Modal/showModal";
|
|
3
|
-
//
|
|
4
|
-
//interface ContextPopoverOptions {
|
|
5
|
-
// popover: Component;
|
|
6
|
-
// props?: Record<PropertyKey, any>;
|
|
7
|
-
//}
|
|
8
|
-
//
|
|
9
|
-
///**
|
|
10
|
-
// * A mount directive for showing a popover when the user opens an element's context menu.
|
|
11
|
-
// * @param node The element to show the popover for
|
|
12
|
-
// * @param options Options for showing the popover, consisting of the popover component and any props
|
|
13
|
-
// */
|
|
14
|
-
//export default function contextPopover(node: HTMLElement, options: ContextPopoverOptions) {
|
|
15
|
-
// const { popover, props } = options;
|
|
16
|
-
//
|
|
17
|
-
// // Add a contextmenu event handler to the node
|
|
18
|
-
// node.addEventListener("contextmenu", handleClick);
|
|
19
|
-
//
|
|
20
|
-
// function handleClick(e: MouseEvent) {
|
|
21
|
-
// e.preventDefault();
|
|
22
|
-
// show();
|
|
23
|
-
// }
|
|
24
|
-
//
|
|
25
|
-
// let div: HTMLDivElement;
|
|
26
|
-
//
|
|
27
|
-
// function show() {
|
|
28
|
-
// // Show the popover in a div
|
|
29
|
-
// if (div) {
|
|
30
|
-
// document.body.removeChild(div);
|
|
31
|
-
// }
|
|
32
|
-
// div = document.createElement("div");
|
|
33
|
-
// document.body.appendChild(div);
|
|
34
|
-
//
|
|
35
|
-
// showPopover(popover, node, props, div);
|
|
36
|
-
// }
|
|
37
|
-
//
|
|
38
|
-
// return {
|
|
39
|
-
// destroy(): void {
|
|
40
|
-
// // Remove the event listener from the node on destroy
|
|
41
|
-
// node.removeEventListener("contextmenu", handleClick);
|
|
42
|
-
//
|
|
43
|
-
// // Remove the div we added
|
|
44
|
-
// // TODO: Should we do this in more places?
|
|
45
|
-
// if (div) {
|
|
46
|
-
// document.body.removeChild(div);
|
|
47
|
-
// }
|
|
48
|
-
// },
|
|
49
|
-
// };
|
|
50
|
-
//}
|
|
51
|
-
//
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export function disableScroll(): () => void {
|
|
2
|
-
// Remember body styles
|
|
3
|
-
const overflowX = document.body.style.overflowY;
|
|
4
|
-
const overflowY = document.body.style.overflowY;
|
|
5
|
-
const overscrollBehaviourX = document.body.style.overscrollBehaviorX;
|
|
6
|
-
const overscrollBehaviourY = document.body.style.overscrollBehaviorY;
|
|
7
|
-
const marginRight = document.body.style.marginRight;
|
|
8
|
-
|
|
9
|
-
// Get scrollbar width (if visible) so that we can set a margin to avoid things jumping around
|
|
10
|
-
// HACK: Does this work in all browsers/systems?
|
|
11
|
-
const scrollBarWidth = window.innerWidth - document.body.clientWidth;
|
|
12
|
-
|
|
13
|
-
// Set body styles to disallow scrolling
|
|
14
|
-
document.body.style.overflowY = "hidden";
|
|
15
|
-
document.body.style.overflowY = "hidden";
|
|
16
|
-
document.body.style.overscrollBehaviorX = "contain";
|
|
17
|
-
document.body.style.overscrollBehaviorY = "contain";
|
|
18
|
-
document.body.style.marginRight = scrollBarWidth + "px";
|
|
19
|
-
|
|
20
|
-
return () => {
|
|
21
|
-
// Reset body styles
|
|
22
|
-
document.body.style.overflowY = overflowX;
|
|
23
|
-
document.body.style.overflowY = overflowY;
|
|
24
|
-
document.body.style.overscrollBehaviorX = overscrollBehaviourX;
|
|
25
|
-
document.body.style.overscrollBehaviorY = overscrollBehaviourY;
|
|
26
|
-
document.body.style.marginRight = marginRight;
|
|
27
|
-
};
|
|
28
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
//import type { Component } from "@torpor/view";
|
|
2
|
-
//import showPopover from "../Modal/showModal";
|
|
3
|
-
//import hoverTrigger from "./hoverTrigger";
|
|
4
|
-
//
|
|
5
|
-
//interface HoverPopoverOptions {
|
|
6
|
-
// popover: Component;
|
|
7
|
-
// props?: Record<PropertyKey, any>;
|
|
8
|
-
// hoverDelay?: number;
|
|
9
|
-
// touchDelay?: number;
|
|
10
|
-
//}
|
|
11
|
-
//
|
|
12
|
-
///**
|
|
13
|
-
// * A mount directive for showing a popover when an element is hovered.
|
|
14
|
-
// * @param node The element to show the popover for
|
|
15
|
-
// * @param options Options for showing the popover, consisting of the popover component, any props and delays for hover and touch
|
|
16
|
-
// */
|
|
17
|
-
//export default function hoverPopover(node: HTMLElement, options: HoverPopoverOptions): () => void {
|
|
18
|
-
// const { popover, props, hoverDelay, touchDelay } = options;
|
|
19
|
-
//
|
|
20
|
-
// let div: HTMLDivElement | undefined;
|
|
21
|
-
//
|
|
22
|
-
// function onHover(node: HTMLElement, e: MouseEvent | TouchEvent) {
|
|
23
|
-
// // Show the popover in a div
|
|
24
|
-
// if (div) {
|
|
25
|
-
// document.body.removeChild(div);
|
|
26
|
-
// }
|
|
27
|
-
// div = document.createElement("div");
|
|
28
|
-
// document.body.appendChild(div);
|
|
29
|
-
//
|
|
30
|
-
// // Get the position relative to the element, so we can reposition on scroll
|
|
31
|
-
// const rect = node.getBoundingClientRect();
|
|
32
|
-
// let position: { x: number; y: number };
|
|
33
|
-
// if (e.type.startsWith("mouse")) {
|
|
34
|
-
// const me = e as MouseEvent;
|
|
35
|
-
// position = { x: me.clientX - rect.left, y: me.clientY - rect.top };
|
|
36
|
-
// } else {
|
|
37
|
-
// const te = e as TouchEvent;
|
|
38
|
-
// position = {
|
|
39
|
-
// x: te.touches[0].clientX - rect.left,
|
|
40
|
-
// y: te.touches[0].clientY - rect.top,
|
|
41
|
-
// };
|
|
42
|
-
// }
|
|
43
|
-
// const allProps = Object.assign({}, props, { anchor: node, position });
|
|
44
|
-
//
|
|
45
|
-
// showPopover(popover, node, allProps, div);
|
|
46
|
-
// }
|
|
47
|
-
//
|
|
48
|
-
// function onExit() {
|
|
49
|
-
// // Remove the div
|
|
50
|
-
// if (div) {
|
|
51
|
-
// document.body.removeChild(div);
|
|
52
|
-
// div = undefined;
|
|
53
|
-
// }
|
|
54
|
-
// }
|
|
55
|
-
//
|
|
56
|
-
// return hoverTrigger(node, { onHover, onExit, hoverDelay, touchDelay });
|
|
57
|
-
//}
|
|
58
|
-
//
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
interface HoverTriggerOptions {
|
|
2
|
-
onHover: (node: HTMLElement, e: TouchEvent | MouseEvent) => void;
|
|
3
|
-
onExit?: (node: HTMLElement, e: TouchEvent | MouseEvent) => void;
|
|
4
|
-
hoverDelay?: number;
|
|
5
|
-
touchDelay?: number;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export default function hoverTrigger(node: HTMLElement, options: HoverTriggerOptions): () => void {
|
|
9
|
-
const { onHover, onExit } = options;
|
|
10
|
-
const hoverDelay = options.hoverDelay || 1000;
|
|
11
|
-
const touchDelay = options.touchDelay || 1000;
|
|
12
|
-
|
|
13
|
-
let interval: NodeJS.Timeout | undefined;
|
|
14
|
-
|
|
15
|
-
// Add click event handlers to the node
|
|
16
|
-
node.addEventListener("mouseenter", handleMouseEnter);
|
|
17
|
-
node.addEventListener("mouseleave", handleMouseLeave);
|
|
18
|
-
node.addEventListener("mousemove", handleMouseMove);
|
|
19
|
-
node.addEventListener("touchstart", handleMouseEnter);
|
|
20
|
-
node.addEventListener("touchend", handleMouseLeave);
|
|
21
|
-
|
|
22
|
-
function handleMouseEnter(e: MouseEvent | TouchEvent) {
|
|
23
|
-
// Handle the hover after a delay
|
|
24
|
-
e.preventDefault();
|
|
25
|
-
if (!interval) {
|
|
26
|
-
const delay = e.type.startsWith("mouse") ? hoverDelay : touchDelay;
|
|
27
|
-
interval = setTimeout(() => onHover(node, e), delay);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function handleMouseLeave(e: MouseEvent | TouchEvent) {
|
|
32
|
-
// Prevent short hovers or touches from firing the event
|
|
33
|
-
if (interval) {
|
|
34
|
-
clearTimeout(interval);
|
|
35
|
-
interval = undefined;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (onExit) {
|
|
39
|
-
onExit(node, e);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function handleMouseMove(e: MouseEvent) {
|
|
44
|
-
// Reset the interval on mouse move
|
|
45
|
-
if (interval) {
|
|
46
|
-
clearTimeout(interval);
|
|
47
|
-
interval = setTimeout(() => onHover(node, e), hoverDelay);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// Remove the event listeners from the node on destroy
|
|
52
|
-
return () => {
|
|
53
|
-
node.removeEventListener("mouseenter", handleMouseEnter);
|
|
54
|
-
node.removeEventListener("mouseleave", handleMouseLeave);
|
|
55
|
-
node.removeEventListener("mousemove", handleMouseMove);
|
|
56
|
-
node.removeEventListener("touchstart", handleMouseEnter);
|
|
57
|
-
node.removeEventListener("touchend", handleMouseLeave);
|
|
58
|
-
};
|
|
59
|
-
}
|
package/src/mount/trapFocus.ts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
export interface TrapFocusOptions {
|
|
2
|
-
focusableElements: HTMLElement[];
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
export function trapFocus(node: HTMLElement, options?: TrapFocusOptions): () => void {
|
|
6
|
-
options = options || { focusableElements: [] };
|
|
7
|
-
|
|
8
|
-
// Selectors for all things that are focusable:
|
|
9
|
-
const focusableSelectors = [
|
|
10
|
-
"a[href]",
|
|
11
|
-
"area[href]",
|
|
12
|
-
'input:not([disabled]):not([type="hidden"]):not([aria-hidden])',
|
|
13
|
-
"select:not([disabled]):not([aria-hidden])",
|
|
14
|
-
"textarea:not([disabled]):not([aria-hidden])",
|
|
15
|
-
"button:not([disabled]):not([aria-hidden])",
|
|
16
|
-
"iframe",
|
|
17
|
-
"object",
|
|
18
|
-
"embed",
|
|
19
|
-
"[contenteditable]",
|
|
20
|
-
'[tabindex]:not([tabindex^="-"])',
|
|
21
|
-
];
|
|
22
|
-
|
|
23
|
-
// Set the focusable elements array in the options, which can be used in the caller e.g. to focus the first element
|
|
24
|
-
options.focusableElements = Array.from(node.querySelectorAll(focusableSelectors.join()));
|
|
25
|
-
|
|
26
|
-
// Store first and last focusable elements
|
|
27
|
-
const firstFocusableElement = options.focusableElements[0] as HTMLElement;
|
|
28
|
-
const lastFocusableElement = options.focusableElements[
|
|
29
|
-
options.focusableElements.length - 1
|
|
30
|
-
] as HTMLElement;
|
|
31
|
-
|
|
32
|
-
// Add the keydown event listener to the node
|
|
33
|
-
node.addEventListener("keydown", handleKey);
|
|
34
|
-
|
|
35
|
-
// On Tab or Shift+Tab, move through the focusable elements, wrapping at either end
|
|
36
|
-
function handleKey(e: KeyboardEvent) {
|
|
37
|
-
if (e.key === "Tab") {
|
|
38
|
-
if (e.shiftKey) {
|
|
39
|
-
if (document.activeElement === firstFocusableElement) {
|
|
40
|
-
// Shift + Tab on the first element, so move to the last one
|
|
41
|
-
lastFocusableElement.focus();
|
|
42
|
-
e.preventDefault();
|
|
43
|
-
}
|
|
44
|
-
} else {
|
|
45
|
-
if (document.activeElement === lastFocusableElement) {
|
|
46
|
-
// Tab on the last element, so move to the first one
|
|
47
|
-
firstFocusableElement.focus();
|
|
48
|
-
e.preventDefault();
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// Remove the keydown event listener from the node on destroy
|
|
55
|
-
return () => {
|
|
56
|
-
node.removeEventListener("keydown", handleKey);
|
|
57
|
-
};
|
|
58
|
-
}
|