@formhaus/core 0.9.0 → 0.10.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/style.css CHANGED
@@ -1,60 +1,65 @@
1
- /**
2
- * @formhaus/core baseline styles.
3
- * Optional. Import from React or Vue apps:
4
- *
5
- * import '@formhaus/core/style.css';
6
- *
7
- * Override any custom property below to retheme without forking the CSS.
8
- */
9
-
10
1
  :where(.fh-form) {
11
- --fh-color-text: #111827;
12
- --fh-color-text-muted: #6b7280;
13
- --fh-color-border: #d1d5db;
14
- --fh-color-border-focus: #2563eb;
15
- --fh-color-error: #dc2626;
2
+ --fh-color-text: #18181b;
3
+ --fh-color-text-muted: #5f5f68;
4
+ --fh-color-border: #d4d4d8;
5
+ --fh-color-border-hover: #a1a1aa;
6
+ --fh-color-border-focus: var(--fh-color-primary);
7
+ --fh-color-error: #c0352d;
16
8
  --fh-color-bg: #ffffff;
17
- --fh-color-bg-disabled: #f3f4f6;
18
- --fh-color-primary: #2563eb;
19
- --fh-color-primary-hover: #1d4ed8;
9
+ --fh-color-bg-disabled: #f4f4f5;
10
+ --fh-color-primary: #5502fb;
11
+ --fh-color-primary-hover: #4400cc;
20
12
  --fh-color-primary-text: #ffffff;
21
- --fh-color-secondary-border: #d1d5db;
22
- --fh-radius: 6px;
23
- --fh-gap: 16px;
24
- --fh-input-padding: 8px 12px;
25
- --fh-font-size: 14px;
13
+ --fh-color-primary-soft: #f5f0ff;
14
+ --fh-color-secondary-border: #d4d4d8;
15
+ --fh-radius: 10px;
16
+ --fh-gap: 28px;
17
+ --fh-input-padding: 10px 14px;
18
+ --fh-control-height: 46px;
19
+ --fh-font-size: 15px;
26
20
  --fh-font-size-small: 13px;
27
21
  }
28
22
 
29
- .fh-form {
30
- display: flex;
31
- flex-direction: column;
32
- gap: var(--fh-gap);
33
- color: var(--fh-color-text);
34
- font-size: var(--fh-font-size);
23
+ :where([data-fh-theme="dark"] .fh-form, .fh-form[data-fh-theme="dark"]) {
24
+ color-scheme: dark;
25
+ --fh-color-text: #ececee;
26
+ --fh-color-text-muted: #a8a8b3;
27
+ --fh-color-border: #3a3a41;
28
+ --fh-color-border-hover: #5a5a63;
29
+ --fh-color-error: #f2736a;
30
+ --fh-color-bg: #18181c;
31
+ --fh-color-bg-disabled: #232328;
32
+ --fh-color-primary: #7c4dff;
33
+ --fh-color-primary-hover: #8d63ff;
34
+ --fh-color-primary-text: #ffffff;
35
+ --fh-color-primary-soft: #241a3d;
36
+ --fh-color-secondary-border: #3a3a41;
35
37
  }
36
38
 
37
- .fh-form__fields {
38
- display: flex;
39
- flex-direction: column;
40
- gap: var(--fh-gap);
39
+ @supports (color: color-mix(in srgb, red, blue)) {
40
+ :where(.fh-form) {
41
+ --fh-color-primary-hover: color-mix(in srgb, var(--fh-color-primary) 82%, #000000);
42
+ --fh-color-primary-soft: color-mix(in srgb, var(--fh-color-primary) 9%, var(--fh-color-bg));
43
+ }
44
+ :where([data-fh-theme="dark"] .fh-form, .fh-form[data-fh-theme="dark"]) { --fh-color-primary-hover: color-mix(in srgb, var(--fh-color-primary) 85%, #ffffff); }
41
45
  }
42
46
 
43
- .fh-field {
44
- display: flex;
45
- flex-direction: column;
46
- gap: 4px;
47
- }
47
+ .fh-form, .fh-form__fields { display: grid; grid-template-columns: 100%; gap: var(--fh-gap); }
48
48
 
49
- .fh-field__label {
50
- font-weight: 500;
51
- }
49
+ .fh-form { color: var(--fh-color-text); font-size: var(--fh-font-size); line-height: 1.5; }
52
50
 
53
- .fh-field__required {
54
- color: var(--fh-color-error);
55
- }
51
+ .fh-field { display: flex; flex-direction: column; gap: 8px; min-width: 0; margin: 0; padding: 0; border: 0; }
52
+
53
+ .fh-field__label { font-size: var(--fh-font-size); font-weight: 600; line-height: 1.4; }
54
+ legend.fh-field__label { padding: 0; margin-bottom: 8px; }
55
+ .fh-field__required { color: var(--fh-color-error); }
56
+
57
+ .fh-field__helper { margin: -4px 0 2px; color: var(--fh-color-text-muted); font-size: var(--fh-font-size-small); line-height: 1.45; }
56
58
 
57
59
  .fh-field__input {
60
+ width: 100%;
61
+ min-height: var(--fh-control-height);
62
+ box-sizing: border-box;
58
63
  padding: var(--fh-input-padding);
59
64
  border: 1px solid var(--fh-color-border);
60
65
  border-radius: var(--fh-radius);
@@ -62,156 +67,154 @@
62
67
  color: inherit;
63
68
  font: inherit;
64
69
  font-size: var(--fh-font-size);
65
- width: 100%;
66
- box-sizing: border-box;
70
+ transition: border-color 120ms, box-shadow 120ms;
67
71
  }
68
72
 
69
- .fh-field__input:focus {
70
- outline: none;
71
- border-color: var(--fh-color-border-focus);
72
- box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
73
- }
73
+ .fh-field__input::placeholder { color: var(--fh-color-text-muted); opacity: 0.8; }
74
+ .fh-field__input:hover:not(:disabled, :focus) { border-color: var(--fh-color-border-hover); }
75
+ .fh-field__input:focus { outline: 2px solid var(--fh-color-border-focus); outline-offset: 1px; border-color: var(--fh-color-border-focus); }
76
+ .fh-field__input:disabled { background: var(--fh-color-bg-disabled); cursor: not-allowed; }
77
+ .fh-field__input--textarea { min-height: 112px; resize: vertical; }
74
78
 
75
- .fh-field__input:disabled {
76
- background: var(--fh-color-bg-disabled);
77
- cursor: not-allowed;
79
+ .fh-field__input--select {
80
+ padding-right: 44px;
81
+ text-overflow: ellipsis;
82
+ appearance: none;
83
+ background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
84
+ background-position: right 21px center, right 16px center;
85
+ background-size: 5px 5px;
86
+ background-repeat: no-repeat;
78
87
  }
79
88
 
80
- .fh-field__input[aria-invalid="true"] {
81
- border-color: var(--fh-color-error);
82
- }
83
-
84
- .fh-field__input--textarea {
85
- resize: vertical;
86
- min-height: 80px;
87
- }
88
-
89
- .fh-field__error,
90
- .fh-form__top-error {
91
- color: var(--fh-color-error);
92
- font-size: var(--fh-font-size-small);
93
- margin: 0;
94
- }
95
-
96
- .fh-field__helper {
97
- color: var(--fh-color-text-muted);
98
- font-size: var(--fh-font-size-small);
99
- margin: 0;
100
- }
101
-
102
- .fh-form__top-errors {
103
- display: flex;
104
- flex-direction: column;
105
- gap: 4px;
106
- }
107
-
108
- .fh-field--checkbox .fh-field__checkbox-wrapper,
109
- .fh-field--switch .fh-field__switch-wrapper {
110
- display: flex;
111
- align-items: center;
112
- gap: 8px;
113
- }
89
+ .fh-field__error, .fh-form__top-error { margin: 0; color: var(--fh-color-error); font-size: var(--fh-font-size-small); font-weight: 500; }
90
+ .fh-form__top-errors { display: flex; flex-direction: column; gap: 4px; }
114
91
 
115
- .fh-field__radio-group,
116
- .fh-field__multiselect-group {
117
- display: flex;
118
- flex-direction: column;
119
- gap: 6px;
120
- }
92
+ .fh-field__radio-group, .fh-field__multiselect-group { display: flex; flex-direction: column; gap: 8px; }
93
+ .fh-field__radio-group--inline, .fh-field__multiselect-group--inline { flex-flow: row wrap; }
121
94
 
122
95
  .fh-field__radio-option,
123
96
  .fh-field__multiselect-option {
97
+ position: relative;
124
98
  display: flex;
125
- align-items: center;
126
- gap: 8px;
127
- }
128
-
129
- .fh-form-actions {
130
- display: flex;
131
- gap: 8px;
132
- align-items: center;
99
+ align-items: flex-start;
100
+ gap: 12px;
101
+ padding: 12px 14px;
102
+ border: 1px solid var(--fh-color-border);
103
+ border-radius: var(--fh-radius);
104
+ background: var(--fh-color-bg);
105
+ transition: border-color 120ms, background-color 120ms;
106
+ }
107
+
108
+ :is(.fh-field__radio-option, .fh-field__multiselect-option):hover { border-color: var(--fh-color-border-hover); }
109
+ :is(.fh-field__radio-option, .fh-field__multiselect-option):has(:checked) { border-color: var(--fh-color-primary); background: var(--fh-color-primary-soft); }
110
+ :is(.fh-field__radio-option, .fh-field__multiselect-option):has(:disabled) { opacity: 0.6; }
111
+ :is(.fh-field__radio-option, .fh-field__multiselect-option):has(:focus-visible) { outline: 2px solid var(--fh-color-border-focus); outline-offset: 2px; }
112
+ @supports selector(:has(*)) { :is(.fh-field__radio-option, .fh-field__multiselect-option) input:focus-visible { outline: none; } }
113
+ :is(.fh-field__radio-label, .fh-field__multiselect-label) { flex: 1 1 auto; cursor: pointer; }
114
+ :is(.fh-field__radio-label, .fh-field__multiselect-label, .fh-field__checkbox-wrapper .fh-field__label, .fh-field__switch-wrapper .fh-field__label)::before { content: ""; position: absolute; inset: 0; border-radius: inherit; }
115
+
116
+ .fh-field__checkbox-wrapper, .fh-field__switch-wrapper { position: relative; display: flex; align-items: flex-start; gap: 12px; }
117
+
118
+ :is(.fh-field__checkbox-wrapper, .fh-field__switch-wrapper) .fh-field__label { font-weight: 400; line-height: 1.5; cursor: pointer; }
119
+
120
+ .fh-field__radio,
121
+ .fh-field__checkbox,
122
+ .fh-field__switch {
123
+ position: relative;
124
+ z-index: 1;
125
+ flex: none;
126
+ width: 18px;
127
+ height: 18px;
128
+ margin: 2px 0 0;
129
+ border: 1.5px solid var(--fh-color-border-hover);
130
+ background: var(--fh-color-bg);
131
+ appearance: none;
132
+ cursor: pointer;
133
+ transition: background-color 120ms, border-color 120ms, box-shadow 120ms;
134
+ }
135
+
136
+ .fh-field__radio { border-width: 2px; border-radius: 50%; }
137
+ .fh-field__radio:checked { border-color: var(--fh-color-primary); background: radial-gradient(circle closest-side, var(--fh-color-primary) 4px, var(--fh-color-bg) 4.5px); }
138
+ .fh-field__checkbox { border-radius: 5px; }
139
+ .fh-field__checkbox:checked { border-color: var(--fh-color-primary); background: var(--fh-color-primary); }
140
+
141
+ .fh-field__checkbox:checked::after {
142
+ content: "";
143
+ position: absolute;
144
+ inset: 0;
145
+ background: var(--fh-color-primary-text);
146
+ --fh-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 8.5l3 3 6-7' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
147
+ -webkit-mask: var(--fh-check) center / 14px no-repeat;
148
+ mask: var(--fh-check) center / 14px no-repeat;
149
+ }
150
+
151
+ .fh-field__switch { width: 36px; height: 22px; margin: 1px 0 0; border: 0; border-radius: 999px; background: var(--fh-color-border); }
152
+ .fh-field__switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--fh-color-primary-text); transition: transform 150ms; }
153
+ .fh-field__switch:checked { background: var(--fh-color-primary); }
154
+ .fh-field__switch:checked::after { transform: translateX(14px); }
155
+ :is(.fh-field__radio, .fh-field__checkbox, .fh-field__switch):focus-visible { outline: 2px solid var(--fh-color-border-focus); outline-offset: 2px; }
156
+ :is(.fh-field__radio, .fh-field__checkbox, .fh-field__switch):disabled { cursor: not-allowed; }
157
+
158
+ .fh-field__input[aria-invalid="true"],
159
+ .fh-field__checkbox[aria-invalid="true"],
160
+ .fh-field[aria-invalid="true"] :is(.fh-field__radio-option, .fh-field__multiselect-option) {
161
+ border-color: var(--fh-color-error);
133
162
  }
134
163
 
135
- .fh-form-actions__secondary {
136
- display: flex;
137
- gap: 8px;
138
- margin-left: auto;
139
- }
164
+ .fh-form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding-top: 4px; }
165
+ .fh-form-actions__secondary { display: flex; gap: 8px; margin-right: auto; }
166
+ .fh-form-actions__secondary:empty { display: none; }
140
167
 
141
168
  .fh-form-actions__button {
142
- padding: 8px 16px;
143
- border-radius: var(--fh-radius);
169
+ min-height: var(--fh-control-height);
170
+ padding: 0 20px;
144
171
  border: 1px solid transparent;
172
+ border-radius: var(--fh-radius);
145
173
  background: transparent;
146
174
  color: inherit;
147
175
  font: inherit;
148
176
  font-size: var(--fh-font-size);
177
+ font-weight: 600;
149
178
  cursor: pointer;
179
+ transition: background-color 120ms, border-color 120ms, box-shadow 120ms;
150
180
  }
151
181
 
152
- .fh-form-actions__button:disabled {
153
- opacity: 0.5;
154
- cursor: not-allowed;
155
- }
156
-
157
- .fh-form-actions__button--primary {
158
- background: var(--fh-color-primary);
159
- color: var(--fh-color-primary-text);
160
- }
182
+ .fh-form-actions__button:focus-visible { outline: 2px solid var(--fh-color-border-focus); outline-offset: 2px; }
183
+ .fh-form-actions__button:disabled { opacity: 0.5; cursor: not-allowed; }
184
+ .fh-form-actions__button--primary { margin-left: auto; background: var(--fh-color-primary); color: var(--fh-color-primary-text); }
185
+ .fh-form-actions__button--primary:hover:not(:disabled) { background: var(--fh-color-primary-hover); }
186
+ .fh-form-actions__button--secondary { border-color: var(--fh-color-secondary-border); background: var(--fh-color-bg); }
187
+ .fh-form-actions__button--secondary:hover:not(:disabled) { border-color: var(--fh-color-border-hover); }
188
+ .fh-form-actions__button--text { padding: 0 10px; color: var(--fh-color-text-muted); font-weight: 500; }
189
+ .fh-form-actions__button--text:hover:not(:disabled) { color: var(--fh-color-text); }
161
190
 
162
- .fh-form-actions__button--primary:hover:not(:disabled) {
163
- background: var(--fh-color-primary-hover);
191
+ @media (max-width: 480px) {
192
+ .fh-form-actions__button--primary, .fh-form-actions__secondary { flex: 1 0 100%; }
193
+ .fh-form-actions__secondary { justify-content: space-between; }
164
194
  }
165
195
 
166
- .fh-form-actions__button--secondary {
167
- border-color: var(--fh-color-secondary-border);
196
+ @media (pointer: coarse) {
197
+ :where(.fh-form) { --fh-font-size: 17px; --fh-font-size-small: 15px; }
198
+ .fh-field__input { font-size: max(16px, var(--fh-font-size)); }
199
+ :is(.fh-field__checkbox-wrapper, .fh-field__switch-wrapper) { padding-block: 10px; }
200
+ .fh-field__radio, .fh-field__checkbox { margin-top: 4px; }
168
201
  }
169
202
 
170
- .fh-form-actions__button--secondary:hover:not(:disabled) {
171
- background: var(--fh-color-bg-disabled);
172
- }
203
+ .fh-step-progress { display: flex; flex-direction: column; gap: 6px; }
204
+ .fh-step-progress__counter { color: var(--fh-color-text-muted); font-size: var(--fh-font-size-small); }
205
+ .fh-step-progress__title { margin: 4px 0 0; font-size: 18px; font-weight: 600; line-height: 1.35; }
206
+ .fh-step-progress__description { margin: 0; color: var(--fh-color-text-muted); }
207
+ .fh-step-progress__bar { height: 4px; border-radius: 999px; background: var(--fh-color-bg-disabled); overflow: hidden; }
208
+ .fh-step-progress__fill { height: 100%; background: var(--fh-color-primary); transition: width 200ms ease-out; }
173
209
 
174
- .fh-form-actions__button--text {
175
- text-decoration: underline;
176
- padding-left: 8px;
177
- padding-right: 8px;
210
+ @media (forced-colors: active) {
211
+ .fh-field__radio, .fh-field__checkbox, .fh-field__switch { appearance: auto; width: 18px; height: 18px; box-shadow: none; }
212
+ .fh-field__checkbox:checked::after, .fh-field__switch::after { content: none; }
213
+ .fh-field__input--select { appearance: auto; background-image: none; }
214
+ :is(.fh-field__radio-option, .fh-field__multiselect-option):has(:checked) { border-color: Highlight; }
215
+ :is(.fh-field__radio-option, .fh-field__multiselect-option):has(:focus-visible), .fh-form-actions__button:focus-visible, .fh-field__input:focus, :is(.fh-field__radio, .fh-field__checkbox, .fh-field__switch):focus-visible { outline: 2px solid CanvasText; }
178
216
  }
179
217
 
180
- .fh-step-progress {
181
- display: flex;
182
- flex-direction: column;
183
- gap: 8px;
184
- }
185
-
186
- .fh-step-progress__info {
187
- display: flex;
188
- flex-direction: column;
189
- gap: 2px;
190
- }
191
-
192
- .fh-step-progress__counter {
193
- color: var(--fh-color-text-muted);
194
- font-size: var(--fh-font-size-small);
195
- }
196
-
197
- .fh-step-progress__title {
198
- font-weight: 600;
199
- }
200
-
201
- .fh-step-progress__description {
202
- color: var(--fh-color-text-muted);
203
- font-size: var(--fh-font-size-small);
204
- }
205
-
206
- .fh-step-progress__bar {
207
- height: 4px;
208
- background: var(--fh-color-bg-disabled);
209
- border-radius: 999px;
210
- overflow: hidden;
211
- }
212
-
213
- .fh-step-progress__fill {
214
- height: 100%;
215
- background: var(--fh-color-primary);
216
- transition: width 200ms ease-out;
217
- }
218
+ .fh-form__notice { display: grid; gap: 8px; justify-items: start; margin-bottom: var(--fh-gap); padding: 12px 14px; border: 1px solid var(--fh-color-error); border-radius: var(--fh-radius); color: var(--fh-color-text); }
219
+ .fh-form__notice--info { border-color: var(--fh-color-border-focus); }
220
+ .fh-form__notice > p, .fh-form__notice > ul { margin: 0; }