@torpor/ui 0.2.0 → 0.2.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/CHANGELOG.md +12 -0
- package/dist/Accordion/Accordion.torp +23 -11
- package/dist/Accordion/AccordionContent.torp +13 -6
- package/dist/Accordion/AccordionHeader.torp +14 -5
- package/dist/Accordion/AccordionItem.torp +22 -8
- package/dist/Accordion/AccordionTrigger.torp +14 -6
- package/dist/Accordion/AccordionTypes.ts +2 -0
- package/dist/Accordion/index.d.ts +100 -35
- package/dist/Breadcrumb/Breadcrumb.torp +12 -3
- package/dist/Breadcrumb/BreadcrumbItem.torp +12 -3
- package/dist/Breadcrumb/BreadcrumbSeparator.torp +10 -1
- package/dist/Breadcrumb/index.d.ts +49 -21
- package/dist/Calendar/Calendar.torp +9 -1
- package/dist/Calendar/CalendarDay.torp +9 -1
- package/dist/Calendar/index.d.ts +16 -18
- package/dist/Dialog/Dialog.torp +13 -3
- package/dist/Dialog/DialogBody.torp +11 -3
- package/dist/Dialog/DialogButton.torp +16 -4
- package/dist/Dialog/DialogFooter.torp +11 -1
- package/dist/Dialog/DialogHeader.torp +11 -2
- package/dist/Dialog/index.d.ts +78 -35
- package/dist/Disclosure/Disclosure.torp +17 -7
- package/dist/Disclosure/DisclosureContent.torp +13 -6
- package/dist/Disclosure/DisclosureHeader.torp +14 -5
- package/dist/Disclosure/DisclosureTrigger.torp +10 -2
- package/dist/Disclosure/index.d.ts +67 -28
- package/dist/Drawer/Drawer.torp +11 -1
- package/dist/Drawer/index.d.ts +10 -9
- package/dist/Form/Field.torp +93 -0
- package/dist/Form/Form.torp +131 -0
- package/dist/Form/FormTypes.ts +30 -0
- package/dist/Form/Input.torp +94 -0
- package/dist/Form/Label.torp +31 -0
- package/dist/Form/Message.torp +35 -0
- package/dist/Form/StandardSchemaV1.ts +70 -0
- package/dist/Form/index.d.ts +117 -0
- package/dist/Form/index.js +22 -0
- package/dist/Form/index.js.map +1 -0
- package/dist/Menu/Menu.torp +12 -3
- package/dist/Menu/MenuButton.torp +14 -3
- package/dist/Menu/MenuCheck.torp +14 -3
- package/dist/Menu/MenuGroup.torp +13 -3
- package/dist/Menu/MenuIndicator.torp +12 -3
- package/dist/Menu/MenuPopout.torp +17 -6
- package/dist/Menu/MenuPopoutContent.torp +13 -4
- package/dist/Menu/MenuPopoutTrigger.torp +13 -4
- package/dist/Menu/MenuRadio.torp +16 -5
- package/dist/Menu/MenuRadioGroup.torp +16 -5
- package/dist/Menu/MenuSeparator.torp +11 -1
- package/dist/Menu/index.d.ts +170 -77
- package/dist/MenuBar/MenuBar.torp +13 -4
- package/dist/MenuBar/MenuBarItem.torp +17 -6
- package/dist/MenuBar/MenuBarItemContent.torp +13 -4
- package/dist/MenuBar/MenuBarItemTrigger.torp +11 -2
- package/dist/MenuBar/index.d.ts +79 -28
- package/dist/NavMenu/NavMenu.torp +13 -4
- package/dist/NavMenu/NavMenuButton.torp +12 -5
- package/dist/NavMenu/NavMenuElement.torp +14 -6
- package/dist/NavMenu/NavMenuGroup.torp +12 -3
- package/dist/NavMenu/NavMenuGroupHeader.torp +12 -4
- package/dist/NavMenu/NavMenuLink.torp +16 -8
- package/dist/NavMenu/NavMenuPopout.torp +11 -3
- package/dist/NavMenu/NavMenuPopoutButton.torp +14 -8
- package/dist/NavMenu/NavMenuPopoutContent.torp +13 -3
- package/dist/NavMenu/NavMenuSeparator.torp +10 -1
- package/dist/NavMenu/index.d.ts +147 -70
- package/dist/Notification/Notification.torp +15 -5
- package/dist/Notification/NotificationClose.torp +10 -1
- package/dist/Notification/NotificationContainer.torp +11 -1
- package/dist/Notification/NotificationContent.torp +11 -1
- package/dist/Notification/index.d.ts +46 -28
- package/dist/Popover/Popover.torp +20 -6
- package/dist/Popover/PopoverContent.torp +10 -1
- package/dist/Popover/PopoverContentAnchored.torp +13 -6
- package/dist/Popover/PopoverContentContextual.torp +10 -1
- package/dist/Popover/PopoverOverlay.torp +10 -1
- package/dist/Popover/PopoverTrigger.torp +10 -1
- package/dist/Popover/PopoverTriggerContextual.torp +10 -1
- package/dist/Popover/PopoverTriggerHover.torp +11 -2
- package/dist/Popover/index.d.ts +101 -56
- package/dist/TabGroup/TabContent.torp +11 -5
- package/dist/TabGroup/TabGroup.torp +21 -9
- package/dist/TabGroup/TabHeader.torp +14 -5
- package/dist/TabGroup/TabList.torp +13 -4
- package/dist/TabGroup/TabTrigger.torp +12 -4
- package/dist/TabGroup/index.d.ts +93 -35
- package/dist/icons/ArrowDown.torp +3 -3
- package/dist/icons/ArrowLeft.torp +3 -3
- package/dist/icons/ArrowRight.torp +3 -3
- package/dist/icons/ArrowUp.torp +3 -3
- package/dist/icons/Bars.torp +3 -3
- package/dist/icons/Check.torp +3 -3
- package/dist/icons/ChevronDown.torp +3 -3
- package/dist/icons/ChevronLeft.torp +3 -3
- package/dist/icons/ChevronRight.torp +3 -3
- package/dist/icons/ChevronUp.torp +3 -3
- package/dist/icons/Cross.torp +3 -3
- package/dist/icons/Loading.torp +3 -3
- package/dist/icons/Minus.torp +3 -3
- package/dist/icons/Plus.torp +3 -3
- package/dist/icons/index.d.ts +14 -126
- package/dist/metafile-esm.json +1 -1
- package/package.json +13 -4
- package/src/Accordion/Accordion.torp +23 -11
- package/src/Accordion/AccordionContent.torp +13 -6
- package/src/Accordion/AccordionHeader.torp +14 -5
- package/src/Accordion/AccordionItem.torp +22 -8
- package/src/Accordion/AccordionTrigger.torp +14 -6
- package/src/Accordion/AccordionTypes.ts +2 -0
- package/src/Breadcrumb/Breadcrumb.torp +12 -3
- package/src/Breadcrumb/BreadcrumbItem.torp +12 -3
- package/src/Breadcrumb/BreadcrumbSeparator.torp +10 -1
- package/src/Calendar/Calendar.torp +9 -1
- package/src/Calendar/CalendarDay.torp +9 -1
- package/src/Dialog/Dialog.torp +13 -3
- package/src/Dialog/DialogBody.torp +11 -3
- package/src/Dialog/DialogButton.torp +16 -4
- package/src/Dialog/DialogFooter.torp +11 -1
- package/src/Dialog/DialogHeader.torp +11 -2
- package/src/Disclosure/Disclosure.torp +17 -7
- package/src/Disclosure/DisclosureContent.torp +13 -6
- package/src/Disclosure/DisclosureHeader.torp +14 -5
- package/src/Disclosure/DisclosureTrigger.torp +10 -2
- package/src/Drawer/Drawer.torp +11 -1
- package/src/Form/Field.torp +93 -0
- package/src/Form/Form.torp +131 -0
- package/src/Form/FormTypes.ts +30 -0
- package/src/Form/Input.torp +94 -0
- package/src/Form/Label.torp +31 -0
- package/src/Form/Message.torp +35 -0
- package/src/Form/StandardSchemaV1.ts +70 -0
- package/src/Form/index.ts +7 -0
- package/src/Menu/Menu.torp +12 -3
- package/src/Menu/MenuButton.torp +14 -3
- package/src/Menu/MenuCheck.torp +14 -3
- package/src/Menu/MenuGroup.torp +13 -3
- package/src/Menu/MenuIndicator.torp +12 -3
- package/src/Menu/MenuPopout.torp +17 -6
- package/src/Menu/MenuPopoutContent.torp +13 -4
- package/src/Menu/MenuPopoutTrigger.torp +13 -4
- package/src/Menu/MenuRadio.torp +16 -5
- package/src/Menu/MenuRadioGroup.torp +16 -5
- package/src/Menu/MenuSeparator.torp +11 -1
- package/src/MenuBar/MenuBar.torp +13 -4
- package/src/MenuBar/MenuBarItem.torp +17 -6
- package/src/MenuBar/MenuBarItemContent.torp +13 -4
- package/src/MenuBar/MenuBarItemTrigger.torp +11 -2
- package/src/NavMenu/NavMenu.torp +13 -4
- package/src/NavMenu/NavMenuButton.torp +12 -5
- package/src/NavMenu/NavMenuElement.torp +14 -6
- package/src/NavMenu/NavMenuGroup.torp +12 -3
- package/src/NavMenu/NavMenuGroupHeader.torp +12 -4
- package/src/NavMenu/NavMenuLink.torp +16 -8
- package/src/NavMenu/NavMenuPopout.torp +11 -3
- package/src/NavMenu/NavMenuPopoutButton.torp +14 -8
- package/src/NavMenu/NavMenuPopoutContent.torp +13 -3
- package/src/NavMenu/NavMenuSeparator.torp +10 -1
- package/src/Notification/Notification.torp +15 -5
- package/src/Notification/NotificationClose.torp +10 -1
- package/src/Notification/NotificationContainer.torp +11 -1
- package/src/Notification/NotificationContent.torp +11 -1
- package/src/Popover/Popover.torp +20 -6
- package/src/Popover/PopoverContent.torp +10 -1
- package/src/Popover/PopoverContentAnchored.torp +13 -6
- package/src/Popover/PopoverContentContextual.torp +10 -1
- package/src/Popover/PopoverOverlay.torp +10 -1
- package/src/Popover/PopoverTrigger.torp +10 -1
- package/src/Popover/PopoverTriggerContextual.torp +10 -1
- package/src/Popover/PopoverTriggerHover.torp +11 -2
- package/src/TabGroup/TabContent.torp +11 -5
- package/src/TabGroup/TabGroup.torp +21 -9
- package/src/TabGroup/TabHeader.torp +14 -5
- package/src/TabGroup/TabList.torp +13 -4
- package/src/TabGroup/TabTrigger.torp +12 -4
- package/src/icons/ArrowDown.torp +3 -3
- package/src/icons/ArrowLeft.torp +3 -3
- package/src/icons/ArrowRight.torp +3 -3
- package/src/icons/ArrowUp.torp +3 -3
- package/src/icons/Bars.torp +3 -3
- package/src/icons/Check.torp +3 -3
- package/src/icons/ChevronDown.torp +3 -3
- package/src/icons/ChevronLeft.torp +3 -3
- package/src/icons/ChevronRight.torp +3 -3
- package/src/icons/ChevronUp.torp +3 -3
- package/src/icons/Cross.torp +3 -3
- package/src/icons/Loading.torp +3 -3
- package/src/icons/Minus.torp +3 -3
- package/src/icons/Plus.torp +3 -3
- package/test/Accordion/components/AccordionAccessibility.torp +2 -0
- package/test/Accordion/components/AccordionKeyboard.torp +2 -0
- package/test/Accordion/components/AccordionList.torp +2 -0
- package/test/Accordion/components/AccordionMultiple.torp +2 -0
- package/test/Accordion/components/AccordionSingle.torp +2 -0
- package/test/Disclosure/accessibility.test.ts +3 -2
- package/test/Disclosure/components/DisclosureTest.torp +2 -0
- package/test/Disclosure/toggle.test.ts +3 -2
- package/test/Form/components/FieldTest.torp +25 -0
- package/test/Form/components/FormTest.torp +31 -0
- package/test/Form/components/InputTest.torp +9 -0
- package/test/Form/field.test.ts +34 -0
- package/test/Form/form.test.ts +34 -0
- package/test/Form/input.test.ts +19 -0
- package/test/Menu/accessibility.test.ts +3 -2
- package/test/Menu/basic.test.ts +11 -10
- package/test/MenuBar/accessibility.test.ts +3 -2
- package/test/MenuBar/basic.test.ts +3 -2
- package/test/NavMenu/basic.test.ts +1 -1
- package/test/NavMenu/components/{NavMenu.torp → NavMenuBasic.torp} +1 -1
- package/test/TabGroup/components/TabGroupAccessibility.torp +2 -0
- package/test/TabGroup/components/TabGroupKeyboard.torp +2 -0
- package/test/TabGroup/components/TabGroupList.torp +2 -0
- package/test/TabGroup/components/TabGroupTrigger.torp +2 -0
- package/tsup.config.ts +1 -1
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
import { TabGroupContextName, type TabGroupContext, type ItemState } from "./TabGroupTypes";
|
|
2
2
|
|
|
3
|
+
interface TabGroupProps {
|
|
4
|
+
/** An ID for the root element */
|
|
5
|
+
id?: string;
|
|
6
|
+
/** Class name(s) for the root element */
|
|
7
|
+
class?: string,
|
|
8
|
+
/** The orientation of the tab buttons, which affects keyboard navigation */
|
|
9
|
+
orientation?: "horizontal" | "vertical",
|
|
10
|
+
/** How tabs are activated; if automatic they are shown on focus, if manual they must be clicked */
|
|
11
|
+
activation?: "automatic" | "manual",
|
|
12
|
+
/** The value of the active TabContent */
|
|
13
|
+
value?: string | string[],
|
|
14
|
+
/** If set to true, the user cannot interact with any items in the TabGroup */
|
|
15
|
+
disabled?: boolean,
|
|
16
|
+
/** Raised when the active item has changed */
|
|
17
|
+
onchange?: (value: string | string[]) => void
|
|
18
|
+
}
|
|
19
|
+
|
|
3
20
|
/**
|
|
4
21
|
* A list of interactive headings coupled with layered sections of content that
|
|
5
22
|
* enable users to reveal a single section of content at a time.
|
|
@@ -18,14 +35,9 @@ import { TabGroupContextName, type TabGroupContext, type ItemState } from "./Tab
|
|
|
18
35
|
* <TabContent />
|
|
19
36
|
* </TabGroup>
|
|
20
37
|
* ```
|
|
21
|
-
*
|
|
22
|
-
* @prop {"horizontal" | "vertical"} orientation -- The orientation of the tab buttons, which affects keyboard navigation
|
|
23
|
-
* @prop {"automatic" | "manual"} activation -- How tabs are activated; if automatic they are shown on focus, if manual they must be clicked
|
|
24
|
-
* @prop {string | string[]} value -- The value of the active TabContent
|
|
25
|
-
* @prop {boolean} disabled -- If set to true, the user cannot interact with any items in the TabGroup
|
|
26
|
-
* @prop {(value: string | string[]) => void} [onchange] -- Raised when the active item has changed
|
|
27
38
|
*/
|
|
28
|
-
export default function TabGroup($props:
|
|
39
|
+
export default function TabGroup($props: TabGroupProps) {
|
|
40
|
+
$props ??= $watch({});
|
|
29
41
|
$props.orientation ||= "horizontal";
|
|
30
42
|
$props.activation ||= "automatic";
|
|
31
43
|
$props.value ||= "";
|
|
@@ -63,7 +75,7 @@ export default function TabGroup($props: any) {
|
|
|
63
75
|
});
|
|
64
76
|
|
|
65
77
|
$run(() => {
|
|
66
|
-
itemStates.forEach((s) => s.parentDisabled = $props.disabled);
|
|
78
|
+
itemStates.forEach((s) => s.parentDisabled = $props.disabled === true);
|
|
67
79
|
});
|
|
68
80
|
|
|
69
81
|
// Dispatch the change event when the value changes
|
|
@@ -74,7 +86,7 @@ export default function TabGroup($props: any) {
|
|
|
74
86
|
if (firstChange) {
|
|
75
87
|
firstChange = false;
|
|
76
88
|
} else if (ev) {
|
|
77
|
-
ev(value);
|
|
89
|
+
ev(value!);
|
|
78
90
|
}
|
|
79
91
|
});
|
|
80
92
|
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { TabGroupContextName, TabItemContextName, type TabGroupContext, type TabItemContext } from "./TabGroupTypes";
|
|
2
2
|
|
|
3
|
+
interface TabHeaderProps {
|
|
4
|
+
/** An ID for the root element */
|
|
5
|
+
id?: string;
|
|
6
|
+
/** Class name(s) for the root element */
|
|
7
|
+
class?: string,
|
|
8
|
+
/** The type of HTML header to use */
|
|
9
|
+
as?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6"
|
|
10
|
+
}
|
|
11
|
+
|
|
3
12
|
/**
|
|
4
13
|
* The header for a tab item, which contains the TabTrigger.
|
|
5
14
|
*
|
|
@@ -10,15 +19,15 @@ import { TabGroupContextName, TabItemContextName, type TabGroupContext, type Tab
|
|
|
10
19
|
* <TabTrigger />
|
|
11
20
|
* </TabHeader>
|
|
12
21
|
* ```
|
|
13
|
-
*
|
|
14
|
-
* @prop {"h1" | "h2" | "h3" | "h4" | "h5" | "h6"} as -- The type of HTML header to use
|
|
15
22
|
*/
|
|
16
|
-
export default function TabHeader($props:
|
|
23
|
+
export default function TabHeader($props: TabHeaderProps) {
|
|
24
|
+
$props ??= $watch({});
|
|
25
|
+
|
|
17
26
|
const context = $context[TabGroupContextName] as TabGroupContext;
|
|
18
27
|
if (!context) {
|
|
19
28
|
throw new Error("TabHeader must be contained within a TabGroup");
|
|
20
29
|
}
|
|
21
|
-
let $state =
|
|
30
|
+
let $state = context.registerHeader($props.index, $props.value);
|
|
22
31
|
|
|
23
32
|
const itemContext: TabItemContext = {
|
|
24
33
|
triggerItem: context.triggerItem,
|
|
@@ -44,7 +53,7 @@ export default function TabHeader($props: any) {
|
|
|
44
53
|
$state.orientation
|
|
45
54
|
]}
|
|
46
55
|
data-state={$state.dataState}
|
|
47
|
-
data-disabled={$state.
|
|
56
|
+
data-disabled={$state.disabled ? "true" : undefined}
|
|
48
57
|
>
|
|
49
58
|
<slot />
|
|
50
59
|
</h4>
|
|
@@ -1,4 +1,13 @@
|
|
|
1
|
-
import { TabGroupContextName,
|
|
1
|
+
import { TabGroupContextName, type TabGroupContext } from "./TabGroupTypes";
|
|
2
|
+
|
|
3
|
+
interface TabListProps {
|
|
4
|
+
/** An ID for the root element */
|
|
5
|
+
id?: string;
|
|
6
|
+
/** Class name(s) for the root element */
|
|
7
|
+
class?: string,
|
|
8
|
+
/** An ARIA label for describing the tab list to screen readers */
|
|
9
|
+
ariaLabel?: string,
|
|
10
|
+
}
|
|
2
11
|
|
|
3
12
|
/**
|
|
4
13
|
* A component that holds the TabHeaders of a TabGroup.
|
|
@@ -12,10 +21,10 @@ import { TabGroupContextName, TabItemContextName, type TabGroupContext, type Tab
|
|
|
12
21
|
* </TabHeader>
|
|
13
22
|
* </TabList>
|
|
14
23
|
* ```
|
|
15
|
-
*
|
|
16
|
-
* @prop {string} ariaLabel -- An ARIA label for describing the tab list to screen readers
|
|
17
24
|
*/
|
|
18
|
-
export default function TabList($props:
|
|
25
|
+
export default function TabList($props: TabListProps) {
|
|
26
|
+
$props ??= $watch({});
|
|
27
|
+
|
|
19
28
|
// Get stuff out of the TabGroupContext
|
|
20
29
|
const context = $context[TabGroupContextName] as TabGroupContext;
|
|
21
30
|
if (!context) {
|
|
@@ -1,20 +1,28 @@
|
|
|
1
1
|
import getId from "../utils/getId";
|
|
2
2
|
import { TabItemContextName, type TabItemContext } from "./TabGroupTypes";
|
|
3
3
|
|
|
4
|
+
interface TabTriggerProps {
|
|
5
|
+
/** An ID for the root element */
|
|
6
|
+
id?: string;
|
|
7
|
+
/** Class name(s) for the root element */
|
|
8
|
+
class?: string,
|
|
9
|
+
}
|
|
10
|
+
|
|
4
11
|
/**
|
|
5
12
|
* A header button for a tab item, which can be used to reveal an associated TabContent.
|
|
6
13
|
*/
|
|
7
|
-
export default function TabTrigger() {
|
|
8
|
-
|
|
9
|
-
|
|
14
|
+
export default function TabTrigger($props: TabTriggerProps) {
|
|
15
|
+
$props ??= $watch({});
|
|
10
16
|
$props.id ||= getId();
|
|
11
17
|
|
|
18
|
+
let button: HTMLButtonElement;
|
|
19
|
+
|
|
12
20
|
// Get stuff out of the TabItemContext
|
|
13
21
|
const context = $context[TabItemContextName] as TabItemContext;
|
|
14
22
|
if (!context) {
|
|
15
23
|
throw new Error("TabTrigger must be contained within a TabHeader");
|
|
16
24
|
}
|
|
17
|
-
let $state =
|
|
25
|
+
let $state = context.state;
|
|
18
26
|
|
|
19
27
|
// Set the header ID so that it can be used with aria-labelledby in TabContent
|
|
20
28
|
$state.headerId = $props.id;
|
package/src/icons/ArrowDown.torp
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export default function ArrowDown() {
|
|
1
|
+
export default function ArrowDown($props: any) {
|
|
2
2
|
@render {
|
|
3
3
|
<svg
|
|
4
|
-
{$props
|
|
5
|
-
class={`torp-icon ${$props
|
|
4
|
+
{$props?.id}
|
|
5
|
+
class={`torp-icon ${$props?.class ?? ""}`.trim()}
|
|
6
6
|
viewBox="0 0 100 100"
|
|
7
7
|
stroke-linejoin="round"
|
|
8
8
|
stroke-width="12"
|
package/src/icons/ArrowLeft.torp
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export default function ArrowLeft() {
|
|
1
|
+
export default function ArrowLeft($props: any) {
|
|
2
2
|
@render {
|
|
3
3
|
<svg
|
|
4
|
-
{$props
|
|
5
|
-
class={`torp-icon ${$props
|
|
4
|
+
{$props?.id}
|
|
5
|
+
class={`torp-icon ${$props?.class ?? ""}`.trim()}
|
|
6
6
|
viewBox="0 0 100 100"
|
|
7
7
|
stroke-linejoin="round"
|
|
8
8
|
stroke-width="12"
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export default function ArrowRight() {
|
|
1
|
+
export default function ArrowRight($props: any) {
|
|
2
2
|
@render {
|
|
3
3
|
<svg
|
|
4
|
-
{$props
|
|
5
|
-
class={`torp-icon ${$props
|
|
4
|
+
{$props?.id}
|
|
5
|
+
class={`torp-icon ${$props?.class ?? ""}`.trim()}
|
|
6
6
|
viewBox="0 0 100 100"
|
|
7
7
|
stroke-linejoin="round"
|
|
8
8
|
stroke-width="12"
|
package/src/icons/ArrowUp.torp
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export default function ArrowUp() {
|
|
1
|
+
export default function ArrowUp($props: any) {
|
|
2
2
|
@render {
|
|
3
3
|
<svg
|
|
4
|
-
{$props
|
|
5
|
-
class={`torp-icon ${$props
|
|
4
|
+
{$props?.id}
|
|
5
|
+
class={`torp-icon ${$props?.class ?? ""}`.trim()}
|
|
6
6
|
viewBox="0 0 100 100"
|
|
7
7
|
stroke-linejoin="round"
|
|
8
8
|
stroke-width="12"
|
package/src/icons/Bars.torp
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export default function Bars() {
|
|
1
|
+
export default function Bars($props: any) {
|
|
2
2
|
@render {
|
|
3
3
|
<svg
|
|
4
|
-
{$props
|
|
5
|
-
class={`torp-icon ${$props
|
|
4
|
+
{$props?.id}
|
|
5
|
+
class={`torp-icon ${$props?.class ?? ""}`.trim()}
|
|
6
6
|
viewBox="0 0 100 100"
|
|
7
7
|
stroke-linejoin="round"
|
|
8
8
|
stroke-width="12"
|
package/src/icons/Check.torp
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export default function Check() {
|
|
1
|
+
export default function Check($props: any) {
|
|
2
2
|
@render {
|
|
3
3
|
<svg
|
|
4
|
-
{$props
|
|
5
|
-
class={`torp-icon ${$props
|
|
4
|
+
{$props?.id}
|
|
5
|
+
class={`torp-icon ${$props?.class ?? ""}`.trim()}
|
|
6
6
|
viewBox="0 0 100 100"
|
|
7
7
|
stroke-linejoin="round"
|
|
8
8
|
stroke-width="12"
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export default function ChevronDown() {
|
|
1
|
+
export default function ChevronDown($props: any) {
|
|
2
2
|
@render {
|
|
3
3
|
<svg
|
|
4
|
-
{$props
|
|
5
|
-
class={`torp-icon ${$props
|
|
4
|
+
{$props?.id}
|
|
5
|
+
class={`torp-icon ${$props?.class ?? ""}`.trim()}
|
|
6
6
|
viewBox="0 0 100 100"
|
|
7
7
|
stroke-linejoin="round"
|
|
8
8
|
stroke-width="12"
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export default function ChevronLeft() {
|
|
1
|
+
export default function ChevronLeft($props: any) {
|
|
2
2
|
@render {
|
|
3
3
|
<svg
|
|
4
|
-
{$props
|
|
5
|
-
class={`torp-icon ${$props
|
|
4
|
+
{$props?.id}
|
|
5
|
+
class={`torp-icon ${$props?.class ?? ""}`.trim()}
|
|
6
6
|
viewBox="0 0 100 100"
|
|
7
7
|
stroke-linejoin="round"
|
|
8
8
|
stroke-width="12"
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export default function ChevronRight() {
|
|
1
|
+
export default function ChevronRight($props: any) {
|
|
2
2
|
@render {
|
|
3
3
|
<svg
|
|
4
|
-
{$props
|
|
5
|
-
class={`torp-icon ${$props
|
|
4
|
+
{$props?.id}
|
|
5
|
+
class={`torp-icon ${$props?.class ?? ""}`.trim()}
|
|
6
6
|
viewBox="0 0 100 100"
|
|
7
7
|
stroke-linejoin="round"
|
|
8
8
|
stroke-width="12"
|
package/src/icons/ChevronUp.torp
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export default function ChevronUp() {
|
|
1
|
+
export default function ChevronUp($props: any) {
|
|
2
2
|
@render {
|
|
3
3
|
<svg
|
|
4
|
-
{$props
|
|
5
|
-
class={`torp-icon ${$props
|
|
4
|
+
{$props?.id}
|
|
5
|
+
class={`torp-icon ${$props?.class ?? ""}`.trim()}
|
|
6
6
|
viewBox="0 0 100 100"
|
|
7
7
|
stroke-linejoin="round"
|
|
8
8
|
stroke-width="12"
|
package/src/icons/Cross.torp
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export default function Cross() {
|
|
1
|
+
export default function Cross($props: any) {
|
|
2
2
|
@render {
|
|
3
3
|
<svg
|
|
4
|
-
{$props
|
|
5
|
-
class={`torp-icon ${$props
|
|
4
|
+
{$props?.id}
|
|
5
|
+
class={`torp-icon ${$props?.class ?? ""}`.trim()}
|
|
6
6
|
viewBox="0 0 100 100"
|
|
7
7
|
stroke-linejoin="round"
|
|
8
8
|
stroke-width="12"
|
package/src/icons/Loading.torp
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export default function Loading() {
|
|
1
|
+
export default function Loading($props: any) {
|
|
2
2
|
@render {
|
|
3
3
|
<svg
|
|
4
|
-
{$props
|
|
5
|
-
class={`torp-icon ${$props
|
|
4
|
+
{$props?.id}
|
|
5
|
+
class={`torp-icon ${$props?.class ?? ""}`.trim()}
|
|
6
6
|
viewBox="0 0 100 100"
|
|
7
7
|
stroke-linejoin="round"
|
|
8
8
|
stroke-width="20"
|
package/src/icons/Minus.torp
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export default function Minus() {
|
|
1
|
+
export default function Minus($props: any) {
|
|
2
2
|
@render {
|
|
3
3
|
<svg
|
|
4
|
-
{$props
|
|
5
|
-
class={`torp-icon ${$props
|
|
4
|
+
{$props?.id}
|
|
5
|
+
class={`torp-icon ${$props?.class ?? ""}`.trim()}
|
|
6
6
|
viewBox="0 0 100 100"
|
|
7
7
|
stroke-linejoin="round"
|
|
8
8
|
stroke-width="12"
|
package/src/icons/Plus.torp
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export default function Plus() {
|
|
1
|
+
export default function Plus($props: any) {
|
|
2
2
|
@render {
|
|
3
3
|
<svg
|
|
4
|
-
{$props
|
|
5
|
-
class={`torp-icon ${$props
|
|
4
|
+
{$props?.id}
|
|
5
|
+
class={`torp-icon ${$props?.class ?? ""}`.trim()}
|
|
6
6
|
viewBox="0 0 100 100"
|
|
7
7
|
stroke-linejoin="round"
|
|
8
8
|
stroke-width="12"
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getByText, queryByText } from "@testing-library/dom";
|
|
2
2
|
import "@testing-library/jest-dom/vitest";
|
|
3
|
+
import userEvent from "@testing-library/user-event";
|
|
3
4
|
import { mount } from "@torpor/view";
|
|
4
5
|
import { describe, expect, it } from "vitest";
|
|
5
6
|
import DisclosureTest from "./components/DisclosureTest.torp";
|
|
@@ -19,7 +20,7 @@ describe("Disclosure", () => {
|
|
|
19
20
|
expect(queryByText(container, "Disclosure header")).toHaveAttribute("aria-expanded", "false");
|
|
20
21
|
|
|
21
22
|
// When the content area is visible, it is set to true
|
|
22
|
-
|
|
23
|
+
await userEvent.click(getByText(container, "Disclosure header"));
|
|
23
24
|
expect(queryByText(container, "Disclosure header")).toHaveAttribute("aria-expanded", "true");
|
|
24
25
|
|
|
25
26
|
// Optionally, the element with role button has a value specified for aria-controls that refers
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getByText, queryByText } from "@testing-library/dom";
|
|
2
2
|
import "@testing-library/jest-dom/vitest";
|
|
3
|
+
import userEvent from "@testing-library/user-event";
|
|
3
4
|
import { mount } from "@torpor/view";
|
|
4
5
|
import { describe, expect, it } from "vitest";
|
|
5
6
|
import DisclosureTest from "./components/DisclosureTest.torp";
|
|
@@ -13,7 +14,7 @@ describe("Disclosure", () => {
|
|
|
13
14
|
expect(queryByText(container, "Disclosure content")).not.toBeInTheDocument();
|
|
14
15
|
|
|
15
16
|
// Clicking the header should reveal the body
|
|
16
|
-
|
|
17
|
+
await userEvent.click(getByText(container, "Disclosure header"));
|
|
17
18
|
expect(queryByText(container, "Disclosure content")).toBeInTheDocument();
|
|
18
19
|
});
|
|
19
20
|
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Field,
|
|
3
|
+
Label,
|
|
4
|
+
Input,
|
|
5
|
+
Message,
|
|
6
|
+
} from "../../../src/Form/index";
|
|
7
|
+
import * as z from "zod";
|
|
8
|
+
|
|
9
|
+
export default function FormTest($props: { value: string }) {
|
|
10
|
+
const schema = z.string().trim().min(1, { message: 'Name is required!' });
|
|
11
|
+
|
|
12
|
+
let $state = $watch({
|
|
13
|
+
data: {
|
|
14
|
+
name: "",
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
@render {
|
|
19
|
+
<Field name="name" &value={$state.data.name} {schema}>
|
|
20
|
+
<Label>Name:</Label>
|
|
21
|
+
<Input id="name-id" placeholder="Name..." />
|
|
22
|
+
<Message />
|
|
23
|
+
</Field>
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Form,
|
|
3
|
+
Field,
|
|
4
|
+
Label,
|
|
5
|
+
Input,
|
|
6
|
+
Message,
|
|
7
|
+
} from "../../../src/Form/index";
|
|
8
|
+
import * as z from "zod";
|
|
9
|
+
|
|
10
|
+
export default function FormTest($props: { value: string }) {
|
|
11
|
+
const schema = z.object({
|
|
12
|
+
name: z.string().trim().min(1, { message: 'Name is required!' }),
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
let $state = $watch({
|
|
16
|
+
data: {
|
|
17
|
+
name: "",
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
@render {
|
|
22
|
+
<Form {$state.data} {schema}>
|
|
23
|
+
<Field name="name" &value={$state.data.name}>
|
|
24
|
+
<Label>Name:</Label>
|
|
25
|
+
<Input id="name-id" placeholder="Name..." />
|
|
26
|
+
<Message />
|
|
27
|
+
</Field>
|
|
28
|
+
<button>Submit</button>
|
|
29
|
+
</Form>
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import {
|
|
2
|
+
fireEvent,
|
|
3
|
+
getByPlaceholderText,
|
|
4
|
+
queryByPlaceholderText,
|
|
5
|
+
queryByText,
|
|
6
|
+
} from "@testing-library/dom";
|
|
7
|
+
import "@testing-library/jest-dom/vitest";
|
|
8
|
+
import userEvent from "@testing-library/user-event";
|
|
9
|
+
import { mount } from "@torpor/view";
|
|
10
|
+
import { expect, test } from "vitest";
|
|
11
|
+
import Field from "./components/FieldTest.torp";
|
|
12
|
+
|
|
13
|
+
test("Field", async () => {
|
|
14
|
+
const container = document.createElement("div");
|
|
15
|
+
document.body.appendChild(container);
|
|
16
|
+
mount(container, Field);
|
|
17
|
+
|
|
18
|
+
// Label, input, message
|
|
19
|
+
expect(queryByText(container, "Name:")).not.toBeNull();
|
|
20
|
+
expect(queryByPlaceholderText(container, "Name...")).not.toBeNull();
|
|
21
|
+
expect(queryByText(container, "Name is required!")).toBeNull();
|
|
22
|
+
|
|
23
|
+
// Label `for` should be automatically hooked up
|
|
24
|
+
expect(queryByPlaceholderText(container, "Name...")).toHaveAttribute("id", "name-id");
|
|
25
|
+
expect(queryByText(container, "Name:")).toHaveAttribute("for", "name-id");
|
|
26
|
+
|
|
27
|
+
// Validation should be fired on blur
|
|
28
|
+
fireEvent.blur(queryByPlaceholderText(container, "Name...")!);
|
|
29
|
+
expect(queryByText(container, "Name is required!")).not.toBeNull();
|
|
30
|
+
|
|
31
|
+
// After blur, validation should fire on input
|
|
32
|
+
await userEvent.type(getByPlaceholderText(container, "Name..."), "G");
|
|
33
|
+
expect(queryByText(container, "Name is required!")).toBeNull();
|
|
34
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getByPlaceholderText,
|
|
3
|
+
getByText,
|
|
4
|
+
queryByPlaceholderText,
|
|
5
|
+
queryByText,
|
|
6
|
+
} from "@testing-library/dom";
|
|
7
|
+
import "@testing-library/jest-dom/vitest";
|
|
8
|
+
import userEvent from "@testing-library/user-event";
|
|
9
|
+
import { mount } from "@torpor/view";
|
|
10
|
+
import { expect, test } from "vitest";
|
|
11
|
+
import Form from "./components/FormTest.torp";
|
|
12
|
+
|
|
13
|
+
test("Form", async () => {
|
|
14
|
+
const container = document.createElement("div");
|
|
15
|
+
document.body.appendChild(container);
|
|
16
|
+
mount(container, Form);
|
|
17
|
+
|
|
18
|
+
// Label, input, message
|
|
19
|
+
expect(queryByText(container, "Name:")).not.toBeNull();
|
|
20
|
+
expect(queryByPlaceholderText(container, "Name...")).not.toBeNull();
|
|
21
|
+
expect(queryByText(container, "Name is required!")).toBeNull();
|
|
22
|
+
|
|
23
|
+
// Label `for` should be automatically hooked up
|
|
24
|
+
expect(queryByPlaceholderText(container, "Name...")).toHaveAttribute("id", "name-id");
|
|
25
|
+
expect(queryByText(container, "Name:")).toHaveAttribute("for", "name-id");
|
|
26
|
+
|
|
27
|
+
// Validation should be fired on submit
|
|
28
|
+
await userEvent.click(getByText(container, "Submit"));
|
|
29
|
+
expect(queryByText(container, "Name is required!")).not.toBeNull();
|
|
30
|
+
|
|
31
|
+
// After submitting, validation should fire on input
|
|
32
|
+
await userEvent.type(getByPlaceholderText(container, "Name..."), "G");
|
|
33
|
+
expect(queryByText(container, "Name is required!")).toBeNull();
|
|
34
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { getByPlaceholderText, queryByPlaceholderText } from "@testing-library/dom";
|
|
2
|
+
import "@testing-library/jest-dom/vitest";
|
|
3
|
+
import userEvent from "@testing-library/user-event";
|
|
4
|
+
import { mount } from "@torpor/view";
|
|
5
|
+
import { expect, test } from "vitest";
|
|
6
|
+
import Input from "./components/InputTest.torp";
|
|
7
|
+
|
|
8
|
+
test("Input", async () => {
|
|
9
|
+
let props = { value: "" };
|
|
10
|
+
|
|
11
|
+
const container = document.createElement("div");
|
|
12
|
+
document.body.appendChild(container);
|
|
13
|
+
mount(container, Input, props);
|
|
14
|
+
|
|
15
|
+
expect(queryByPlaceholderText(container, "Name...")).not.toBeNull();
|
|
16
|
+
|
|
17
|
+
await userEvent.type(getByPlaceholderText(container, "Name..."), "Greg");
|
|
18
|
+
expect(props.value).toBe("Greg");
|
|
19
|
+
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getByText, queryByText } from "@testing-library/dom";
|
|
2
2
|
import "@testing-library/jest-dom/vitest";
|
|
3
|
+
import userEvent from "@testing-library/user-event";
|
|
3
4
|
import { mount } from "@torpor/view";
|
|
4
5
|
import { describe, expect, it } from "vitest";
|
|
5
6
|
import MenuAccessibility from "./components/MenuAccessibility.torp";
|
|
@@ -35,7 +36,7 @@ describe("Menu", () => {
|
|
|
35
36
|
// A parent menuitem has aria-expanded set to false when its child menu is not visible and set
|
|
36
37
|
// to true when the child menu is visible
|
|
37
38
|
expect(queryByText(container, "Check popout button")).toHaveAttribute("aria-expanded", "false");
|
|
38
|
-
|
|
39
|
+
await userEvent.click(getByText(container, "Check popout button"));
|
|
39
40
|
expect(queryByText(container, "Check popout button")).toHaveAttribute("aria-expanded", "true");
|
|
40
41
|
|
|
41
42
|
// One of the following approaches is used to enable scripts to move focus among items in a
|