@stacksjs/components 0.2.865 → 0.2.868

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 (116) hide show
  1. package/dist/AppearancePicker-61r20jpp.stx +351 -0
  2. package/dist/{Button-sebyqeva.stx → Button-pg8mzsq3.stx} +249 -0
  3. package/dist/Checkbox-52mhrzkz.stx +417 -0
  4. package/dist/ColorSwatches-ecfxphjy.stx +287 -0
  5. package/dist/{NumberInput-axcfj9y8.stx → NumberInput-e2afxyh3.stx} +303 -0
  6. package/dist/{PasswordInput-8m3109tp.stx → PasswordInput-n2ven456.stx} +315 -0
  7. package/dist/RadioGroup-ps9kn22f.stx +329 -0
  8. package/dist/RadioGroupOption-6hyy1bvb.stx +246 -0
  9. package/dist/{SegmentedControl-fr69q4gb.stx → SegmentedControl-7q0t8c9s.stx} +170 -1
  10. package/dist/{Select-1cnqbcmg.stx → Select-ygzchedx.stx} +266 -0
  11. package/dist/SettingsGroup-dkae46k5.stx +200 -0
  12. package/dist/SettingsPane-jbd1gbdt.stx +50 -0
  13. package/dist/SettingsPaneHeader-f0cvkqs7.stx +188 -0
  14. package/dist/SettingsRow-4cxbsf1q.stx +424 -0
  15. package/dist/SettingsSidebarGroup-p2ygv5yy.stx +108 -0
  16. package/dist/SettingsSidebarItem-x8fsn3w5.stx +228 -0
  17. package/dist/SettingsWindow-mm490ymt.stx +537 -0
  18. package/dist/Slider-j59dgw1c.stx +377 -0
  19. package/dist/Switch-ga9ap8n8.stx +374 -0
  20. package/dist/{TextInput-tsvfwxmg.stx → TextInput-tyqzz3jy.stx} +325 -0
  21. package/dist/index.d.ts +6 -0
  22. package/dist/index.js +35 -24
  23. package/dist/preview-frame/preview-frame.js +58 -2
  24. package/dist/settings/settings.js +757 -0
  25. package/dist/ui/appearance-picker/AppearancePicker.d.ts +12 -0
  26. package/dist/ui/appearance-picker/index.d.ts +16 -0
  27. package/dist/ui/button/Button.d.ts +24 -1
  28. package/dist/ui/button/index.d.ts +1 -0
  29. package/dist/ui/checkbox/Checkbox.d.ts +9 -1
  30. package/dist/ui/checkbox/index.d.ts +1 -0
  31. package/dist/ui/color-swatches/ColorSwatches.d.ts +26 -0
  32. package/dist/ui/color-swatches/index.d.ts +18 -0
  33. package/dist/ui/input/NumberInput.d.ts +11 -1
  34. package/dist/ui/input/PasswordInput.d.ts +9 -1
  35. package/dist/ui/input/TextInput.d.ts +12 -1
  36. package/dist/ui/input/index.d.ts +7 -3
  37. package/dist/ui/preview-frame/core.d.ts +22 -0
  38. package/dist/ui/preview-frame/view.d.ts +9 -0
  39. package/dist/ui/radio-group/RadioGroup.d.ts +14 -2
  40. package/dist/ui/radio-group/RadioGroupOption.d.ts +6 -1
  41. package/dist/ui/radio-group/index.d.ts +2 -0
  42. package/dist/ui/segmented-control/SegmentedControl.d.ts +9 -1
  43. package/dist/ui/segmented-control/index.d.ts +1 -0
  44. package/dist/ui/select/Select.d.ts +10 -1
  45. package/dist/ui/select/index.d.ts +1 -0
  46. package/dist/ui/settings/SettingsGroup.d.ts +30 -0
  47. package/dist/ui/settings/SettingsPane.d.ts +19 -0
  48. package/dist/ui/settings/SettingsPaneHeader.d.ts +20 -0
  49. package/dist/ui/settings/SettingsRow.d.ts +53 -0
  50. package/dist/ui/settings/SettingsSidebarGroup.d.ts +11 -0
  51. package/dist/ui/settings/SettingsSidebarItem.d.ts +22 -0
  52. package/dist/ui/settings/SettingsWindow.d.ts +22 -0
  53. package/dist/ui/settings/core.d.ts +146 -0
  54. package/dist/ui/settings/index.d.ts +73 -0
  55. package/dist/ui/settings/settings.d.ts +8 -0
  56. package/dist/ui/settings/view.d.ts +36 -0
  57. package/dist/ui/slider/Slider.d.ts +24 -0
  58. package/dist/ui/slider/core.d.ts +33 -0
  59. package/dist/ui/slider/index.d.ts +20 -0
  60. package/dist/ui/switch/Switch.d.ts +10 -1
  61. package/dist/ui/switch/index.d.ts +2 -1
  62. package/dist/utils/mac-theme.d.ts +24 -0
  63. package/package.json +8 -3
  64. package/src/index.ts +6 -0
  65. package/src/ui/appearance-picker/AppearancePicker.stx +351 -0
  66. package/src/ui/appearance-picker/README.md +61 -0
  67. package/src/ui/appearance-picker/index.ts +22 -0
  68. package/src/ui/button/Button.stx +249 -0
  69. package/src/ui/button/README.md +21 -0
  70. package/src/ui/button/index.ts +8 -0
  71. package/src/ui/checkbox/Checkbox.stx +275 -0
  72. package/src/ui/checkbox/index.ts +2 -0
  73. package/src/ui/color-swatches/ColorSwatches.stx +287 -0
  74. package/src/ui/color-swatches/README.md +66 -0
  75. package/src/ui/color-swatches/index.ts +25 -0
  76. package/src/ui/input/NumberInput.stx +303 -0
  77. package/src/ui/input/PasswordInput.stx +315 -0
  78. package/src/ui/input/TextInput.stx +325 -0
  79. package/src/ui/input/index.ts +9 -3
  80. package/src/ui/preview-frame/README.md +16 -14
  81. package/src/ui/preview-frame/core.ts +50 -0
  82. package/src/ui/preview-frame/index.ts +4 -4
  83. package/src/ui/preview-frame/view.ts +61 -4
  84. package/src/ui/radio-group/README.md +17 -0
  85. package/src/ui/radio-group/RadioGroup.stx +184 -6
  86. package/src/ui/radio-group/RadioGroupOption.stx +178 -2
  87. package/src/ui/radio-group/index.ts +4 -0
  88. package/src/ui/segmented-control/SegmentedControl.stx +170 -1
  89. package/src/ui/segmented-control/index.ts +2 -0
  90. package/src/ui/select/README.md +12 -0
  91. package/src/ui/select/Select.stx +266 -0
  92. package/src/ui/select/index.ts +2 -0
  93. package/src/ui/settings/README.md +221 -0
  94. package/src/ui/settings/SettingsGroup.stx +200 -0
  95. package/src/ui/settings/SettingsPane.stx +50 -0
  96. package/src/ui/settings/SettingsPaneHeader.stx +188 -0
  97. package/src/ui/settings/SettingsRow.stx +424 -0
  98. package/src/ui/settings/SettingsSidebarGroup.stx +108 -0
  99. package/src/ui/settings/SettingsSidebarItem.stx +228 -0
  100. package/src/ui/settings/SettingsWindow.stx +537 -0
  101. package/src/ui/settings/core.ts +359 -0
  102. package/src/ui/settings/index.ts +111 -0
  103. package/src/ui/settings/settings.ts +8 -0
  104. package/src/ui/settings/view.ts +740 -0
  105. package/src/ui/slider/README.md +91 -0
  106. package/src/ui/slider/Slider.stx +377 -0
  107. package/src/ui/slider/core.ts +120 -0
  108. package/src/ui/slider/index.ts +34 -0
  109. package/src/ui/switch/README.md +11 -0
  110. package/src/ui/switch/Switch.stx +217 -0
  111. package/src/ui/switch/index.ts +4 -1
  112. package/src/utils/mac-theme.ts +95 -0
  113. package/dist/Checkbox-80myyzzm.stx +0 -142
  114. package/dist/RadioGroup-smqcqgds.stx +0 -151
  115. package/dist/RadioGroupOption-twcw1b2a.stx +0 -70
  116. package/dist/Switch-s8yf2rvm.stx +0 -157
@@ -28,6 +28,14 @@ export const required = $bool($props.required)
28
28
  export const showStrength = $bool($props.showStrength)
29
29
  export const className = $props.className || ''
30
30
  export const inputClassName = $props.inputClassName || ''
31
+ /*
32
+ * `variant="mac"` draws the secure field a Mac draws: TextInput's Mac field
33
+ * (24px, 6px corners, a raised face inside a hairline) with the reveal button
34
+ * inside its trailing edge. Same <input>, same attributes and events; only
35
+ * the classes change, to `stx-mac-field`, which this file's <style> block
36
+ * draws from the `--stx-mac-*` tokens. `size` is not read.
37
+ */
38
+ export const mac = $props.variant === 'mac'
31
39
 
32
40
  /*
33
41
  * Padding decides the height here too, with no `h-*` to override it: an app
@@ -141,6 +149,8 @@ const strengthLabelColor = derived(() => {
141
149
  })
142
150
  const inputType = derived(() => showPassword() ? 'text' : 'password')
143
151
  const toggleAriaLabel = derived(() => showPassword() ? 'Hide password' : 'Show password')
152
+ // The Mac look colours its strength bar from this word rather than a class.
153
+ const strengthLevel = derived(() => strengthText().toLowerCase())
144
154
 
145
155
  defineExpose({ value: inputValue })
146
156
  </script>
@@ -197,6 +207,68 @@ defineExpose({ value: inputValue })
197
207
  <p id="{{ helperId }}" class="{{ nativeHelperClasses }}">{{ helperText }}</p>
198
208
  @endif
199
209
  </div>
210
+ @elseif(mac)
211
+ <div class="stx-mac-field-wrap {{ className }}">
212
+ @if(label)
213
+ <label for="{{ inputId }}" class="stx-mac-field-label" @if(error)data-error="true"@endif>
214
+ {{ label }}
215
+ @if(required)
216
+ <span class="stx-mac-field-required">*</span>
217
+ @endif
218
+ </label>
219
+ @endif
220
+
221
+ <div class="stx-mac-field-box">
222
+ <input
223
+ @if(name)name="{{ name }}"@endif
224
+ @if(autocomplete)autocomplete="{{ autocomplete }}"@endif
225
+ @if(form)form="{{ form }}"@endif
226
+ @if(inputMode)inputmode="{{ inputMode }}"@endif
227
+ @if(enterKeyHint)enterkeyhint="{{ enterKeyHint }}"@endif
228
+ :type="inputType()"
229
+ id="{{ inputId }}"
230
+ class="stx-mac-field stx-mac-field-secure {{ inputClassName }}"
231
+ value="{{ value }}"
232
+ :value="inputValue()"
233
+ placeholder="{{ placeholder }}"
234
+ :placeholder="String(placeholderText() ?? '')"
235
+ @if(disabled)disabled@endif
236
+ @if(readonly)readonly@endif
237
+ @if(required)required@endif
238
+ @input="onInput($event)"
239
+ :aria-invalid="{{ error ? 'true' : 'false' }}"
240
+ @if(helperText)aria-describedby="{{ helperId }}"@endif
241
+ />
242
+
243
+ <button
244
+ type="button"
245
+ @click="toggleVisibility()"
246
+ class="stx-mac-field-reveal"
247
+ :aria-label="toggleAriaLabel()"
248
+ >
249
+ <i :show="showPassword()" class="i-f7-eye-slash stx-mac-field-glyph"></i>
250
+ <i :show="!showPassword()" class="i-f7-eye stx-mac-field-glyph"></i>
251
+ </button>
252
+ </div>
253
+
254
+ @if(showStrength)
255
+ <div :show="inputValue().length > 0" class="stx-mac-field-strength" :data-level="strengthLevel()">
256
+ <div class="stx-mac-field-strength-head">
257
+ <span>Password strength</span>
258
+ <span class="stx-mac-field-strength-word" x-text="strengthText()"></span>
259
+ </div>
260
+ <div class="stx-mac-field-strength-track">
261
+ <div class="stx-mac-field-strength-bar" :style="`width: ${strength()}%`"></div>
262
+ </div>
263
+ </div>
264
+ @endif
265
+
266
+ @if(helperText)
267
+ <p id="{{ helperId }}" class="stx-mac-field-helper" @if(error)data-error="true"@endif>
268
+ {{ helperText }}
269
+ </p>
270
+ @endif
271
+ </div>
200
272
  @else
201
273
  <div class="w-full {{ className }}">
202
274
  @if(label)
@@ -282,3 +354,246 @@ defineExpose({ value: inputValue })
282
354
  @endif
283
355
  </div>
284
356
  @endif
357
+
358
+ <style data-native-exclude>
359
+ :where(:root) {
360
+ --stx-mac-font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI Variable Text', 'Segoe UI', system-ui, Roboto, 'Helvetica Neue', sans-serif;
361
+ --stx-mac-font-size: 13px;
362
+ --stx-mac-font-size-small: 11px;
363
+ --stx-mac-hairline: 0.5px;
364
+ --stx-mac-focus-ring: 0 0 0 3px color-mix(in srgb, var(--stx-mac-accent) 35%, transparent);
365
+ --stx-mac-card-radius: 12px;
366
+ --stx-mac-control-radius: 6px;
367
+ --stx-mac-row-height: 38px;
368
+ --stx-mac-row-inset: 10px;
369
+ --stx-mac-sidebar-width: 226px;
370
+ --stx-mac-accent: var(--stx-accent, rgb(0, 122, 255));
371
+ --stx-mac-accent-ink: #ffffff;
372
+ --stx-mac-ink: rgba(0, 0, 0, 0.85);
373
+ --stx-mac-ink-secondary: rgba(0, 0, 0, 0.5);
374
+ --stx-mac-ink-tertiary: rgba(0, 0, 0, 0.26);
375
+ --stx-mac-window: #ffffff;
376
+ --stx-mac-sidebar: #f2f1f0;
377
+ --stx-mac-card: rgba(0, 0, 0, 0.04);
378
+ --stx-mac-separator: rgba(0, 0, 0, 0.1);
379
+ --stx-mac-hover: rgba(0, 0, 0, 0.05);
380
+ --stx-mac-selection-inactive: rgba(0, 0, 0, 0.08);
381
+ --stx-mac-well: rgba(0, 0, 0, 0.07);
382
+ --stx-mac-control: #ffffff;
383
+ --stx-mac-control-line: rgba(0, 0, 0, 0.12);
384
+ --stx-mac-control-shadow: 0 0.5px 1.5px rgba(0, 0, 0, 0.14), 0 0 0 0.5px rgba(0, 0, 0, 0.08);
385
+ --stx-mac-switch-on: #34c759;
386
+ --stx-mac-knob: #ffffff;
387
+ --stx-mac-danger: #ff3b30;
388
+ }
389
+ :where(.dark) {
390
+ --stx-mac-accent: var(--stx-accent, #0a84ff);
391
+ --stx-mac-accent-ink: #ffffff;
392
+ --stx-mac-ink: rgba(255, 255, 255, 0.85);
393
+ --stx-mac-ink-secondary: rgba(255, 255, 255, 0.55);
394
+ --stx-mac-ink-tertiary: rgba(255, 255, 255, 0.25);
395
+ --stx-mac-window: #1e1e1e;
396
+ --stx-mac-sidebar: #2a2a2a;
397
+ --stx-mac-card: rgba(255, 255, 255, 0.05);
398
+ --stx-mac-separator: rgba(255, 255, 255, 0.1);
399
+ --stx-mac-hover: rgba(255, 255, 255, 0.06);
400
+ --stx-mac-selection-inactive: rgba(255, 255, 255, 0.1);
401
+ --stx-mac-well: rgba(255, 255, 255, 0.1);
402
+ --stx-mac-control: rgba(255, 255, 255, 0.14);
403
+ --stx-mac-control-line: rgba(255, 255, 255, 0.06);
404
+ --stx-mac-control-shadow: 0 0.5px 1.5px rgba(0, 0, 0, 0.4), inset 0 0.5px 0 rgba(255, 255, 255, 0.12);
405
+ --stx-mac-switch-on: #30d158;
406
+ --stx-mac-knob: #ffffff;
407
+ --stx-mac-danger: #ff453a;
408
+ }
409
+ @media (max-resolution: 1.5dppx) {
410
+ :where(:root) {
411
+ --stx-mac-hairline: 1px;
412
+ }
413
+ }
414
+ @media (prefers-contrast: more) {
415
+ :where(:root) {
416
+ --stx-mac-separator: rgba(0, 0, 0, 0.4);
417
+ --stx-mac-control-line: rgba(0, 0, 0, 0.5);
418
+ --stx-mac-ink-secondary: rgba(0, 0, 0, 0.75);
419
+ --stx-mac-hairline: 1px;
420
+ }
421
+ :where(.dark) {
422
+ --stx-mac-separator: rgba(255, 255, 255, 0.45);
423
+ --stx-mac-control-line: rgba(255, 255, 255, 0.5);
424
+ --stx-mac-ink-secondary: rgba(255, 255, 255, 0.8);
425
+ }
426
+ }
427
+
428
+ .stx-mac-field-wrap {
429
+ display: block;
430
+ width: var(--stx-mac-field-width, 100%);
431
+ max-width: 100%;
432
+ font-family: var(--stx-mac-font);
433
+ font-size: var(--stx-mac-font-size);
434
+ letter-spacing: -0.08px;
435
+ -webkit-font-smoothing: antialiased;
436
+ color: var(--stx-mac-ink);
437
+ cursor: default;
438
+ }
439
+
440
+ .stx-mac-field-label {
441
+ display: block;
442
+ margin-bottom: 4px;
443
+ line-height: 16px;
444
+ -webkit-user-select: none;
445
+ user-select: none;
446
+ }
447
+
448
+ .stx-mac-field-label[data-error='true'],
449
+ .stx-mac-field-required,
450
+ .stx-mac-field-helper[data-error='true'] {
451
+ color: var(--stx-mac-danger);
452
+ }
453
+
454
+ .stx-mac-field-box {
455
+ position: relative;
456
+ display: flex;
457
+ align-items: center;
458
+ }
459
+
460
+ .stx-mac-field {
461
+ --stx-mac-field-line: inset 0 0 0 var(--stx-mac-hairline) var(--stx-mac-control-line);
462
+ display: block;
463
+ flex: 1 1 auto;
464
+ box-sizing: border-box;
465
+ width: 100%;
466
+ min-width: 0;
467
+ height: 24px;
468
+ margin: 0;
469
+ padding: 0 7px;
470
+ border: 0;
471
+ border-radius: var(--stx-mac-control-radius);
472
+ background: var(--stx-mac-control);
473
+ box-shadow: var(--stx-mac-field-line);
474
+ color: var(--stx-mac-ink);
475
+ font: inherit;
476
+ letter-spacing: inherit;
477
+ -webkit-appearance: none;
478
+ appearance: none;
479
+ outline: none;
480
+ transition: box-shadow 150ms ease;
481
+ }
482
+
483
+ .stx-mac-field::placeholder {
484
+ color: var(--stx-mac-ink-tertiary);
485
+ }
486
+
487
+ .stx-mac-field:focus-visible {
488
+ box-shadow: var(--stx-mac-field-line), var(--stx-mac-focus-ring);
489
+ }
490
+
491
+ .stx-mac-field[aria-invalid='true'] {
492
+ --stx-mac-field-line: inset 0 0 0 1px var(--stx-mac-danger);
493
+ }
494
+
495
+ .stx-mac-field:disabled {
496
+ opacity: 0.5;
497
+ }
498
+
499
+ .stx-mac-field-helper {
500
+ margin: 4px 0 0;
501
+ font-size: var(--stx-mac-font-size-small);
502
+ line-height: 14px;
503
+ letter-spacing: 0;
504
+ color: var(--stx-mac-ink-secondary);
505
+ }
506
+
507
+ @media (prefers-reduced-motion: reduce) {
508
+ .stx-mac-field {
509
+ transition: none;
510
+ }
511
+ }
512
+
513
+ /* Two classes, so these win over the plain field's rules whichever component's stylesheet the page loads last. */
514
+ .stx-mac-field.stx-mac-field-secure {
515
+ padding-right: 26px;
516
+ }
517
+
518
+ .stx-mac-field-reveal {
519
+ position: absolute;
520
+ top: 3px;
521
+ right: 4px;
522
+ display: inline-flex;
523
+ align-items: center;
524
+ justify-content: center;
525
+ width: 18px;
526
+ height: 18px;
527
+ margin: 0;
528
+ padding: 0;
529
+ border: 0;
530
+ border-radius: 5px;
531
+ background: transparent;
532
+ color: var(--stx-mac-ink-secondary);
533
+ -webkit-appearance: none;
534
+ appearance: none;
535
+ cursor: default;
536
+ outline: none;
537
+ }
538
+
539
+ .stx-mac-field-reveal:hover {
540
+ color: var(--stx-mac-ink);
541
+ }
542
+
543
+ .stx-mac-field-reveal:focus-visible {
544
+ box-shadow: var(--stx-mac-focus-ring);
545
+ }
546
+
547
+ .stx-mac-field-glyph {
548
+ width: 13px;
549
+ height: 13px;
550
+ }
551
+
552
+ .stx-mac-field-strength {
553
+ --stx-mac-field-strength: var(--stx-mac-danger);
554
+ margin-top: 6px;
555
+ font-size: var(--stx-mac-font-size-small);
556
+ letter-spacing: 0;
557
+ color: var(--stx-mac-ink-secondary);
558
+ -webkit-user-select: none;
559
+ user-select: none;
560
+ }
561
+
562
+ .stx-mac-field-strength[data-level='medium'] {
563
+ --stx-mac-field-strength: #ff9500;
564
+ }
565
+
566
+ .stx-mac-field-strength[data-level='strong'] {
567
+ --stx-mac-field-strength: var(--stx-mac-switch-on);
568
+ }
569
+
570
+ .stx-mac-field-strength-head {
571
+ display: flex;
572
+ justify-content: space-between;
573
+ margin-bottom: 3px;
574
+ }
575
+
576
+ .stx-mac-field-strength-word {
577
+ color: var(--stx-mac-field-strength);
578
+ }
579
+
580
+ .stx-mac-field-strength-track {
581
+ height: 4px;
582
+ overflow: hidden;
583
+ border-radius: 2px;
584
+ background: var(--stx-mac-well);
585
+ }
586
+
587
+ .stx-mac-field-strength-bar {
588
+ height: 100%;
589
+ border-radius: 2px;
590
+ background: var(--stx-mac-field-strength);
591
+ transition: width 150ms ease;
592
+ }
593
+
594
+ @media (prefers-reduced-motion: reduce) {
595
+ .stx-mac-field-strength-bar {
596
+ transition: none;
597
+ }
598
+ }
599
+ </style>
@@ -15,6 +15,17 @@ export const maxLength = $props.maxLength ?? $props.maxlength
15
15
  export const showCount = $bool($props.showCount)
16
16
  export const className = $props.className || ''
17
17
  export const inputClassName = $props.inputClassName || ''
18
+ /*
19
+ * `variant="mac"` draws the text field a Mac draws: 24px tall with 6px
20
+ * corners, a raised face inside a hairline, 13px text, and the accent's ring
21
+ * while it has the keyboard. It is the same <input> with the same attributes
22
+ * and events; only the classes change, to `stx-mac-field`, which this file's
23
+ * <style> block draws from the `--stx-mac-*` tokens. It has one size, so
24
+ * `size` is not read, and it is as wide as `--stx-mac-field-width` (the
25
+ * whole of its container when that is unset).
26
+ */
27
+ export const mac = $props.variant === 'mac'
28
+ export const macFieldClasses = `stx-mac-field ${leftIcon ? 'stx-mac-field-leading' : ''} ${rightIcon || clearable ? 'stx-mac-field-trailing' : ''} ${inputClassName}`.replace(/\s+/g, ' ').trim()
18
29
 
19
30
  /*
20
31
  * Padding decides the height here too, with no `h-*` to override it: an app
@@ -319,6 +330,89 @@ defineExpose({ value: inputValue, clear: onClear })
319
330
  <p class="mt-1.5 px-4 text-right text-[13px] text-[#6d6d72] dark:text-[#8d8d93]" :text="charCount()"></p>
320
331
  @endif
321
332
  </div>
333
+ @elseif(mac)
334
+ <div class="stx-mac-field-wrap {{ className }}">
335
+ @if(label)
336
+ <label for="{{ inputId }}" class="stx-mac-field-label" @if(error)data-error="true"@endif>
337
+ {{ label }}
338
+ @if(required)
339
+ <span class="stx-mac-field-required">*</span>
340
+ @endif
341
+ </label>
342
+ @endif
343
+
344
+ <div class="stx-mac-field-box">
345
+ @if(leftIcon)
346
+ <span class="stx-mac-field-icon stx-mac-field-icon-leading" aria-hidden="true">{!! leftIcon !!}</span>
347
+ @endif
348
+
349
+ <input
350
+ data-stx-native-host-root
351
+ @if(name)name="{{ name }}"@endif
352
+ @if(autocomplete)autocomplete="{{ autocomplete }}"@endif
353
+ @if(form)form="{{ form }}"@endif
354
+ @if(inputMode)inputmode="{{ inputMode }}"@endif
355
+ @if(enterKeyHint)enterkeyhint="{{ enterKeyHint }}"@endif
356
+ type="{{ type }}"
357
+ @if(min)min="{{ min }}"@endif
358
+ @if(max)max="{{ max }}"@endif
359
+ @if(step)step="{{ step }}"@endif
360
+ @if(pattern)pattern="{{ pattern }}"@endif
361
+ @if(minLength)minlength="{{ minLength }}"@endif
362
+ @if(htmlSize)size="{{ htmlSize }}"@endif
363
+ @if(list)list="{{ list }}"@endif
364
+ @if(autofocus)autofocus@endif
365
+ id="{{ inputId }}"
366
+ class="{{ macFieldClasses }}"
367
+ value="{{ value }}"
368
+ :value="inputValue()"
369
+ placeholder="{{ placeholder }}"
370
+ :placeholder="String(placeholderText() ?? '')"
371
+ @if(disabled)disabled@endif
372
+ :disabled="isDisabled()"
373
+ @if(readonly)readonly@endif
374
+ :readonly="isReadonly()"
375
+ @if(required)required@endif
376
+ @if(maxLength && freeText)maxlength="{{ maxLength }}"@endif
377
+ @input="onInput($event)"
378
+ @change="onChange($event)"
379
+ @focus="onFocus($event)"
380
+ @blur="onBlur($event)"
381
+ aria-invalid="{{ error ? 'true' : 'false' }}"
382
+ :aria-invalid="isError() ? 'true' : 'false'"
383
+ @if(helperText)aria-describedby="{{ helperId }}"@endif
384
+ />
385
+
386
+ @if(clearable)
387
+ <button
388
+ type="button"
389
+ :show="hasValue() && !isDisabled() && !isReadonly()"
390
+ @click="onClear()"
391
+ class="stx-mac-field-clear"
392
+ aria-label="Clear input"
393
+ ></button>
394
+ @endif
395
+ @if(rightIcon && !clearable)
396
+ <span class="stx-mac-field-icon stx-mac-field-icon-trailing" aria-hidden="true">{!! rightIcon !!}</span>
397
+ @endif
398
+ </div>
399
+
400
+ @if(helperText || (showCount && maxLength))
401
+ <div class="stx-mac-field-foot">
402
+ @if(helperText)
403
+ <p id="{{ helperId }}" class="stx-mac-field-helper" @if(error)data-error="true"@endif>
404
+ {{ helperText }}
405
+ </p>
406
+ @else
407
+ <span></span>
408
+ @endif
409
+
410
+ @if(showCount && maxLength)
411
+ <p class="stx-mac-field-helper" x-text="charCount()"></p>
412
+ @endif
413
+ </div>
414
+ @endif
415
+ </div>
322
416
  @else
323
417
  <div class="w-full {{ className }}">
324
418
  @if(label)
@@ -424,3 +518,234 @@ defineExpose({ value: inputValue, clear: onClear })
424
518
  @endif
425
519
  </div>
426
520
  @endif
521
+
522
+ <style data-native-exclude>
523
+ :where(:root) {
524
+ --stx-mac-font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI Variable Text', 'Segoe UI', system-ui, Roboto, 'Helvetica Neue', sans-serif;
525
+ --stx-mac-font-size: 13px;
526
+ --stx-mac-font-size-small: 11px;
527
+ --stx-mac-hairline: 0.5px;
528
+ --stx-mac-focus-ring: 0 0 0 3px color-mix(in srgb, var(--stx-mac-accent) 35%, transparent);
529
+ --stx-mac-card-radius: 12px;
530
+ --stx-mac-control-radius: 6px;
531
+ --stx-mac-row-height: 38px;
532
+ --stx-mac-row-inset: 10px;
533
+ --stx-mac-sidebar-width: 226px;
534
+ --stx-mac-accent: var(--stx-accent, rgb(0, 122, 255));
535
+ --stx-mac-accent-ink: #ffffff;
536
+ --stx-mac-ink: rgba(0, 0, 0, 0.85);
537
+ --stx-mac-ink-secondary: rgba(0, 0, 0, 0.5);
538
+ --stx-mac-ink-tertiary: rgba(0, 0, 0, 0.26);
539
+ --stx-mac-window: #ffffff;
540
+ --stx-mac-sidebar: #f2f1f0;
541
+ --stx-mac-card: rgba(0, 0, 0, 0.04);
542
+ --stx-mac-separator: rgba(0, 0, 0, 0.1);
543
+ --stx-mac-hover: rgba(0, 0, 0, 0.05);
544
+ --stx-mac-selection-inactive: rgba(0, 0, 0, 0.08);
545
+ --stx-mac-well: rgba(0, 0, 0, 0.07);
546
+ --stx-mac-control: #ffffff;
547
+ --stx-mac-control-line: rgba(0, 0, 0, 0.12);
548
+ --stx-mac-control-shadow: 0 0.5px 1.5px rgba(0, 0, 0, 0.14), 0 0 0 0.5px rgba(0, 0, 0, 0.08);
549
+ --stx-mac-switch-on: #34c759;
550
+ --stx-mac-knob: #ffffff;
551
+ --stx-mac-danger: #ff3b30;
552
+ }
553
+ :where(.dark) {
554
+ --stx-mac-accent: var(--stx-accent, #0a84ff);
555
+ --stx-mac-accent-ink: #ffffff;
556
+ --stx-mac-ink: rgba(255, 255, 255, 0.85);
557
+ --stx-mac-ink-secondary: rgba(255, 255, 255, 0.55);
558
+ --stx-mac-ink-tertiary: rgba(255, 255, 255, 0.25);
559
+ --stx-mac-window: #1e1e1e;
560
+ --stx-mac-sidebar: #2a2a2a;
561
+ --stx-mac-card: rgba(255, 255, 255, 0.05);
562
+ --stx-mac-separator: rgba(255, 255, 255, 0.1);
563
+ --stx-mac-hover: rgba(255, 255, 255, 0.06);
564
+ --stx-mac-selection-inactive: rgba(255, 255, 255, 0.1);
565
+ --stx-mac-well: rgba(255, 255, 255, 0.1);
566
+ --stx-mac-control: rgba(255, 255, 255, 0.14);
567
+ --stx-mac-control-line: rgba(255, 255, 255, 0.06);
568
+ --stx-mac-control-shadow: 0 0.5px 1.5px rgba(0, 0, 0, 0.4), inset 0 0.5px 0 rgba(255, 255, 255, 0.12);
569
+ --stx-mac-switch-on: #30d158;
570
+ --stx-mac-knob: #ffffff;
571
+ --stx-mac-danger: #ff453a;
572
+ }
573
+ @media (max-resolution: 1.5dppx) {
574
+ :where(:root) {
575
+ --stx-mac-hairline: 1px;
576
+ }
577
+ }
578
+ @media (prefers-contrast: more) {
579
+ :where(:root) {
580
+ --stx-mac-separator: rgba(0, 0, 0, 0.4);
581
+ --stx-mac-control-line: rgba(0, 0, 0, 0.5);
582
+ --stx-mac-ink-secondary: rgba(0, 0, 0, 0.75);
583
+ --stx-mac-hairline: 1px;
584
+ }
585
+ :where(.dark) {
586
+ --stx-mac-separator: rgba(255, 255, 255, 0.45);
587
+ --stx-mac-control-line: rgba(255, 255, 255, 0.5);
588
+ --stx-mac-ink-secondary: rgba(255, 255, 255, 0.8);
589
+ }
590
+ }
591
+
592
+ .stx-mac-field-wrap {
593
+ display: block;
594
+ width: var(--stx-mac-field-width, 100%);
595
+ max-width: 100%;
596
+ font-family: var(--stx-mac-font);
597
+ font-size: var(--stx-mac-font-size);
598
+ letter-spacing: -0.08px;
599
+ -webkit-font-smoothing: antialiased;
600
+ color: var(--stx-mac-ink);
601
+ cursor: default;
602
+ }
603
+
604
+ .stx-mac-field-label {
605
+ display: block;
606
+ margin-bottom: 4px;
607
+ line-height: 16px;
608
+ -webkit-user-select: none;
609
+ user-select: none;
610
+ }
611
+
612
+ .stx-mac-field-label[data-error='true'],
613
+ .stx-mac-field-required,
614
+ .stx-mac-field-helper[data-error='true'] {
615
+ color: var(--stx-mac-danger);
616
+ }
617
+
618
+ .stx-mac-field-box {
619
+ position: relative;
620
+ display: flex;
621
+ align-items: center;
622
+ }
623
+
624
+ .stx-mac-field {
625
+ --stx-mac-field-line: inset 0 0 0 var(--stx-mac-hairline) var(--stx-mac-control-line);
626
+ display: block;
627
+ flex: 1 1 auto;
628
+ box-sizing: border-box;
629
+ width: 100%;
630
+ min-width: 0;
631
+ height: 24px;
632
+ margin: 0;
633
+ padding: 0 7px;
634
+ border: 0;
635
+ border-radius: var(--stx-mac-control-radius);
636
+ background: var(--stx-mac-control);
637
+ box-shadow: var(--stx-mac-field-line);
638
+ color: var(--stx-mac-ink);
639
+ font: inherit;
640
+ letter-spacing: inherit;
641
+ -webkit-appearance: none;
642
+ appearance: none;
643
+ outline: none;
644
+ transition: box-shadow 150ms ease;
645
+ }
646
+
647
+ .stx-mac-field::placeholder {
648
+ color: var(--stx-mac-ink-tertiary);
649
+ }
650
+
651
+ .stx-mac-field:focus-visible {
652
+ box-shadow: var(--stx-mac-field-line), var(--stx-mac-focus-ring);
653
+ }
654
+
655
+ .stx-mac-field[aria-invalid='true'] {
656
+ --stx-mac-field-line: inset 0 0 0 1px var(--stx-mac-danger);
657
+ }
658
+
659
+ .stx-mac-field:disabled {
660
+ opacity: 0.5;
661
+ }
662
+
663
+ .stx-mac-field-helper {
664
+ margin: 4px 0 0;
665
+ font-size: var(--stx-mac-font-size-small);
666
+ line-height: 14px;
667
+ letter-spacing: 0;
668
+ color: var(--stx-mac-ink-secondary);
669
+ }
670
+
671
+ @media (prefers-reduced-motion: reduce) {
672
+ .stx-mac-field {
673
+ transition: none;
674
+ }
675
+ }
676
+
677
+ /* Two classes, so these win over the plain field's rules whichever component's stylesheet the page loads last. */
678
+ .stx-mac-field.stx-mac-field-leading {
679
+ padding-left: 24px;
680
+ }
681
+
682
+ .stx-mac-field.stx-mac-field-trailing {
683
+ padding-right: 24px;
684
+ }
685
+
686
+ .stx-mac-field-icon {
687
+ position: absolute;
688
+ top: 5.5px;
689
+ display: inline-flex;
690
+ align-items: center;
691
+ justify-content: center;
692
+ width: 13px;
693
+ height: 13px;
694
+ color: var(--stx-mac-ink-secondary);
695
+ pointer-events: none;
696
+ }
697
+
698
+ .stx-mac-field-icon-leading {
699
+ left: 6px;
700
+ }
701
+
702
+ .stx-mac-field-icon-trailing {
703
+ right: 6px;
704
+ }
705
+
706
+ /* The clear button: a small filled disc with a cross cut from two bars. */
707
+ .stx-mac-field-clear {
708
+ position: absolute;
709
+ top: 5px;
710
+ right: 5px;
711
+ width: 14px;
712
+ height: 14px;
713
+ margin: 0;
714
+ padding: 0;
715
+ border: 0;
716
+ border-radius: 50%;
717
+ background: var(--stx-mac-ink-tertiary);
718
+ -webkit-appearance: none;
719
+ appearance: none;
720
+ cursor: default;
721
+ outline: none;
722
+ }
723
+
724
+ .stx-mac-field-clear::before,
725
+ .stx-mac-field-clear::after {
726
+ content: '';
727
+ position: absolute;
728
+ top: 6.25px;
729
+ left: 3.5px;
730
+ width: 7px;
731
+ height: 1.5px;
732
+ border-radius: 1px;
733
+ background: var(--stx-mac-window);
734
+ transform: rotate(45deg);
735
+ }
736
+
737
+ .stx-mac-field-clear::after {
738
+ transform: rotate(-45deg);
739
+ }
740
+
741
+ .stx-mac-field-clear:focus-visible {
742
+ box-shadow: var(--stx-mac-focus-ring);
743
+ }
744
+
745
+ .stx-mac-field-foot {
746
+ display: flex;
747
+ align-items: baseline;
748
+ justify-content: space-between;
749
+ gap: 8px;
750
+ }
751
+ </style>
@@ -22,10 +22,16 @@ export interface BaseInputProps {
22
22
  inputClassName?: string
23
23
  }
24
24
 
25
+ /** The Mac look, which TextInput, PasswordInput and NumberInput draw; `size` is not read under it. */
26
+ export interface MacFieldLookProps {
27
+ /** `'mac'` draws the 24px Mac field (a stepper, for NumberInput) from the `--stx-mac-*` tokens. */
28
+ variant?: 'mac'
29
+ }
30
+
25
31
  /** The text-like input types `TextInput` renders; anything else is served as `text`. */
26
32
  export type TextInputType = 'text' | 'date' | 'time' | 'datetime-local' | 'month' | 'week' | 'url' | 'tel' | 'color' | 'search' | 'email' | 'number' | 'password'
27
33
 
28
- export interface TextInputProps extends BaseInputProps {
34
+ export interface TextInputProps extends BaseInputProps, MacFieldLookProps {
29
35
  type?: TextInputType
30
36
  leftIcon?: string
31
37
  rightIcon?: string
@@ -54,12 +60,12 @@ export interface EmailInputProps extends Omit<BaseInputProps, 'placeholder'> {
54
60
  placeholder?: string
55
61
  }
56
62
 
57
- export interface PasswordInputProps extends Omit<BaseInputProps, 'placeholder'> {
63
+ export interface PasswordInputProps extends Omit<BaseInputProps, 'placeholder'>, MacFieldLookProps {
58
64
  placeholder?: string
59
65
  showStrength?: boolean
60
66
  }
61
67
 
62
- export interface NumberInputProps extends BaseInputProps {
68
+ export interface NumberInputProps extends BaseInputProps, MacFieldLookProps {
63
69
  min?: number
64
70
  max?: number
65
71
  step?: number