@themodcraft/core-ui 1.1.1 → 1.1.2

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.
Files changed (52) hide show
  1. package/dist/components/button/Button.d.ts +1 -1
  2. package/dist/components/button/Button.js +72 -114
  3. package/dist/components/button/Button.module.css +1 -0
  4. package/dist/components/button/index.js +1 -1
  5. package/dist/components/checkbox/Checkbox.js +27 -45
  6. package/dist/components/checkbox/Checkbox.module.css +1 -0
  7. package/dist/components/checkbox/Switch.js +32 -77
  8. package/dist/components/checkbox/Switch.module.css +1 -0
  9. package/dist/components/checkbox/index.js +2 -2
  10. package/dist/components/code-block/CodeBlock.js +119 -53
  11. package/dist/components/code-block/CodeBlock.module.css +1 -0
  12. package/dist/components/code-block/index.js +1 -1
  13. package/dist/components/divider/Divider.d.ts +1 -1
  14. package/dist/components/divider/Divider.js +20 -34
  15. package/dist/components/divider/Divider.module.css +1 -0
  16. package/dist/components/divider/index.js +1 -1
  17. package/dist/components/radio/Radio.client.d.ts +2 -0
  18. package/dist/components/radio/Radio.client.js +142 -0
  19. package/dist/components/radio/Radio.d.ts +1 -1
  20. package/dist/components/radio/Radio.js +61 -76
  21. package/dist/components/radio/Radio.module.css +1 -0
  22. package/dist/components/radio/index.d.ts +1 -0
  23. package/dist/components/radio/index.js +2 -1
  24. package/dist/components/slider/Slider.js +31 -84
  25. package/dist/components/slider/Slider.module.css +1 -0
  26. package/dist/components/slider/index.js +1 -1
  27. package/dist/components/text-input/AuthFields.js +57 -11
  28. package/dist/components/text-input/TextArea.js +32 -17
  29. package/dist/components/text-input/TextInput.js +32 -13
  30. package/dist/components/text-input/TextInput.module.css +1 -0
  31. package/dist/components/text-input/contrast.client.d.ts +9 -0
  32. package/dist/components/text-input/contrast.client.js +132 -0
  33. package/dist/components/text-input/index.d.ts +1 -0
  34. package/dist/components/text-input/index.js +4 -3
  35. package/dist/components/text-input/shared.d.ts +1 -26
  36. package/dist/components/text-input/shared.js +4 -112
  37. package/dist/config/component-config.js +6 -4
  38. package/dist/index.js +16 -11
  39. package/dist/path-map/asset-path-map.js +28 -21
  40. package/dist/path-map/index.js +1 -1
  41. package/dist/styles/index.css +1 -67
  42. package/dist/tokens/default-theme.json.js +34 -0
  43. package/dist/tokens/index.js +1 -2
  44. package/dist/utils/color.js +49 -60
  45. package/package.json +7 -7
  46. package/dist/components/button/Button.types.js +0 -1
  47. package/dist/components/checkbox/Checkbox.types.js +0 -1
  48. package/dist/components/code-block/CodeBlock.types.js +0 -1
  49. package/dist/components/divider/Divider.types.js +0 -1
  50. package/dist/components/radio/Radio.types.js +0 -1
  51. package/dist/components/slider/Slider.types.js +0 -1
  52. package/dist/components/text-input/TextInput.types.js +0 -1
@@ -1 +1 @@
1
- export { Divider } from "./Divider";
1
+ export { Divider } from './Divider.js';
@@ -0,0 +1,2 @@
1
+ import type { RadioGroupProps } from "./Radio.types";
2
+ export declare function SmartRadioGroup({ defaultValue, description, label, name, onChange, onValueChange, options, value, ...props }: RadioGroupProps): import("react").JSX.Element;
@@ -0,0 +1,142 @@
1
+ "use client";
2
+ import { c } from 'react/compiler-runtime';
3
+ import { Radio } from './Radio.js';
4
+ import styles from './Radio.module.css';
5
+ import { jsx, jsxs } from 'react/jsx-runtime';
6
+
7
+ function SmartRadioGroup(t0) {
8
+ const $ = c(35);
9
+ let defaultValue;
10
+ let description;
11
+ let label;
12
+ let name;
13
+ let onChange;
14
+ let onValueChange;
15
+ let options;
16
+ let props;
17
+ let value;
18
+ if ($[0] !== t0) {
19
+ ({
20
+ defaultValue,
21
+ description,
22
+ label,
23
+ name,
24
+ onChange,
25
+ onValueChange,
26
+ options,
27
+ value,
28
+ ...props
29
+ } = t0);
30
+ $[0] = t0;
31
+ $[1] = defaultValue;
32
+ $[2] = description;
33
+ $[3] = label;
34
+ $[4] = name;
35
+ $[5] = onChange;
36
+ $[6] = onValueChange;
37
+ $[7] = options;
38
+ $[8] = props;
39
+ $[9] = value;
40
+ } else {
41
+ defaultValue = $[1];
42
+ description = $[2];
43
+ label = $[3];
44
+ name = $[4];
45
+ onChange = $[5];
46
+ onValueChange = $[6];
47
+ options = $[7];
48
+ props = $[8];
49
+ value = $[9];
50
+ }
51
+ let t1;
52
+ if ($[10] !== label) {
53
+ t1 = label ? /*#__PURE__*/jsx("legend", {
54
+ className: styles.groupLegend,
55
+ children: label
56
+ }) : null;
57
+ $[10] = label;
58
+ $[11] = t1;
59
+ } else {
60
+ t1 = $[11];
61
+ }
62
+ let t2;
63
+ if ($[12] !== description) {
64
+ t2 = description ? /*#__PURE__*/jsx("p", {
65
+ className: styles.groupDescription,
66
+ children: description
67
+ }) : null;
68
+ $[12] = description;
69
+ $[13] = t2;
70
+ } else {
71
+ t2 = $[13];
72
+ }
73
+ let t3;
74
+ if ($[14] !== defaultValue || $[15] !== name || $[16] !== onChange || $[17] !== onValueChange || $[18] !== options || $[19] !== props || $[20] !== value) {
75
+ let t4;
76
+ if ($[22] !== defaultValue || $[23] !== name || $[24] !== onChange || $[25] !== onValueChange || $[26] !== props || $[27] !== value) {
77
+ t4 = option => /*#__PURE__*/jsx(Radio, {
78
+ checked: value !== undefined ? value === option.value : undefined,
79
+ defaultChecked: defaultValue === option.value,
80
+ description: option.description,
81
+ disabled: props.disabled || option.disabled,
82
+ name: name,
83
+ onChange: event => {
84
+ onChange?.(event);
85
+ if (event.target.checked) {
86
+ onValueChange?.(option.value);
87
+ }
88
+ },
89
+ required: props.required,
90
+ value: option.value,
91
+ children: option.label
92
+ }, option.value);
93
+ $[22] = defaultValue;
94
+ $[23] = name;
95
+ $[24] = onChange;
96
+ $[25] = onValueChange;
97
+ $[26] = props;
98
+ $[27] = value;
99
+ $[28] = t4;
100
+ } else {
101
+ t4 = $[28];
102
+ }
103
+ t3 = options.map(t4);
104
+ $[14] = defaultValue;
105
+ $[15] = name;
106
+ $[16] = onChange;
107
+ $[17] = onValueChange;
108
+ $[18] = options;
109
+ $[19] = props;
110
+ $[20] = value;
111
+ $[21] = t3;
112
+ } else {
113
+ t3 = $[21];
114
+ }
115
+ let t4;
116
+ if ($[29] !== t3) {
117
+ t4 = /*#__PURE__*/jsx("div", {
118
+ className: styles.options,
119
+ children: t3
120
+ });
121
+ $[29] = t3;
122
+ $[30] = t4;
123
+ } else {
124
+ t4 = $[30];
125
+ }
126
+ let t5;
127
+ if ($[31] !== t1 || $[32] !== t2 || $[33] !== t4) {
128
+ t5 = /*#__PURE__*/jsxs("fieldset", {
129
+ className: styles.groupRoot,
130
+ children: [t1, t2, t4]
131
+ });
132
+ $[31] = t1;
133
+ $[32] = t2;
134
+ $[33] = t4;
135
+ $[34] = t5;
136
+ } else {
137
+ t5 = $[34];
138
+ }
139
+ return t5;
140
+ }
141
+
142
+ export { SmartRadioGroup };
@@ -1,3 +1,3 @@
1
1
  import type { RadioGroupProps, RadioProps } from "./Radio.types";
2
2
  export declare function Radio({ description, label, children, ...props }: RadioProps): import("react").JSX.Element;
3
- export declare function RadioGroup({ defaultValue, description, label, name, onChange, onValueChange, options, value, ...props }: RadioGroupProps): import("react").JSX.Element;
3
+ export declare function RadioGroup({ defaultValue, description, label, name, onChange, onValueChange: _onValueChange, options, value, ...props }: RadioGroupProps): import("react").JSX.Element;
@@ -1,79 +1,64 @@
1
- "use client";
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import styled from "@emotion/styled";
4
- import { useContrastedFieldStyle } from "../text-input/shared";
5
- const RadioRoot = styled.label `
6
- align-items: flex-start;
7
- color: var(--tmc-field-label-text, var(--tmc-field-auto-text, var(--tmc-color-text, #151821)));
8
- cursor: pointer;
9
- display: inline-flex;
10
- gap: 0.7rem;
11
- `;
12
- const RadioInput = styled.input `
13
- accent-color: var(--cta-color, var(--tmc-color-accent, #2454d6));
14
- cursor: pointer;
15
- flex: 0 0 auto;
16
- height: 1.1rem;
17
- margin-top: 0.1rem;
18
- width: 1.1rem;
1
+ import styles from './Radio.module.css';
2
+ import { jsxs, jsx } from 'react/jsx-runtime';
19
3
 
20
- &:focus-visible {
21
- outline: 2px solid var(--tmc-color-accent, #2454d6);
22
- outline-offset: 3px;
23
- }
24
-
25
- &:disabled {
26
- cursor: not-allowed;
27
- opacity: 0.55;
28
- }
29
- `;
30
- const Copy = styled.span `
31
- display: grid;
32
- gap: 0.2rem;
33
- line-height: 1.35;
34
- `;
35
- const Label = styled.span `
36
- color: inherit;
37
- font-size: 0.95rem;
38
- font-weight: 600;
39
- `;
40
- const Description = styled.span `
41
- color: var(--tmc-field-description-text, var(--tmc-color-text-muted, var(--tmc-field-auto-text, #5f6b7a)));
42
- font-size: 0.82rem;
43
- `;
44
- const GroupRoot = styled.fieldset `
45
- border: 0;
46
- color: var(--tmc-field-label-text, var(--tmc-field-auto-text, var(--tmc-color-text, #151821)));
47
- display: grid;
48
- gap: 0.65rem;
49
- margin: 0;
50
- min-inline-size: 0;
51
- padding: 0;
52
- `;
53
- const GroupLegend = styled.legend `
54
- color: inherit;
55
- font-size: 0.9rem;
56
- font-weight: 650;
57
- margin: 0 0 0.35rem;
58
- padding: 0;
59
- `;
60
- const GroupDescription = styled.p `
61
- color: var(--tmc-field-description-text, var(--tmc-color-text-muted, var(--tmc-field-auto-text, #5f6b7a)));
62
- font-size: 0.82rem;
63
- line-height: 1.45;
64
- margin: -0.25rem 0 0.25rem;
65
- `;
66
- const Options = styled.div `
67
- display: grid;
68
- gap: 0.75rem;
69
- `;
70
- export function Radio({ description, label, children, ...props }) {
71
- const fieldStyle = useContrastedFieldStyle();
72
- return (_jsxs(RadioRoot, { ...fieldStyle, children: [_jsx(RadioInput, { type: "radio", ...props }), (label || description || children) && (_jsxs(Copy, { children: [(label || children) && _jsx(Label, { children: label ?? children }), description && _jsx(Description, { children: description })] }))] }));
4
+ function Radio({
5
+ description,
6
+ label,
7
+ children,
8
+ ...props
9
+ }) {
10
+ return /*#__PURE__*/jsxs("label", {
11
+ className: styles.radioRoot,
12
+ children: [/*#__PURE__*/jsx("input", {
13
+ className: styles.radioInput,
14
+ type: "radio",
15
+ ...props
16
+ }), (label || description || children) && /*#__PURE__*/jsxs("span", {
17
+ className: styles.copy,
18
+ children: [(label || children) && /*#__PURE__*/jsx("span", {
19
+ className: styles.label,
20
+ children: label ?? children
21
+ }), description && /*#__PURE__*/jsx("span", {
22
+ className: styles.description,
23
+ children: description
24
+ })]
25
+ })]
26
+ });
73
27
  }
74
- export function RadioGroup({ defaultValue, description, label, name, onChange, onValueChange, options, value, ...props }) {
75
- const fieldStyle = useContrastedFieldStyle();
76
- return (_jsxs(GroupRoot, { ...fieldStyle, children: [label ? _jsx(GroupLegend, { children: label }) : null, description ? _jsx(GroupDescription, { children: description }) : null, _jsx(Options, { children: options.map((option) => (_jsx(Radio, { checked: value !== undefined ? value === option.value : undefined, defaultChecked: defaultValue === option.value, description: option.description, disabled: props.disabled || option.disabled, name: name, onChange: (event) => { onChange?.(event); if (event.target.checked) {
77
- onValueChange?.(option.value);
78
- } }, required: props.required, value: option.value, children: option.label }, option.value))) })] }));
28
+ function RadioGroup({
29
+ defaultValue,
30
+ description,
31
+ label,
32
+ name,
33
+ onChange,
34
+ onValueChange: _onValueChange,
35
+ options,
36
+ value,
37
+ ...props
38
+ }) {
39
+ return /*#__PURE__*/jsxs("fieldset", {
40
+ className: styles.groupRoot,
41
+ children: [label ? /*#__PURE__*/jsx("legend", {
42
+ className: styles.groupLegend,
43
+ children: label
44
+ }) : null, description ? /*#__PURE__*/jsx("p", {
45
+ className: styles.groupDescription,
46
+ children: description
47
+ }) : null, /*#__PURE__*/jsx("div", {
48
+ className: styles.options,
49
+ children: options.map(option => /*#__PURE__*/jsx(Radio, {
50
+ checked: value !== undefined ? value === option.value : undefined,
51
+ defaultChecked: defaultValue === option.value,
52
+ description: option.description,
53
+ disabled: props.disabled || option.disabled,
54
+ name: name,
55
+ onChange: onChange,
56
+ required: props.required,
57
+ value: option.value,
58
+ children: option.label
59
+ }, option.value))
60
+ })]
61
+ });
79
62
  }
63
+
64
+ export { Radio, RadioGroup };
@@ -0,0 +1 @@
1
+ .radioRoot{align-items:flex-start;color:var(--tmc-field-label-text,var(--tmc-field-auto-text,var(--tmc-color-text,#151821)));cursor:pointer;display:inline-flex;gap:.7rem}.radioInput{accent-color:var(--cta-color,var(--tmc-color-accent,#2454d6));cursor:pointer;flex:0 0 auto;height:1.1rem;margin-top:.1rem;width:1.1rem}.radioInput:focus-visible{outline:2px solid var(--tmc-color-accent,#2454d6);outline-offset:3px}.radioInput:disabled{cursor:not-allowed;opacity:.55}.copy{display:grid;gap:.2rem;line-height:1.35}.label{color:inherit;font-size:.95rem;font-weight:600}.description{color:var(--tmc-field-description-text,var(--tmc-color-text-muted,var(--tmc-field-auto-text,#5f6b7a)));font-size:.82rem}.groupRoot{border:0;color:var(--tmc-field-label-text,var(--tmc-field-auto-text,var(--tmc-color-text,#151821)));display:grid;gap:.65rem;margin:0;min-inline-size:0;padding:0}.groupLegend{color:inherit;font-size:.9rem;font-weight:650;margin:0 0 .35rem;padding:0}.groupDescription{color:var(--tmc-field-description-text,var(--tmc-color-text-muted,var(--tmc-field-auto-text,#5f6b7a)));font-size:.82rem;line-height:1.45;margin:-.25rem 0 .25rem}.options{display:grid;gap:.75rem}
@@ -1,2 +1,3 @@
1
1
  export { Radio, RadioGroup } from "./Radio";
2
+ export { SmartRadioGroup } from "./Radio.client";
2
3
  export type { RadioGroupProps, RadioOption, RadioProps } from "./Radio.types";
@@ -1 +1,2 @@
1
- export { Radio, RadioGroup } from "./Radio";
1
+ export { Radio, RadioGroup } from './Radio.js';
2
+ export { SmartRadioGroup } from './Radio.client.js';
@@ -1,86 +1,33 @@
1
- "use client";
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import styled from "@emotion/styled";
4
- import { useContrastedFieldStyle } from "../text-input/shared";
5
- const SliderRoot = styled.label `
6
- color: var(--tmc-field-label-text, var(--tmc-field-auto-text, var(--primary-text, var(--tmc-color-text, #151821))));
7
- display: grid;
8
- gap: 0.55rem;
9
- width: 100%;
10
- `;
11
- const SliderHeader = styled.span `
12
- align-items: center;
13
- display: flex;
14
- font-size: 0.9rem;
15
- font-weight: 600;
16
- gap: 0.75rem;
17
- justify-content: space-between;
18
- `;
19
- const SliderValue = styled.span `
20
- color: var(--tmc-field-description-text, var(--tmc-field-auto-text, var(--secondary-text, var(--tmc-color-text-muted, #5f6b7a))));
21
- font-size: 0.8rem;
22
- font-variant-numeric: tabular-nums;
23
- `;
24
- const SliderInput = styled.input `
25
- --slider-track: var(--neutral-600, var(--tmc-color-surface-muted, #e7ebf0));
26
- --slider-fill: var(--cta-color, var(--tmc-color-accent, #2454d6));
27
- --slider-thumb: var(--tmc-color-surface-raised, #fbfcfe);
28
- appearance: none;
29
- background: transparent;
30
- cursor: pointer;
31
- height: 1.5rem;
32
- width: 100%;
1
+ import styles from './Slider.module.css';
2
+ import { jsxs, jsx } from 'react/jsx-runtime';
33
3
 
34
- &::-webkit-slider-runnable-track {
35
- background: linear-gradient(90deg, var(--slider-fill), var(--slider-track));
36
- border-radius: 999px;
37
- height: 0.45rem;
38
- }
39
-
40
- &::-webkit-slider-thumb {
41
- appearance: none;
42
- background: var(--slider-thumb);
43
- border: 2px solid var(--slider-fill);
44
- border-radius: 999px;
45
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.24);
46
- height: 1.15rem;
47
- margin-top: -0.35rem;
48
- width: 1.15rem;
49
- }
50
-
51
- &::-moz-range-track {
52
- background: var(--slider-track);
53
- border-radius: 999px;
54
- height: 0.45rem;
55
- }
56
-
57
- &::-moz-range-progress {
58
- background: var(--slider-fill);
59
- border-radius: 999px;
60
- height: 0.45rem;
61
- }
62
-
63
- &::-moz-range-thumb {
64
- background: var(--slider-thumb);
65
- border: 2px solid var(--slider-fill);
66
- border-radius: 999px;
67
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.24);
68
- height: 1.15rem;
69
- width: 1.15rem;
70
- }
71
-
72
- &:focus-visible {
73
- outline: 2px solid var(--slider-fill);
74
- outline-offset: 4px;
75
- }
76
-
77
- &:disabled {
78
- cursor: not-allowed;
79
- opacity: 0.55;
80
- }
81
- `;
82
- export function Slider({ label, showValue, value, valueLabel, defaultValue, ...props }) {
83
- const renderedValue = valueLabel ?? value ?? defaultValue;
84
- const fieldStyle = useContrastedFieldStyle();
85
- return (_jsxs(SliderRoot, { ...fieldStyle, children: [(label || showValue) && (_jsxs(SliderHeader, { children: [label && _jsx("span", { children: label }), showValue && renderedValue !== undefined && _jsx(SliderValue, { children: renderedValue })] })), _jsx(SliderInput, { defaultValue: defaultValue, type: "range", value: value, ...props })] }));
4
+ function Slider({
5
+ label,
6
+ showValue,
7
+ value,
8
+ valueLabel,
9
+ defaultValue,
10
+ ...props
11
+ }) {
12
+ const renderedValue = valueLabel ?? value ?? defaultValue;
13
+ return /*#__PURE__*/jsxs("label", {
14
+ className: styles.sliderRoot,
15
+ children: [(label || showValue) && /*#__PURE__*/jsxs("span", {
16
+ className: styles.sliderHeader,
17
+ children: [label && /*#__PURE__*/jsx("span", {
18
+ children: label
19
+ }), showValue && renderedValue !== undefined && /*#__PURE__*/jsx("span", {
20
+ className: styles.sliderValue,
21
+ children: renderedValue
22
+ })]
23
+ }), /*#__PURE__*/jsx("input", {
24
+ className: styles.sliderInput,
25
+ defaultValue: defaultValue,
26
+ type: "range",
27
+ value: value,
28
+ ...props
29
+ })]
30
+ });
86
31
  }
32
+
33
+ export { Slider };
@@ -0,0 +1 @@
1
+ .sliderRoot{color:var(--tmc-field-label-text,var(--tmc-field-auto-text,var(--primary-text,var(--tmc-color-text,#151821))));display:grid;gap:.55rem;width:100%}.sliderHeader{align-items:center;display:flex;font-size:.9rem;font-weight:600;gap:.75rem;justify-content:space-between}.sliderValue{color:var(--tmc-field-description-text,var(--tmc-field-auto-text,var(--secondary-text,var(--tmc-color-text-muted,#5f6b7a))));font-size:.8rem;font-variant-numeric:tabular-nums}.sliderInput{--slider-track:var(--neutral-600,var(--tmc-color-surface-muted,#e7ebf0));--slider-fill:var(--cta-color,var(--tmc-color-accent,#2454d6));--slider-thumb:var(--tmc-color-surface-raised,#fbfcfe);appearance:none;background:transparent;cursor:pointer;height:1.5rem;width:100%}.sliderInput::-webkit-slider-runnable-track{background:linear-gradient(90deg,var(--slider-fill),var(--slider-track));border-radius:999px;height:.45rem}.sliderInput::-webkit-slider-thumb{appearance:none;background:var(--slider-thumb);border:2px solid var(--slider-fill);border-radius:999px;box-shadow:0 2px 8px rgba(0,0,0,.24);height:1.15rem;margin-top:-.35rem;width:1.15rem}.sliderInput::-moz-range-track{background:var(--slider-track);border-radius:999px;height:.45rem}.sliderInput::-moz-range-progress{background:var(--slider-fill);border-radius:999px;height:.45rem}.sliderInput::-moz-range-thumb{background:var(--slider-thumb);border:2px solid var(--slider-fill);border-radius:999px;box-shadow:0 2px 8px rgba(0,0,0,.24);height:1.15rem;width:1.15rem}.sliderInput:focus-visible{outline:2px solid var(--slider-fill);outline-offset:4px}.sliderInput:disabled{cursor:not-allowed;opacity:.55}
@@ -1 +1 @@
1
- export { Slider } from "./Slider";
1
+ export { Slider } from './Slider.js';
@@ -1,15 +1,61 @@
1
- "use client";
2
- import { jsx as _jsx } from "react/jsx-runtime";
3
- import { TextInput } from "./TextInput";
4
- export function UsernameField({ autoComplete = "username", label = "Username", type, ...props }) {
5
- return _jsx(TextInput, { autoComplete: autoComplete, label: label, type: type ?? "text", ...props });
1
+ import { TextInput } from './TextInput.js';
2
+ import { jsx } from 'react/jsx-runtime';
3
+
4
+ function UsernameField({
5
+ autoComplete = "username",
6
+ label = "Username",
7
+ type,
8
+ ...props
9
+ }) {
10
+ return /*#__PURE__*/jsx(TextInput, {
11
+ autoComplete: autoComplete,
12
+ label: label,
13
+ type: type ?? "text",
14
+ ...props
15
+ });
6
16
  }
7
- export function EmailField({ autoComplete = "email", inputMode = "email", label = "Email", type, ...props }) {
8
- return _jsx(TextInput, { autoComplete: autoComplete, inputMode: inputMode, label: label, type: type ?? "email", ...props });
17
+ function EmailField({
18
+ autoComplete = "email",
19
+ inputMode = "email",
20
+ label = "Email",
21
+ type,
22
+ ...props
23
+ }) {
24
+ return /*#__PURE__*/jsx(TextInput, {
25
+ autoComplete: autoComplete,
26
+ inputMode: inputMode,
27
+ label: label,
28
+ type: type ?? "email",
29
+ ...props
30
+ });
9
31
  }
10
- export function PasswordField({ autoComplete = "current-password", label = "Password", type, ...props }) {
11
- return _jsx(TextInput, { autoComplete: autoComplete, label: label, type: type ?? "password", ...props });
32
+ function PasswordField({
33
+ autoComplete = "current-password",
34
+ label = "Password",
35
+ type,
36
+ ...props
37
+ }) {
38
+ return /*#__PURE__*/jsx(TextInput, {
39
+ autoComplete: autoComplete,
40
+ label: label,
41
+ type: type ?? "password",
42
+ ...props
43
+ });
12
44
  }
13
- export function PhoneNumberField({ autoComplete = "tel", inputMode = "tel", label = "Phone number", type, ...props }) {
14
- return _jsx(TextInput, { autoComplete: autoComplete, inputMode: inputMode, label: label, type: type ?? "tel", ...props });
45
+ function PhoneNumberField({
46
+ autoComplete = "tel",
47
+ inputMode = "tel",
48
+ label = "Phone number",
49
+ type,
50
+ ...props
51
+ }) {
52
+ return /*#__PURE__*/jsx(TextInput, {
53
+ autoComplete: autoComplete,
54
+ inputMode: inputMode,
55
+ label: label,
56
+ type: type ?? "tel",
57
+ ...props
58
+ });
15
59
  }
60
+
61
+ export { EmailField, PasswordField, PhoneNumberField, UsernameField };
@@ -1,18 +1,33 @@
1
- "use client";
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import styled from "@emotion/styled";
4
- import { FieldDescription, FieldError, FieldLabel, FieldRoot, inputSurfaceStyles, useContrastedFieldStyle, useContrastedInputStyle, } from "./shared";
5
- const StyledTextArea = styled.textarea `
6
- ${inputSurfaceStyles}
7
- line-height: 1.5;
8
- max-height: var(--tmc-textarea-max-height, 18rem);
9
- min-height: 7rem;
10
- overflow: auto;
11
- padding: 0.75rem 0.85rem;
12
- resize: vertical;
13
- `;
14
- export function TextArea({ description, error, label, "aria-invalid": ariaInvalid, style, ...props }) {
15
- const fieldStyle = useContrastedFieldStyle();
16
- const inputStyle = useContrastedInputStyle(style);
17
- return (_jsxs(FieldRoot, { ...fieldStyle, children: [label && _jsx(FieldLabel, { children: label }), _jsx(StyledTextArea, { "aria-invalid": ariaInvalid ?? Boolean(error), ...inputStyle, ...props }), description && !error ? _jsx(FieldDescription, { children: description }) : null, error ? _jsx(FieldError, { children: error }) : null] }));
1
+ import { classNames } from './shared.js';
2
+ import styles from './TextInput.module.css';
3
+ import { jsxs, jsx } from 'react/jsx-runtime';
4
+
5
+ function TextArea({
6
+ description,
7
+ error,
8
+ label,
9
+ "aria-invalid": ariaInvalid,
10
+ style,
11
+ ...props
12
+ }) {
13
+ return /*#__PURE__*/jsxs("label", {
14
+ className: styles.fieldRoot,
15
+ children: [label && /*#__PURE__*/jsx("span", {
16
+ className: styles.fieldLabel,
17
+ children: label
18
+ }), /*#__PURE__*/jsx("textarea", {
19
+ "aria-invalid": ariaInvalid ?? Boolean(error),
20
+ className: classNames(styles.inputSurface, styles.textarea),
21
+ style: style,
22
+ ...props
23
+ }), description && !error ? /*#__PURE__*/jsx("span", {
24
+ className: styles.fieldDescription,
25
+ children: description
26
+ }) : null, error ? /*#__PURE__*/jsx("span", {
27
+ className: styles.fieldError,
28
+ children: error
29
+ }) : null]
30
+ });
18
31
  }
32
+
33
+ export { TextArea };
@@ -1,14 +1,33 @@
1
- "use client";
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import styled from "@emotion/styled";
4
- import { FieldDescription, FieldError, FieldLabel, FieldRoot, inputSurfaceStyles, useContrastedFieldStyle, useContrastedInputStyle, } from "./shared";
5
- const StyledInput = styled.input `
6
- ${inputSurfaceStyles}
7
- min-height: 2.6rem;
8
- padding: 0 0.85rem;
9
- `;
10
- export function TextInput({ description, error, label, "aria-invalid": ariaInvalid, style, ...props }) {
11
- const fieldStyle = useContrastedFieldStyle();
12
- const inputStyle = useContrastedInputStyle(style);
13
- return (_jsxs(FieldRoot, { ...fieldStyle, children: [label && _jsx(FieldLabel, { children: label }), _jsx(StyledInput, { "aria-invalid": ariaInvalid ?? Boolean(error), ...inputStyle, ...props }), description && !error ? _jsx(FieldDescription, { children: description }) : null, error ? _jsx(FieldError, { children: error }) : null] }));
1
+ import { classNames } from './shared.js';
2
+ import styles from './TextInput.module.css';
3
+ import { jsxs, jsx } from 'react/jsx-runtime';
4
+
5
+ function TextInput({
6
+ description,
7
+ error,
8
+ label,
9
+ "aria-invalid": ariaInvalid,
10
+ style,
11
+ ...props
12
+ }) {
13
+ return /*#__PURE__*/jsxs("label", {
14
+ className: styles.fieldRoot,
15
+ children: [label && /*#__PURE__*/jsx("span", {
16
+ className: styles.fieldLabel,
17
+ children: label
18
+ }), /*#__PURE__*/jsx("input", {
19
+ "aria-invalid": ariaInvalid ?? Boolean(error),
20
+ className: classNames(styles.inputSurface, styles.input),
21
+ style: style,
22
+ ...props
23
+ }), description && !error ? /*#__PURE__*/jsx("span", {
24
+ className: styles.fieldDescription,
25
+ children: description
26
+ }) : null, error ? /*#__PURE__*/jsx("span", {
27
+ className: styles.fieldError,
28
+ children: error
29
+ }) : null]
30
+ });
14
31
  }
32
+
33
+ export { TextInput };
@@ -0,0 +1 @@
1
+ .fieldRoot{color:var(--tmc-field-label-text,var(--tmc-field-auto-text,var(--tmc-color-text,#151821)));display:grid;gap:.45rem;width:100%}.fieldLabel{color:inherit;font-size:.9rem;font-weight:650}.fieldDescription{color:var(--tmc-field-description-text,var(--tmc-color-text-muted,var(--tmc-field-auto-text,#5f6b7a)))}.fieldDescription,.fieldError{font-size:.82rem;line-height:1.45}.fieldError{color:var(--tmc-color-danger,#b42318)}.inputSurface{background:var(--tmc-color-surface-raised,#fbfcfe);border:1px solid var(--tmc-color-border,#d7dde5);border-radius:var(--tmc-radius-md,6px);color:var(--tmc-input-text,var(--tmc-input-auto-text,var(--tmc-color-on-surface-raised,#151821)));font:inherit;outline:0;transition:background-color .18s ease,border-color .18s ease,box-shadow .18s ease;width:100%}.inputSurface::placeholder{color:var(--tmc-input-placeholder-text,var(--tmc-input-auto-text,var(--tmc-color-text-muted,#5f6b7a)));opacity:.72}.inputSurface:focus{border-color:var(--tmc-color-accent,#2454d6);box-shadow:0 0 0 3px color-mix(in srgb,var(--tmc-color-accent,#2454d6) 24%,transparent)}.inputSurface:disabled{cursor:not-allowed;opacity:.58}.inputSurface[aria-invalid=true]{border-color:var(--tmc-color-danger,#b42318)}.input{min-height:2.6rem;padding:0 .85rem}.textarea{line-height:1.5;max-height:var(--tmc-textarea-max-height,18rem);min-height:7rem;overflow:auto;padding:.75rem .85rem;resize:vertical}
@@ -0,0 +1,9 @@
1
+ import type { CSSProperties } from "react";
2
+ export declare function useContrastedFieldStyle<T extends HTMLElement>(style?: CSSProperties): {
3
+ ref: import("react").RefObject<T | null>;
4
+ style: CSSProperties;
5
+ };
6
+ export declare function useContrastedInputStyle<T extends HTMLElement>(style?: CSSProperties): {
7
+ ref: import("react").RefObject<T | null>;
8
+ style: CSSProperties;
9
+ };