@torpor/ui 1.1.3 → 1.1.5
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/Form/CheckBox.torp +1 -6
- package/dist/Form/Field.torp +5 -2
- package/dist/Form/File.torp +1 -6
- package/dist/Form/FileDrop.torp +1 -6
- package/dist/Form/Input.torp +1 -5
- package/dist/Form/Select.torp +1 -6
- package/dist/Form/TextArea.torp +1 -6
- package/dist/Form/Toggle.torp +1 -6
- package/package.json +5 -5
package/dist/Form/CheckBox.torp
CHANGED
|
@@ -32,16 +32,11 @@ interface CheckBoxProps {
|
|
|
32
32
|
export default function CheckBox($props: CheckBoxProps | undefined) {
|
|
33
33
|
let defaultId = getId();
|
|
34
34
|
|
|
35
|
-
let name = $props?.name;
|
|
36
|
-
|
|
37
35
|
let blurred = false;
|
|
38
36
|
|
|
39
37
|
// Get stuff out of the FormContext and FieldContext
|
|
40
38
|
const formContext = $context[FormContextName] as FormContext;
|
|
41
39
|
const fieldContext = $context[FieldContextName] as FieldContext;
|
|
42
|
-
if (fieldContext) {
|
|
43
|
-
name ??= fieldContext.name;
|
|
44
|
-
}
|
|
45
40
|
|
|
46
41
|
// Use the FieldContext's state, or create a new one
|
|
47
42
|
let $state =
|
|
@@ -88,7 +83,7 @@ export default function CheckBox($props: CheckBoxProps | undefined) {
|
|
|
88
83
|
id={$props?.id ?? defaultId}
|
|
89
84
|
class={["torp-check-box", $props?.class]}
|
|
90
85
|
type="checkbox"
|
|
91
|
-
{name}
|
|
86
|
+
name={$props?.name ?? fieldContext?.name}
|
|
92
87
|
&checked={$state.value}
|
|
93
88
|
aria-label={$props?.ariaLabel}
|
|
94
89
|
data-valid={$state.valid ? "valid" : "invalid"}
|
package/dist/Form/Field.torp
CHANGED
|
@@ -53,9 +53,12 @@ export default function Field($props: FieldProps) {
|
|
|
53
53
|
});
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
// Set the context to pass down to Labels, Inputs and Messages
|
|
56
|
+
// Set the context to pass down to Labels, Inputs and Messages. `name` is a
|
|
57
|
+
// getter so that consumers see updates if the prop changes after mount.
|
|
57
58
|
let context: FieldContext = {
|
|
58
|
-
name
|
|
59
|
+
get name() {
|
|
60
|
+
return $props.name;
|
|
61
|
+
},
|
|
59
62
|
state: $state,
|
|
60
63
|
validate: handleValidate,
|
|
61
64
|
};
|
package/dist/Form/File.torp
CHANGED
|
@@ -38,16 +38,11 @@ interface FileProps {
|
|
|
38
38
|
export default function File($props: FileProps | undefined) {
|
|
39
39
|
let defaultId = getId();
|
|
40
40
|
|
|
41
|
-
let name = $props?.name;
|
|
42
|
-
|
|
43
41
|
let blurred = false;
|
|
44
42
|
|
|
45
43
|
// Get stuff out of the FormContext and FieldContext
|
|
46
44
|
const formContext = $context[FormContextName] as FormContext;
|
|
47
45
|
const fieldContext = $context[FieldContextName] as FieldContext;
|
|
48
|
-
if (fieldContext) {
|
|
49
|
-
name ??= fieldContext.name;
|
|
50
|
-
}
|
|
51
46
|
|
|
52
47
|
// This will change the form's enctype to `multipart/form-data`
|
|
53
48
|
if (formContext) {
|
|
@@ -94,7 +89,7 @@ export default function File($props: FileProps | undefined) {
|
|
|
94
89
|
class={["torp-file", $props?.class]}
|
|
95
90
|
{$props?.style}
|
|
96
91
|
type="file"
|
|
97
|
-
{name}
|
|
92
|
+
name={$props?.name ?? fieldContext?.name}
|
|
98
93
|
{$props?.accept}
|
|
99
94
|
{$props?.placeholder}
|
|
100
95
|
{$props?.readonly}
|
package/dist/Form/FileDrop.torp
CHANGED
|
@@ -39,8 +39,6 @@ export default function FileDrop($props: FileDropProps | undefined) {
|
|
|
39
39
|
let inputId = `${$props?.id ?? defaultId}-input`;
|
|
40
40
|
let input: HTMLInputElement;
|
|
41
41
|
|
|
42
|
-
let name = $props?.name;
|
|
43
|
-
|
|
44
42
|
let blurred = false;
|
|
45
43
|
|
|
46
44
|
function getDisabled(): boolean {
|
|
@@ -50,9 +48,6 @@ export default function FileDrop($props: FileDropProps | undefined) {
|
|
|
50
48
|
// Get stuff out of the FormContext and FieldContext
|
|
51
49
|
const formContext = $context[FormContextName] as FormContext;
|
|
52
50
|
const fieldContext = $context[FieldContextName] as FieldContext;
|
|
53
|
-
if (fieldContext) {
|
|
54
|
-
name ??= fieldContext.name;
|
|
55
|
-
}
|
|
56
51
|
|
|
57
52
|
// This will change the form's enctype to `multipart/form-data`
|
|
58
53
|
if (formContext) {
|
|
@@ -166,7 +161,7 @@ export default function FileDrop($props: FileDropProps | undefined) {
|
|
|
166
161
|
id={inputId}
|
|
167
162
|
class="torp-file-drop-input"
|
|
168
163
|
type="file"
|
|
169
|
-
{name}
|
|
164
|
+
name={$props?.name ?? fieldContext?.name}
|
|
170
165
|
aria-hidden="true"
|
|
171
166
|
tabindex={-1}
|
|
172
167
|
multiple={$props?.multiple}
|
package/dist/Form/Input.torp
CHANGED
|
@@ -43,16 +43,12 @@ export default function Input($props: InputProps | undefined) {
|
|
|
43
43
|
let defaultId = getId();
|
|
44
44
|
|
|
45
45
|
let type = $props?.type ?? "text";
|
|
46
|
-
let name = $props?.name;
|
|
47
46
|
|
|
48
47
|
let blurred = false;
|
|
49
48
|
|
|
50
49
|
// Get stuff out of the FormContext and FieldContext
|
|
51
50
|
const formContext = $context[FormContextName] as FormContext;
|
|
52
51
|
const fieldContext = $context[FieldContextName] as FieldContext;
|
|
53
|
-
if (fieldContext) {
|
|
54
|
-
name ??= fieldContext.name;
|
|
55
|
-
}
|
|
56
52
|
|
|
57
53
|
// Use the FieldContext's state, or create a new one
|
|
58
54
|
let $state =
|
|
@@ -100,7 +96,7 @@ export default function Input($props: InputProps | undefined) {
|
|
|
100
96
|
class={["torp-input", $props?.class]}
|
|
101
97
|
{$props?.style}
|
|
102
98
|
{type}
|
|
103
|
-
{name}
|
|
99
|
+
name={$props?.name ?? fieldContext?.name}
|
|
104
100
|
&value={$state.value}
|
|
105
101
|
{$props?.placeholder}
|
|
106
102
|
{$props?.readonly}
|
package/dist/Form/Select.torp
CHANGED
|
@@ -36,16 +36,11 @@ interface SelectProps {
|
|
|
36
36
|
export default function Select($props: SelectProps | undefined) {
|
|
37
37
|
let defaultId = getId();
|
|
38
38
|
|
|
39
|
-
let name = $props?.name;
|
|
40
|
-
|
|
41
39
|
let blurred = false;
|
|
42
40
|
|
|
43
41
|
// Get stuff out of the FormContext and FieldContext
|
|
44
42
|
const formContext = $context[FormContextName] as FormContext;
|
|
45
43
|
const fieldContext = $context[FieldContextName] as FieldContext;
|
|
46
|
-
if (fieldContext) {
|
|
47
|
-
name ??= fieldContext.name;
|
|
48
|
-
}
|
|
49
44
|
|
|
50
45
|
// Use the FieldContext's state, or create a new one
|
|
51
46
|
let $state =
|
|
@@ -87,7 +82,7 @@ export default function Select($props: SelectProps | undefined) {
|
|
|
87
82
|
id={$props?.id ?? defaultId}
|
|
88
83
|
class={["torp-select", $props?.class]}
|
|
89
84
|
{$props?.style}
|
|
90
|
-
{name}
|
|
85
|
+
name={$props?.name ?? fieldContext?.name}
|
|
91
86
|
&value={$state.value}
|
|
92
87
|
{$props?.placeholder}
|
|
93
88
|
{$props?.readonly}
|
package/dist/Form/TextArea.torp
CHANGED
|
@@ -42,16 +42,11 @@ interface TextAreaProps {
|
|
|
42
42
|
export default function TextArea($props: TextAreaProps | undefined) {
|
|
43
43
|
let defaultId = getId();
|
|
44
44
|
|
|
45
|
-
let name = $props?.name;
|
|
46
|
-
|
|
47
45
|
let blurred = false;
|
|
48
46
|
|
|
49
47
|
// Get stuff out of the FormContext and FieldContext
|
|
50
48
|
const formContext = $context[FormContextName] as FormContext;
|
|
51
49
|
const fieldContext = $context[FieldContextName] as FieldContext;
|
|
52
|
-
if (fieldContext) {
|
|
53
|
-
name ??= fieldContext.name;
|
|
54
|
-
}
|
|
55
50
|
|
|
56
51
|
// Use the FieldContext's state, or create a new one
|
|
57
52
|
let $state =
|
|
@@ -93,7 +88,7 @@ export default function TextArea($props: TextAreaProps | undefined) {
|
|
|
93
88
|
id={$props?.id ?? defaultId}
|
|
94
89
|
class={["torp-text-area", $props?.class]}
|
|
95
90
|
{$props?.style}
|
|
96
|
-
{name}
|
|
91
|
+
name={$props?.name ?? fieldContext?.name}
|
|
97
92
|
&value={$state.value}
|
|
98
93
|
{$props?.rows}
|
|
99
94
|
{$props?.placeholder}
|
package/dist/Form/Toggle.torp
CHANGED
|
@@ -36,16 +36,11 @@ interface ToggleProps {
|
|
|
36
36
|
export default function Toggle($props: ToggleProps | undefined) {
|
|
37
37
|
let defaultId = getId();
|
|
38
38
|
|
|
39
|
-
let name = $props?.name;
|
|
40
|
-
|
|
41
39
|
let blurred = false;
|
|
42
40
|
|
|
43
41
|
// Get stuff out of the FormContext and FieldContext
|
|
44
42
|
const formContext = $context[FormContextName] as FormContext;
|
|
45
43
|
const fieldContext = $context[FieldContextName] as FieldContext;
|
|
46
|
-
if (fieldContext) {
|
|
47
|
-
name ??= fieldContext.name;
|
|
48
|
-
}
|
|
49
44
|
|
|
50
45
|
// Use the FieldContext's state, or create a new one
|
|
51
46
|
let $state =
|
|
@@ -93,7 +88,7 @@ export default function Toggle($props: ToggleProps | undefined) {
|
|
|
93
88
|
class={["torp-toggle", $props?.class]}
|
|
94
89
|
type="checkbox"
|
|
95
90
|
role="switch"
|
|
96
|
-
{name}
|
|
91
|
+
name={$props?.name ?? fieldContext?.name}
|
|
97
92
|
&checked={$state.value}
|
|
98
93
|
aria-checked={$state.value === true ? "true" : "false"}
|
|
99
94
|
disabled={$props?.disabled}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@torpor/ui",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.5",
|
|
4
4
|
"description": "Accessible, unstyled components for use in your Torpor front-end",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"torpor": true,
|
|
@@ -181,8 +181,8 @@
|
|
|
181
181
|
"author": "",
|
|
182
182
|
"license": "ISC",
|
|
183
183
|
"dependencies": {
|
|
184
|
-
"@torpor/unplugin": "^1.0
|
|
185
|
-
"@torpor/view": "^1.1.
|
|
184
|
+
"@torpor/unplugin": "^1.1.0",
|
|
185
|
+
"@torpor/view": "^1.1.2"
|
|
186
186
|
},
|
|
187
187
|
"devDependencies": {
|
|
188
188
|
"@testing-library/dom": "^10.4.1",
|
|
@@ -198,8 +198,8 @@
|
|
|
198
198
|
"vite": "npm:@voidzero-dev/vite-plus-core@0.3.0",
|
|
199
199
|
"vite-plus": "0.3.0",
|
|
200
200
|
"zod": "^4.4.3",
|
|
201
|
-
"@torpor/
|
|
202
|
-
"@torpor/
|
|
201
|
+
"@torpor/prettier": "^1.0.6",
|
|
202
|
+
"@torpor/check": "^1.0.6"
|
|
203
203
|
},
|
|
204
204
|
"scripts": {
|
|
205
205
|
"build": "tsgo --noEmit && vp pack",
|