dsh-web-fetch-playwright 0.1.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.
@@ -0,0 +1,228 @@
1
+ /* Plugin-configuration fields — the shipped ui-settings-plugins field styles
2
+ (label / badge / input / hint on dsw-alias tokens) plus the radio-group and
3
+ checkbox rows this card adds on the same rhythm. */
4
+
5
+ .field {
6
+ display: flex;
7
+ flex-direction: column;
8
+ gap: 6px;
9
+ padding: 12px 0;
10
+ margin: 0;
11
+ border: 0;
12
+ border-top: 1px solid var(--dsw-alias-border-l2);
13
+ }
14
+
15
+ .field:first-child {
16
+ border-top: 0;
17
+ }
18
+
19
+ /* The same field without card-level chrome: renders inside a radio option,
20
+ so the option box supplies the container and the border. The layout is
21
+ spelled out rather than composed from .field — the build pipeline drops
22
+ CSS Modules `composes`, and a lost flex column would leave the input at
23
+ its intrinsic width instead of stretching to the option box. */
24
+ .fieldEmbedded {
25
+ display: flex;
26
+ flex-direction: column;
27
+ gap: 6px;
28
+ margin: 0;
29
+ padding: 0;
30
+ border: 0;
31
+ border-top: 0;
32
+ }
33
+
34
+ .head {
35
+ display: flex;
36
+ align-items: center;
37
+ gap: 8px;
38
+ }
39
+
40
+ .label {
41
+ flex: 1;
42
+ min-width: 0;
43
+ font-size: 13px;
44
+ font-weight: 500;
45
+ line-height: 1.5;
46
+ color: var(--dsw-alias-label-primary);
47
+ }
48
+
49
+ .badges {
50
+ display: inline-flex;
51
+ align-items: center;
52
+ gap: 8px;
53
+ }
54
+
55
+ .badge {
56
+ border-radius: 999px;
57
+ padding: 1px 8px;
58
+ font-size: 11px;
59
+ line-height: 17px;
60
+ white-space: nowrap;
61
+ font-weight: 500;
62
+ background: var(--dsw-alias-bg-module-platform);
63
+ color: var(--dsw-alias-label-secondary);
64
+ }
65
+
66
+ .reset {
67
+ border: none;
68
+ background: none;
69
+ padding: 0;
70
+ font: inherit;
71
+ font-size: 12px;
72
+ line-height: 1.5;
73
+ color: var(--dsw-alias-label-secondary);
74
+ cursor: pointer;
75
+ }
76
+
77
+ .reset:hover:not(:disabled) {
78
+ color: var(--dsw-alias-label-primary);
79
+ }
80
+
81
+ .reset:disabled {
82
+ cursor: default;
83
+ }
84
+
85
+ .input {
86
+ height: 34px;
87
+ padding: 0 12px;
88
+ border: 1px solid var(--dsw-alias-border-l2);
89
+ border-radius: 8px;
90
+ background: var(--dsw-alias-bg-layer-3);
91
+ font: inherit;
92
+ font-size: 13px;
93
+ line-height: 1.5;
94
+ color: var(--dsw-alias-label-primary);
95
+ }
96
+
97
+ .input:focus-visible {
98
+ outline: none;
99
+ border-color: var(--dsw-alias-brand-primary);
100
+ }
101
+
102
+ .input:disabled {
103
+ color: var(--dsw-alias-label-tertiary);
104
+ cursor: default;
105
+ }
106
+
107
+ /* Invalid input: same shape as .input with the error border. Self-contained
108
+ (no `composes: input`) for the same build-pipeline reason as .fieldEmbedded. */
109
+ .inputInvalid {
110
+ height: 34px;
111
+ padding: 0 12px;
112
+ border: 1px solid var(--dsw-alias-label-error);
113
+ border-radius: 8px;
114
+ background: var(--dsw-alias-bg-layer-3);
115
+ font: inherit;
116
+ font-size: 13px;
117
+ line-height: 1.5;
118
+ color: var(--dsw-alias-label-primary);
119
+ }
120
+
121
+ .invalid {
122
+ margin: 0;
123
+ font-size: 12px;
124
+ line-height: 1.5;
125
+ color: var(--dsw-alias-label-error);
126
+ }
127
+
128
+ .hint {
129
+ margin: 0;
130
+ font-size: 12px;
131
+ line-height: 1.5;
132
+ color: var(--dsw-alias-label-tertiary);
133
+ }
134
+
135
+ /* ── radio group ──────────────────────────────────────────────────────── */
136
+
137
+ .radioGroup {
138
+ display: flex;
139
+ flex-direction: column;
140
+ gap: 8px;
141
+ }
142
+
143
+ /* Option box: the pickable header (radio + label/hint) and, when the option
144
+ carries a nested fill-in field, that field indented under the text column. */
145
+ .radioOption {
146
+ display: flex;
147
+ flex-direction: column;
148
+ gap: 8px;
149
+ padding: 10px 12px;
150
+ border: 1px solid var(--dsw-alias-border-l2);
151
+ border-radius: 8px;
152
+ background: var(--dsw-alias-bg-layer-3);
153
+ }
154
+
155
+ .radioOption:has(input[type='radio']:checked) {
156
+ border-color: var(--dsw-alias-brand-primary);
157
+ }
158
+
159
+ .radioPick {
160
+ display: flex;
161
+ align-items: flex-start;
162
+ gap: 10px;
163
+ cursor: pointer;
164
+ }
165
+
166
+ .radioPick input[type='radio'] {
167
+ flex: none;
168
+ width: 14px;
169
+ height: 14px;
170
+ margin-top: 2px;
171
+ accent-color: var(--dsw-alias-brand-primary);
172
+ }
173
+
174
+ .radioPick input[type='radio']:focus-visible {
175
+ outline: 2px solid var(--dsw-alias-brand-primary);
176
+ outline-offset: 1px;
177
+ }
178
+
179
+ .radioText {
180
+ display: flex;
181
+ flex-direction: column;
182
+ gap: 2px;
183
+ min-width: 0;
184
+ }
185
+
186
+ .radioLabel {
187
+ font-size: 13px;
188
+ font-weight: 500;
189
+ line-height: 1.5;
190
+ color: var(--dsw-alias-label-primary);
191
+ }
192
+
193
+ .radioHint {
194
+ font-size: 12px;
195
+ line-height: 1.5;
196
+ color: var(--dsw-alias-label-tertiary);
197
+ }
198
+
199
+ /* Nested fill-in field, aligned with the label/hint text column (radio
200
+ 14px + 10px gap). */
201
+ .radioContent {
202
+ margin-left: 24px;
203
+ }
204
+
205
+ .radioContent input[type='text']:enabled {
206
+ cursor: text;
207
+ }
208
+
209
+ /* ── checkbox ─────────────────────────────────────────────────────────── */
210
+
211
+ .checkboxRow {
212
+ display: flex;
213
+ align-items: center;
214
+ gap: 10px;
215
+ }
216
+
217
+ .checkboxRow input[type='checkbox'] {
218
+ flex: none;
219
+ width: 16px;
220
+ height: 16px;
221
+ margin: 0;
222
+ accent-color: var(--dsw-alias-brand-primary);
223
+ }
224
+
225
+ .checkboxRow input[type='checkbox']:focus-visible {
226
+ outline: 2px solid var(--dsw-alias-brand-primary);
227
+ outline-offset: 1px;
228
+ }
@@ -0,0 +1,189 @@
1
+ /**
2
+ * The Playwright card's controls: the shipped ValueField (text input with
3
+ * override badge and reset) plus the two this card adds — a two-option radio
4
+ * group for the backend (each option carrying its backend-specific input
5
+ * nested inside) and a checkbox for the denoise toggle — styled on the same
6
+ * tokens and rhythm as the built-in plugin-configuration fields.
7
+ *
8
+ * @module dsh-web-fetch-playwright/client/fields
9
+ */
10
+
11
+ import type { ReactNode } from 'react'
12
+ import css from './fields.module.css'
13
+
14
+ /** A staged text field (copy of the shipped ValueField). */
15
+ export function ValueField(props: {
16
+ id: string
17
+ label: string
18
+ hint: string
19
+ text: string
20
+ overridden: boolean
21
+ invalid: boolean
22
+ overriddenLabel: string
23
+ resetLabel: string
24
+ invalidLabel: string
25
+ disabled: boolean
26
+ placeholder?: string
27
+ /** Render inside a radio option: no card-level chrome (border, padding). */
28
+ embedded?: boolean
29
+ onEdit: (text: string) => void
30
+ onReset: () => void
31
+ }) {
32
+ return (
33
+ <div className={props.embedded ? css.fieldEmbedded : css.field}>
34
+ <div className={css.head}>
35
+ <label className={css.label} htmlFor={props.id}>{props.label}</label>
36
+ {props.overridden
37
+ ? (
38
+ <span className={css.badges}>
39
+ <span className={css.badge}>{props.overriddenLabel}</span>
40
+ <button
41
+ type="button"
42
+ className={css.reset}
43
+ disabled={props.disabled}
44
+ onClick={props.onReset}
45
+ >
46
+ {props.resetLabel}
47
+ </button>
48
+ </span>
49
+ )
50
+ : null}
51
+ </div>
52
+ <input
53
+ id={props.id}
54
+ className={props.invalid ? css.inputInvalid : css.input}
55
+ type="text"
56
+ {...props.invalid ? { 'aria-invalid': true } : {}}
57
+ value={props.text}
58
+ placeholder={props.placeholder ?? ''}
59
+ disabled={props.disabled}
60
+ spellCheck={false}
61
+ onChange={(event) => { props.onEdit(event.target.value) }}
62
+ />
63
+ <p className={props.invalid ? css.invalid : css.hint}>
64
+ {props.invalid ? props.invalidLabel : props.hint}
65
+ </p>
66
+ </div>
67
+ )
68
+ }
69
+
70
+ /** One radio option's copy, staged value, and nested control. */
71
+ export interface RadioOption {
72
+ /** The option's stored value ('local' | 'cdp'). */
73
+ value: string
74
+ /** Option label shown beside the radio. */
75
+ label: string
76
+ /** One-line explanation under the option. */
77
+ hint: string
78
+ /**
79
+ * Optional control rendered inside the option, under the label and hint —
80
+ * used to nest each backend's fill-in input in its own radio option. The
81
+ * option box stays a plain div so the nested field's own label element is
82
+ * valid HTML (a `<label>` may not nest another `<label>`).
83
+ */
84
+ content?: ReactNode
85
+ }
86
+
87
+ /** A staged radio group: the backend selector. */
88
+ export function RadioGroupField(props: {
89
+ label: string
90
+ options: readonly RadioOption[]
91
+ text: string
92
+ overridden: boolean
93
+ overriddenLabel: string
94
+ resetLabel: string
95
+ disabled: boolean
96
+ onEdit: (text: string) => void
97
+ onReset: () => void
98
+ }) {
99
+ return (
100
+ <fieldset className={css.field}>
101
+ <div className={css.head}>
102
+ <span className={css.label}>{props.label}</span>
103
+ {props.overridden
104
+ ? (
105
+ <span className={css.badges}>
106
+ <span className={css.badge}>{props.overriddenLabel}</span>
107
+ <button
108
+ type="button"
109
+ className={css.reset}
110
+ disabled={props.disabled}
111
+ onClick={props.onReset}
112
+ >
113
+ {props.resetLabel}
114
+ </button>
115
+ </span>
116
+ )
117
+ : null}
118
+ </div>
119
+ <div className={css.radioGroup} role="radiogroup" aria-label={props.label}>
120
+ {props.options.map(option => (
121
+ <div key={option.value} className={css.radioOption}>
122
+ <label className={css.radioPick}>
123
+ <input
124
+ type="radio"
125
+ name="playwright-backend"
126
+ value={option.value}
127
+ checked={props.text === option.value}
128
+ disabled={props.disabled}
129
+ onChange={() => { props.onEdit(option.value) }}
130
+ />
131
+ <span className={css.radioText}>
132
+ <span className={css.radioLabel}>{option.label}</span>
133
+ <span className={css.radioHint}>{option.hint}</span>
134
+ </span>
135
+ </label>
136
+ {option.content === undefined
137
+ ? null
138
+ : <div className={css.radioContent}>{option.content}</div>}
139
+ </div>
140
+ ))}
141
+ </div>
142
+ </fieldset>
143
+ )
144
+ }
145
+
146
+ /** A staged checkbox: the denoise toggle. An absent stored value defaults to on. */
147
+ export function CheckboxField(props: {
148
+ id: string
149
+ label: string
150
+ hint: string
151
+ checked: boolean
152
+ overridden: boolean
153
+ overriddenLabel: string
154
+ resetLabel: string
155
+ disabled: boolean
156
+ onEdit: (text: string) => void
157
+ onReset: () => void
158
+ }) {
159
+ return (
160
+ <div className={css.field}>
161
+ <div className={css.checkboxRow}>
162
+ <input
163
+ id={props.id}
164
+ type="checkbox"
165
+ checked={props.checked}
166
+ disabled={props.disabled}
167
+ onChange={(event) => { props.onEdit(event.target.checked ? 'true' : 'false') }}
168
+ />
169
+ <label className={css.label} htmlFor={props.id}>{props.label}</label>
170
+ {props.overridden
171
+ ? (
172
+ <span className={css.badges}>
173
+ <span className={css.badge}>{props.overriddenLabel}</span>
174
+ <button
175
+ type="button"
176
+ className={css.reset}
177
+ disabled={props.disabled}
178
+ onClick={props.onReset}
179
+ >
180
+ {props.resetLabel}
181
+ </button>
182
+ </span>
183
+ )
184
+ : null}
185
+ </div>
186
+ <p className={css.hint}>{props.hint}</p>
187
+ </div>
188
+ )
189
+ }