@torpor/ui 0.3.6 → 0.4.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/dist/Accordion/Accordion.torp +26 -25
- package/dist/Accordion/AccordionItem.torp +3 -3
- package/dist/Accordion/AccordionTypes.ts +5 -5
- package/dist/Accordion/index.d.ts +2 -2
- package/dist/Calendar/CalendarTypes.ts +1 -1
- package/dist/Charts/BarChart.torp +159 -0
- package/dist/Charts/DataSeries.ts +5 -0
- package/dist/Charts/GridLines.torp +65 -0
- package/dist/Charts/LineChart.torp +196 -0
- package/dist/Charts/PieChart.torp +145 -0
- package/dist/Charts/ScatterChart.torp +215 -0
- package/dist/Charts/SparkLine.torp +71 -0
- package/dist/Charts/XAxis.torp +66 -0
- package/dist/Charts/YAxis.torp +47 -0
- package/dist/Charts/index.d.ts +220 -0
- package/dist/Charts/index.js +34 -0
- package/dist/Charts/index.js.map +1 -0
- package/dist/Contextual/Contextual.torp +8 -3
- package/dist/Contextual/ContextualTypes.ts +1 -1
- package/dist/Dialog/Dialog.torp +12 -16
- package/dist/Dialog/DialogButton.torp +3 -0
- package/dist/Dialog/DialogTypes.ts +2 -2
- package/dist/Dialog/index.d.ts +2 -0
- package/dist/Disclosure/Disclosure.torp +3 -3
- package/dist/Disclosure/DisclosureTypes.ts +1 -1
- package/dist/Drawer/Drawer.torp +2 -2
- package/dist/Drawer/DrawerTypes.ts +1 -1
- package/dist/Form/CheckBox.torp +1 -2
- package/dist/Form/Input.torp +1 -1
- package/dist/Form/MessageSummary.torp +38 -0
- package/dist/Form/TextArea.torp +3 -0
- package/dist/Form/index.d.ts +25 -1
- package/dist/Form/index.js +4 -0
- package/dist/ListBox/ListBox.torp +271 -0
- package/dist/ListBox/ListBoxItem.torp +107 -0
- package/dist/ListBox/ListBoxSeparator.torp +26 -0
- package/dist/ListBox/ListBoxTypes.ts +23 -0
- package/dist/ListBox/index.d.ts +97 -0
- package/dist/ListBox/index.js +14 -0
- package/dist/ListBox/index.js.map +1 -0
- package/dist/Menu/Menu.torp +19 -14
- package/dist/Menu/MenuTypes.ts +5 -4
- package/dist/MenuBar/MenuBarItem.torp +5 -8
- package/dist/MenuBar/MenuBarTypes.ts +2 -2
- package/dist/Modal/Modal.torp +7 -2
- package/dist/Modal/ModalTypes.ts +1 -1
- package/dist/NavMenu/NavMenu.torp +7 -0
- package/dist/NavMenu/NavMenuButton.torp +5 -2
- package/dist/NavMenu/NavMenuPopout.torp +1 -1
- package/dist/NavMenu/{NavMenuPopoutButton.torp → NavMenuPopoutTrigger.torp} +4 -4
- package/dist/NavMenu/NavMenuSeparator.torp +2 -1
- package/dist/NavMenu/NavMenuTypes.ts +4 -3
- package/dist/NavMenu/index.d.ts +22 -18
- package/dist/NavMenu/index.js +4 -4
- package/dist/Pagination/Pagination.torp +145 -0
- package/dist/Pagination/PaginationItem.torp +100 -0
- package/dist/Pagination/PaginationTypes.ts +25 -0
- package/dist/Pagination/buildPages.ts +57 -0
- package/dist/Pagination/index.d.ts +53 -0
- package/dist/Pagination/index.js +40 -0
- package/dist/Pagination/index.js.map +1 -0
- package/dist/Popover/Popover.torp +8 -3
- package/dist/Popover/PopoverTypes.ts +1 -1
- package/dist/SelectBox/SelectBox.torp +136 -0
- package/dist/SelectBox/SelectBoxContent.torp +81 -0
- package/dist/SelectBox/SelectBoxInput.torp +95 -0
- package/dist/SelectBox/SelectBoxTrigger.torp +41 -0
- package/dist/SelectBox/SelectBoxTypes.ts +18 -0
- package/dist/SelectBox/index.d.ts +127 -0
- package/dist/SelectBox/index.js +18 -0
- package/dist/SelectBox/index.js.map +1 -0
- package/dist/TabGroup/TabGroup.torp +3 -3
- package/dist/TabGroup/TabGroupTypes.ts +2 -2
- package/dist/ToolBar/ToolBar.torp +198 -0
- package/dist/ToolBar/ToolBarButton.torp +57 -0
- package/dist/ToolBar/ToolBarElement.torp +55 -0
- package/dist/ToolBar/ToolBarPopout.torp +97 -0
- package/dist/ToolBar/ToolBarPopoutContent.torp +92 -0
- package/dist/ToolBar/ToolBarPopoutTrigger.torp +138 -0
- package/dist/ToolBar/ToolBarSeparator.torp +25 -0
- package/dist/ToolBar/ToolBarTypes.ts +35 -0
- package/dist/ToolBar/index.d.ts +212 -0
- package/dist/ToolBar/index.js +30 -0
- package/dist/ToolBar/index.js.map +1 -0
- package/dist/metafile-esm.json +1 -1
- package/dist/utils/PopoutTypes.ts +35 -0
- package/dist/utils/chartColors.ts +17 -0
- package/dist/utils/chartUtils.ts +71 -0
- package/package.json +22 -2
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import { type SlotRender } from "@torpor/view";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
interface BarChartProps {
|
|
5
|
+
/** An ID for the root element */
|
|
6
|
+
id?: string;
|
|
7
|
+
/** Classes for the root element */
|
|
8
|
+
class?: ClassValue,
|
|
9
|
+
/** Styles for the root element */
|
|
10
|
+
style?: StyleValue,
|
|
11
|
+
series: DataSeries[],
|
|
12
|
+
height?: number,
|
|
13
|
+
width?: number,
|
|
14
|
+
xLabel?: string,
|
|
15
|
+
yLabel?: string,
|
|
16
|
+
maxValue?: number,
|
|
17
|
+
stepCount?: number,
|
|
18
|
+
stepValue?: number,
|
|
19
|
+
hideXAxis?: boolean,
|
|
20
|
+
hideYAxis?: boolean,
|
|
21
|
+
showHLines?: boolean,
|
|
22
|
+
showVLines?: boolean,
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
declare function BarChart(
|
|
26
|
+
$parent: ParentNode,
|
|
27
|
+
$anchor: Node | null,
|
|
28
|
+
$props: BarChartProps,
|
|
29
|
+
$context?: Record<PropertyKey, any>,
|
|
30
|
+
$slots?: Record<string, SlotRender>,
|
|
31
|
+
): void;
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
interface GridLinesProps {
|
|
36
|
+
/** An ID for the root element */
|
|
37
|
+
id?: string;
|
|
38
|
+
/** Classes for the root element */
|
|
39
|
+
class?: ClassValue,
|
|
40
|
+
/** Styles for the root element */
|
|
41
|
+
style?: StyleValue,
|
|
42
|
+
showHLines?: boolean,
|
|
43
|
+
showVLines?: boolean,
|
|
44
|
+
width: number;
|
|
45
|
+
labels: string[];
|
|
46
|
+
xStepValue: number;
|
|
47
|
+
xStepLabels: number[];
|
|
48
|
+
yStepValue: number;
|
|
49
|
+
yStepLabels: number[];
|
|
50
|
+
itemWidth: number;
|
|
51
|
+
valueHeight: number;
|
|
52
|
+
chartLeft: number;
|
|
53
|
+
chartBottom: number;
|
|
54
|
+
type: string;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
declare function GridLines(
|
|
58
|
+
$parent: ParentNode,
|
|
59
|
+
$anchor: Node | null,
|
|
60
|
+
$props: GridLinesProps,
|
|
61
|
+
$context?: Record<PropertyKey, any>,
|
|
62
|
+
$slots?: Record<string, SlotRender>,
|
|
63
|
+
): void;
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
interface LineChartProps {
|
|
68
|
+
/** An ID for the root element */
|
|
69
|
+
id?: string;
|
|
70
|
+
/** Classes for the root element */
|
|
71
|
+
class?: ClassValue,
|
|
72
|
+
/** Styles for the root element */
|
|
73
|
+
style?: StyleValue,
|
|
74
|
+
series: DataSeries[],
|
|
75
|
+
height?: number,
|
|
76
|
+
width?: number,
|
|
77
|
+
xLabel?: string,
|
|
78
|
+
yLabel?: string,
|
|
79
|
+
maxValue?: number,
|
|
80
|
+
stepCount?: number,
|
|
81
|
+
stepValue?: number,
|
|
82
|
+
showPoints?: boolean,
|
|
83
|
+
hideXAxis?: boolean,
|
|
84
|
+
hideYAxis?: boolean,
|
|
85
|
+
showHLines?: boolean,
|
|
86
|
+
showVLines?: boolean,
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
declare function LineChart(
|
|
90
|
+
$parent: ParentNode,
|
|
91
|
+
$anchor: Node | null,
|
|
92
|
+
$props: LineChartProps,
|
|
93
|
+
$context?: Record<PropertyKey, any>,
|
|
94
|
+
$slots?: Record<string, SlotRender>,
|
|
95
|
+
): void;
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
interface PieChartProps {
|
|
100
|
+
/** An ID for the root element */
|
|
101
|
+
id?: string;
|
|
102
|
+
/** Classes for the root element */
|
|
103
|
+
class?: ClassValue,
|
|
104
|
+
/** Styles for the root element */
|
|
105
|
+
style?: StyleValue,
|
|
106
|
+
data: PieData[],
|
|
107
|
+
size?: number,
|
|
108
|
+
radius?: number,
|
|
109
|
+
cutout?: number,
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
declare function PieChart(
|
|
113
|
+
$parent: ParentNode,
|
|
114
|
+
$anchor: Node | null,
|
|
115
|
+
$props: PieChartProps,
|
|
116
|
+
$context?: Record<PropertyKey, any>,
|
|
117
|
+
$slots?: Record<string, SlotRender>,
|
|
118
|
+
): void;
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
interface ScatterChartProps {
|
|
123
|
+
/** An ID for the root element */
|
|
124
|
+
id?: string;
|
|
125
|
+
/** Classes for the root element */
|
|
126
|
+
class?: ClassValue,
|
|
127
|
+
/** Styles for the root element */
|
|
128
|
+
style?: StyleValue,
|
|
129
|
+
series: DataSeries[],
|
|
130
|
+
height?: number,
|
|
131
|
+
width?: number,
|
|
132
|
+
xLabel?: string,
|
|
133
|
+
yLabel?: string,
|
|
134
|
+
xStepCount?: number,
|
|
135
|
+
xStepValue?: number,
|
|
136
|
+
yStepCount?: number,
|
|
137
|
+
yStepValue?: number,
|
|
138
|
+
hideXAxis?: boolean,
|
|
139
|
+
hideYAxis?: boolean,
|
|
140
|
+
showHLines?: boolean,
|
|
141
|
+
showVLines?: boolean,
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
declare function ScatterChart(
|
|
145
|
+
$parent: ParentNode,
|
|
146
|
+
$anchor: Node | null,
|
|
147
|
+
$props: ScatterChartProps,
|
|
148
|
+
$context?: Record<PropertyKey, any>,
|
|
149
|
+
$slots?: Record<string, SlotRender>,
|
|
150
|
+
): void;
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
interface SparkLineProps {
|
|
155
|
+
/** An ID for the root element */
|
|
156
|
+
id?: string;
|
|
157
|
+
/** Classes for the root element */
|
|
158
|
+
class?: ClassValue,
|
|
159
|
+
/** Styles for the root element */
|
|
160
|
+
style?: StyleValue,
|
|
161
|
+
data: number[];
|
|
162
|
+
color?: string,
|
|
163
|
+
height?: number,
|
|
164
|
+
width?: number,
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
declare function SparkLine(
|
|
168
|
+
$parent: ParentNode,
|
|
169
|
+
$anchor: Node | null,
|
|
170
|
+
$props: SparkLineProps,
|
|
171
|
+
$context?: Record<PropertyKey, any>,
|
|
172
|
+
$slots?: Record<string, SlotRender>,
|
|
173
|
+
): void;
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
interface XAxisProps {
|
|
178
|
+
showAxis: boolean,
|
|
179
|
+
height: number,
|
|
180
|
+
width: number,
|
|
181
|
+
itemWidth: number,
|
|
182
|
+
textHeight: number,
|
|
183
|
+
xLabel: string,
|
|
184
|
+
labels: string[] ,
|
|
185
|
+
stepLabels:number[] ,
|
|
186
|
+
stepValue: number,
|
|
187
|
+
chartLeft: number,
|
|
188
|
+
chartBottom: number,
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
declare function XAxis(
|
|
192
|
+
$parent: ParentNode,
|
|
193
|
+
$anchor: Node | null,
|
|
194
|
+
$props: XAxisProps,
|
|
195
|
+
$context?: Record<PropertyKey, any>,
|
|
196
|
+
$slots?: Record<string, SlotRender>,
|
|
197
|
+
): void;
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
interface YAxisProps {
|
|
202
|
+
showAxis: boolean,
|
|
203
|
+
valueHeight: number,
|
|
204
|
+
textHeight: number,
|
|
205
|
+
yLabel: string,
|
|
206
|
+
stepLabels: number[],
|
|
207
|
+
stepValue: number,
|
|
208
|
+
chartLeft: number,
|
|
209
|
+
chartBottom: number,
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
declare function YAxis(
|
|
213
|
+
$parent: ParentNode,
|
|
214
|
+
$anchor: Node | null,
|
|
215
|
+
$props: YAxisProps,
|
|
216
|
+
$context?: Record<PropertyKey, any>,
|
|
217
|
+
$slots?: Record<string, SlotRender>,
|
|
218
|
+
): void;
|
|
219
|
+
|
|
220
|
+
export { BarChart, GridLines, LineChart, PieChart, ScatterChart, SparkLine, XAxis, YAxis };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// src/Charts/BarChart.torp
|
|
2
|
+
import BarChart_default from "./BarChart.torp";
|
|
3
|
+
|
|
4
|
+
// src/Charts/GridLines.torp
|
|
5
|
+
import GridLines_default from "./GridLines.torp";
|
|
6
|
+
|
|
7
|
+
// src/Charts/LineChart.torp
|
|
8
|
+
import LineChart_default from "./LineChart.torp";
|
|
9
|
+
|
|
10
|
+
// src/Charts/PieChart.torp
|
|
11
|
+
import PieChart_default from "./PieChart.torp";
|
|
12
|
+
|
|
13
|
+
// src/Charts/ScatterChart.torp
|
|
14
|
+
import ScatterChart_default from "./ScatterChart.torp";
|
|
15
|
+
|
|
16
|
+
// src/Charts/SparkLine.torp
|
|
17
|
+
import SparkLine_default from "./SparkLine.torp";
|
|
18
|
+
|
|
19
|
+
// src/Charts/XAxis.torp
|
|
20
|
+
import XAxis_default from "./XAxis.torp";
|
|
21
|
+
|
|
22
|
+
// src/Charts/YAxis.torp
|
|
23
|
+
import YAxis_default from "./YAxis.torp";
|
|
24
|
+
export {
|
|
25
|
+
BarChart_default as BarChart,
|
|
26
|
+
GridLines_default as GridLines,
|
|
27
|
+
LineChart_default as LineChart,
|
|
28
|
+
PieChart_default as PieChart,
|
|
29
|
+
ScatterChart_default as ScatterChart,
|
|
30
|
+
SparkLine_default as SparkLine,
|
|
31
|
+
XAxis_default as XAxis,
|
|
32
|
+
YAxis_default as YAxis
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ClassValue, StyleValue } from "@torpor/view";
|
|
2
2
|
import { ContextualContextName, type Point, type ContextualContext, type ContextualState } from "./ContextualTypes";
|
|
3
|
+
import { PopoutContextName, type PopoutContext } from "../utils/PopoutTypes";
|
|
3
4
|
|
|
4
5
|
interface ContextualProps {
|
|
5
6
|
/** An ID for the root element */
|
|
@@ -62,11 +63,15 @@ export default function Contextual($props: ContextualProps | undefined) {
|
|
|
62
63
|
handleButton,
|
|
63
64
|
handleClickOutside,
|
|
64
65
|
state: $state,
|
|
65
|
-
modal: $props?.modal,
|
|
66
|
+
//modal: $props?.modal,
|
|
66
67
|
anchorElement: $props?.anchor ? $unwrap($props.anchor) : undefined,
|
|
67
68
|
};
|
|
68
69
|
$context[ContextualContextName] = context;
|
|
69
70
|
|
|
71
|
+
// Set the context to pass down to items
|
|
72
|
+
let popoutContext: PopoutContext = context;
|
|
73
|
+
$context[PopoutContextName] = popoutContext;
|
|
74
|
+
|
|
70
75
|
// Dispatch the toggle event when the contextual is opened or closed
|
|
71
76
|
let firstToggle = true;
|
|
72
77
|
$run(() => {
|
|
@@ -90,11 +95,11 @@ export default function Contextual($props: ContextualProps | undefined) {
|
|
|
90
95
|
// Get the button's result
|
|
91
96
|
switch (type) {
|
|
92
97
|
case "confirm": {
|
|
93
|
-
result = value
|
|
98
|
+
result = value ?? true;
|
|
94
99
|
break;
|
|
95
100
|
}
|
|
96
101
|
case "cancel": {
|
|
97
|
-
result = value
|
|
102
|
+
result = value ?? false;
|
|
98
103
|
break;
|
|
99
104
|
}
|
|
100
105
|
default: {
|
package/dist/Dialog/Dialog.torp
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import type { ClassValue, StyleValue } from "@torpor/view";
|
|
2
2
|
import getId from "../utils/getId";
|
|
3
3
|
import { trapFocus, type TrapFocusOptions } from "../mount/trapFocus";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { DialogContextName, type DialogContext, type DialogState, type HandleButtonPress } from "./DialogTypes";
|
|
4
|
+
import { PopoutContextName, type PopoutContext, type HandleButtonPress } from "../utils/PopoutTypes";
|
|
5
|
+
import { DialogContextName, type DialogContext, type DialogState } from "./DialogTypes";
|
|
7
6
|
|
|
8
7
|
interface DialogProps {
|
|
9
8
|
/** An ID for the root element */
|
|
@@ -48,20 +47,18 @@ export default function Dialog($props: DialogProps | undefined) {
|
|
|
48
47
|
focusableElements: []
|
|
49
48
|
};
|
|
50
49
|
|
|
51
|
-
// Maybe get stuff out of a
|
|
50
|
+
// Maybe get stuff out of a popout context
|
|
52
51
|
let modal = false;
|
|
53
|
-
let visible = true;
|
|
54
52
|
let handleButton: HandleButtonPress | undefined = undefined;
|
|
55
|
-
const
|
|
56
|
-
if (
|
|
53
|
+
const popoutContext = $context[PopoutContextName] as PopoutContext;
|
|
54
|
+
if (popoutContext) {
|
|
57
55
|
modal = true;
|
|
58
|
-
|
|
59
|
-
handleButton = modalContext.handleButton;
|
|
56
|
+
handleButton = popoutContext.handleButton;
|
|
60
57
|
|
|
61
|
-
|
|
62
|
-
// Set the focusFirstElement method in the
|
|
58
|
+
popoutContext.handleClickOutside = handleClickOutside;
|
|
59
|
+
// Set the focusFirstElement method in the PopoutContext so that it can be
|
|
63
60
|
// called after everything has been shown
|
|
64
|
-
|
|
61
|
+
popoutContext.focusFirstElement = focusFirstElement;
|
|
65
62
|
}
|
|
66
63
|
|
|
67
64
|
// Set the IDs for using in the Dialog's ARIA attributes
|
|
@@ -69,14 +66,13 @@ export default function Dialog($props: DialogProps | undefined) {
|
|
|
69
66
|
dialogId: $props?.id ?? defaultId,
|
|
70
67
|
headerId: "",
|
|
71
68
|
bodyId: "",
|
|
72
|
-
|
|
73
|
-
})
|
|
69
|
+
});
|
|
74
70
|
|
|
75
71
|
// Set the context to pass down to items
|
|
76
72
|
let context: DialogContext = {
|
|
77
73
|
handleButton,
|
|
78
74
|
state: $state,
|
|
79
|
-
anchorElement:
|
|
75
|
+
anchorElement: popoutContext ? popoutContext.anchorElement : undefined
|
|
80
76
|
};
|
|
81
77
|
$context[DialogContextName] = context;
|
|
82
78
|
|
|
@@ -91,7 +87,7 @@ export default function Dialog($props: DialogProps | undefined) {
|
|
|
91
87
|
// the Esc key
|
|
92
88
|
e.preventDefault();
|
|
93
89
|
if (!modal) {
|
|
94
|
-
|
|
90
|
+
popoutContext.state.visible = false;
|
|
95
91
|
}
|
|
96
92
|
}
|
|
97
93
|
|
|
@@ -16,6 +16,8 @@ interface DialogButtonProps {
|
|
|
16
16
|
disabled?: boolean,
|
|
17
17
|
/** Raised when the button is clicked */
|
|
18
18
|
onclick?: (e: MouseEvent) => void,
|
|
19
|
+
/** Raised when a key is pressed down */
|
|
20
|
+
onkeydown?: (e: KeyboardEvent) => void,
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
/**
|
|
@@ -58,6 +60,7 @@ export default function DialogButton($props: DialogButtonProps | undefined) {
|
|
|
58
60
|
{$props?.style}
|
|
59
61
|
disabled={$props?.disabled}
|
|
60
62
|
onclick={handleClick}
|
|
63
|
+
{$props?.onkeydown}
|
|
61
64
|
&ref={button}
|
|
62
65
|
>
|
|
63
66
|
<slot />
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { type HandleButtonPress } from "../utils/PopoutTypes";
|
|
2
2
|
|
|
3
|
-
export
|
|
3
|
+
export const DialogContextName: unique symbol = Symbol.for("torp.Dialog");
|
|
4
4
|
|
|
5
5
|
export interface DialogContext {
|
|
6
6
|
handleButton?: HandleButtonPress;
|
package/dist/Dialog/index.d.ts
CHANGED
|
@@ -59,12 +59,12 @@ export default function Disclosure($props: DisclosureProps | undefined) {
|
|
|
59
59
|
// Dispatch the toggle event when the value of expanded changes
|
|
60
60
|
let firstToggle = true;
|
|
61
61
|
$run(() => {
|
|
62
|
-
const
|
|
62
|
+
const ontoggle = $props?.ontoggle;
|
|
63
63
|
const expanded = $state.expanded;
|
|
64
64
|
if (firstToggle) {
|
|
65
65
|
firstToggle = false;
|
|
66
|
-
} else if (
|
|
67
|
-
|
|
66
|
+
} else if (ontoggle) {
|
|
67
|
+
ontoggle(expanded);
|
|
68
68
|
}
|
|
69
69
|
});
|
|
70
70
|
|
package/dist/Drawer/Drawer.torp
CHANGED
|
@@ -88,11 +88,11 @@ export default function Drawer($props: DrawerProps | undefined) {
|
|
|
88
88
|
// Get the button's result
|
|
89
89
|
switch (type) {
|
|
90
90
|
case "confirm": {
|
|
91
|
-
result = value
|
|
91
|
+
result = value ?? true;
|
|
92
92
|
break;
|
|
93
93
|
}
|
|
94
94
|
case "cancel": {
|
|
95
|
-
result = value
|
|
95
|
+
result = value ?? false;
|
|
96
96
|
break;
|
|
97
97
|
}
|
|
98
98
|
default: {
|
package/dist/Form/CheckBox.torp
CHANGED
|
@@ -79,8 +79,7 @@ export default function CheckBox($props: CheckBoxProps | undefined) {
|
|
|
79
79
|
@render {
|
|
80
80
|
<input
|
|
81
81
|
id={$props?.id ?? defaultId}
|
|
82
|
-
class={
|
|
83
|
-
${$props?.class ?? ""}`.trim()}
|
|
82
|
+
class={["torp-check-box", $props?.class]}
|
|
84
83
|
type="checkbox"
|
|
85
84
|
{name}
|
|
86
85
|
&checked={$state.value}
|
package/dist/Form/Input.torp
CHANGED
|
@@ -71,7 +71,7 @@ export default function Input($props: InputProps | undefined) {
|
|
|
71
71
|
// NOTE: Adapted this from https://stackoverflow.com/a/57393751,
|
|
72
72
|
// not sure if it's still a good way to do things
|
|
73
73
|
function handleInput(e: Event & { currentTarget: EventTarget & HTMLInputElement }) {
|
|
74
|
-
$state.value = $props
|
|
74
|
+
$state.value = $props?.type?.match(/^(number|range)$/) ? +e.currentTarget.value : e.currentTarget.value;
|
|
75
75
|
if (formContext) {
|
|
76
76
|
formContext.validate();
|
|
77
77
|
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { ClassValue, StyleValue } from "@torpor/view";
|
|
2
|
+
import { FormContextName, type FormContext } from "./FormTypes";
|
|
3
|
+
|
|
4
|
+
interface MessageSummaryProps {
|
|
5
|
+
/** An ID for the root element */
|
|
6
|
+
id?: string;
|
|
7
|
+
/** Classes for the root element */
|
|
8
|
+
class?: ClassValue,
|
|
9
|
+
/** Styles for the root element */
|
|
10
|
+
style?: StyleValue,
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Shows all validation messages for a form in a list.
|
|
15
|
+
*/
|
|
16
|
+
export default function MessageSummary($props: MessageSummaryProps | undefined) {
|
|
17
|
+
// Get stuff out of the FormContext
|
|
18
|
+
const context = $context[FormContextName] as FormContext;
|
|
19
|
+
if (!context) {
|
|
20
|
+
throw new Error("MessageSummary must be contained within a Form");
|
|
21
|
+
}
|
|
22
|
+
const { state: $state } = context;
|
|
23
|
+
|
|
24
|
+
@render {
|
|
25
|
+
@if ($state.issues.length > 0) {
|
|
26
|
+
<ul
|
|
27
|
+
{$props?.id}
|
|
28
|
+
class={["torp-message-summary", $props?.class]}
|
|
29
|
+
{$props?.style}
|
|
30
|
+
>
|
|
31
|
+
<slot />
|
|
32
|
+
@for (let issue of $state.issues) {
|
|
33
|
+
<li>{issue.message}</li>
|
|
34
|
+
}
|
|
35
|
+
</ul>
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
package/dist/Form/TextArea.torp
CHANGED
|
@@ -19,6 +19,8 @@ interface TextAreaProps {
|
|
|
19
19
|
placeholder?: string,
|
|
20
20
|
/** Whether the input should be readonly */
|
|
21
21
|
readonly?: boolean,
|
|
22
|
+
/** Whether the input's value is required */
|
|
23
|
+
required?: boolean,
|
|
22
24
|
/** The maximum number of characters allowed for the input value */
|
|
23
25
|
maxlength?: number,
|
|
24
26
|
/** An ARIA label for describing the input to screen readers when there is no associated label element */
|
|
@@ -94,6 +96,7 @@ export default function TextArea($props: TextAreaProps | undefined) {
|
|
|
94
96
|
{$props?.rows}
|
|
95
97
|
{$props?.placeholder}
|
|
96
98
|
{$props?.readonly}
|
|
99
|
+
{$props?.required}
|
|
97
100
|
{$props?.maxlength}
|
|
98
101
|
aria-label={$props?.ariaLabel}
|
|
99
102
|
data-valid={$state.valid ? "valid" : "invalid"}
|
package/dist/Form/index.d.ts
CHANGED
|
@@ -245,6 +245,28 @@ declare function Message(
|
|
|
245
245
|
|
|
246
246
|
|
|
247
247
|
|
|
248
|
+
interface MessageSummaryProps {
|
|
249
|
+
/** An ID for the root element */
|
|
250
|
+
id?: string;
|
|
251
|
+
/** Classes for the root element */
|
|
252
|
+
class?: ClassValue,
|
|
253
|
+
/** Styles for the root element */
|
|
254
|
+
style?: StyleValue,
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Shows all validation messages for a form in a list.
|
|
259
|
+
*/
|
|
260
|
+
declare function MessageSummary(
|
|
261
|
+
$parent: ParentNode,
|
|
262
|
+
$anchor: Node | null,
|
|
263
|
+
$props: MessageSummaryProps | undefined,
|
|
264
|
+
$context?: Record<PropertyKey, any>,
|
|
265
|
+
$slots?: Record<string, SlotRender>,
|
|
266
|
+
): void;
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
|
|
248
270
|
interface OptionProps {
|
|
249
271
|
/** An ID for the root element */
|
|
250
272
|
id?: string;
|
|
@@ -322,6 +344,8 @@ interface TextAreaProps {
|
|
|
322
344
|
placeholder?: string,
|
|
323
345
|
/** Whether the input should be readonly */
|
|
324
346
|
readonly?: boolean,
|
|
347
|
+
/** Whether the input's value is required */
|
|
348
|
+
required?: boolean,
|
|
325
349
|
/** The maximum number of characters allowed for the input value */
|
|
326
350
|
maxlength?: number,
|
|
327
351
|
/** An ARIA label for describing the input to screen readers when there is no associated label element */
|
|
@@ -343,4 +367,4 @@ declare function TextArea(
|
|
|
343
367
|
$slots?: Record<string, SlotRender>,
|
|
344
368
|
): void;
|
|
345
369
|
|
|
346
|
-
export { CheckBox, Field, File, Form, Hidden, Input, Label, Message, Option, Select, TextArea };
|
|
370
|
+
export { CheckBox, Field, File, Form, Hidden, Input, Label, Message, MessageSummary, Option, Select, TextArea };
|
package/dist/Form/index.js
CHANGED
|
@@ -22,6 +22,9 @@ import Label_default from "./Label.torp";
|
|
|
22
22
|
// src/Form/Message.torp
|
|
23
23
|
import Message_default from "./Message.torp";
|
|
24
24
|
|
|
25
|
+
// src/Form/MessageSummary.torp
|
|
26
|
+
import MessageSummary_default from "./MessageSummary.torp";
|
|
27
|
+
|
|
25
28
|
// src/Form/Option.torp
|
|
26
29
|
import Option_default from "./Option.torp";
|
|
27
30
|
|
|
@@ -39,6 +42,7 @@ export {
|
|
|
39
42
|
Input_default as Input,
|
|
40
43
|
Label_default as Label,
|
|
41
44
|
Message_default as Message,
|
|
45
|
+
MessageSummary_default as MessageSummary,
|
|
42
46
|
Option_default as Option,
|
|
43
47
|
Select_default as Select,
|
|
44
48
|
TextArea_default as TextArea
|