tuidroid 0.0.0-stage → 0.1.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.
Files changed (157) hide show
  1. package/LICENSE +674 -0
  2. package/README.md +181 -2
  3. package/dist/arrange/Mover.svelte +42 -0
  4. package/dist/arrange/Mover.svelte.d.ts +29 -0
  5. package/dist/arrange/PutAway.svelte +48 -0
  6. package/dist/arrange/PutAway.svelte.d.ts +30 -0
  7. package/dist/arrange/arrangement.svelte.d.ts +27 -0
  8. package/dist/arrange/arrangement.svelte.js +44 -0
  9. package/dist/arrange/order.d.ts +7 -0
  10. package/dist/arrange/order.js +20 -0
  11. package/dist/calendar/Calendar.svelte +328 -0
  12. package/dist/calendar/Calendar.svelte.d.ts +28 -0
  13. package/dist/calendar/MonthPicker.svelte +41 -0
  14. package/dist/calendar/MonthPicker.svelte.d.ts +10 -0
  15. package/dist/calendar/YearPicker.svelte +61 -0
  16. package/dist/calendar/YearPicker.svelte.d.ts +11 -0
  17. package/dist/calendar/dates.d.ts +23 -0
  18. package/dist/calendar/dates.js +54 -0
  19. package/dist/charts/BarChart.svelte +98 -0
  20. package/dist/charts/BarChart.svelte.d.ts +28 -0
  21. package/dist/charts/ChartFrame.svelte +133 -0
  22. package/dist/charts/ChartFrame.svelte.d.ts +21 -0
  23. package/dist/charts/ColumnChart.svelte +79 -0
  24. package/dist/charts/ColumnChart.svelte.d.ts +20 -0
  25. package/dist/charts/HeatGrid.svelte +110 -0
  26. package/dist/charts/HeatGrid.svelte.d.ts +22 -0
  27. package/dist/charts/LineChart.svelte +132 -0
  28. package/dist/charts/LineChart.svelte.d.ts +29 -0
  29. package/dist/charts/StripChart.svelte +80 -0
  30. package/dist/charts/StripChart.svelte.d.ts +27 -0
  31. package/dist/charts/scale.d.ts +17 -0
  32. package/dist/charts/scale.js +35 -0
  33. package/dist/controls/AccentStepper.svelte +24 -0
  34. package/dist/controls/AccentStepper.svelte.d.ts +8 -0
  35. package/dist/controls/Button.svelte +264 -0
  36. package/dist/controls/Button.svelte.d.ts +26 -0
  37. package/dist/controls/Cycle.svelte +27 -0
  38. package/dist/controls/Cycle.svelte.d.ts +31 -0
  39. package/dist/controls/NumberStepper.svelte +28 -0
  40. package/dist/controls/NumberStepper.svelte.d.ts +12 -0
  41. package/dist/controls/OptionStepper.svelte +42 -0
  42. package/dist/controls/OptionStepper.svelte.d.ts +34 -0
  43. package/dist/controls/Segmented.svelte +72 -0
  44. package/dist/controls/Segmented.svelte.d.ts +35 -0
  45. package/dist/controls/SettingRow.svelte +59 -0
  46. package/dist/controls/SettingRow.svelte.d.ts +11 -0
  47. package/dist/controls/Stepper.svelte +151 -0
  48. package/dist/controls/Stepper.svelte.d.ts +17 -0
  49. package/dist/controls/TextInput.svelte +176 -0
  50. package/dist/controls/TextInput.svelte.d.ts +12 -0
  51. package/dist/controls/Toggle.svelte +22 -0
  52. package/dist/controls/Toggle.svelte.d.ts +9 -0
  53. package/dist/data/BarRows.svelte +75 -0
  54. package/dist/data/BarRows.svelte.d.ts +15 -0
  55. package/dist/data/CellBar.svelte +55 -0
  56. package/dist/data/CellBar.svelte.d.ts +13 -0
  57. package/dist/data/Delta.svelte +28 -0
  58. package/dist/data/Delta.svelte.d.ts +11 -0
  59. package/dist/data/Hatch.svelte +9 -0
  60. package/dist/data/Hatch.svelte.d.ts +8 -0
  61. package/dist/data/KeyValues.svelte +56 -0
  62. package/dist/data/KeyValues.svelte.d.ts +14 -0
  63. package/dist/data/Legend.svelte +64 -0
  64. package/dist/data/Legend.svelte.d.ts +15 -0
  65. package/dist/data/Meter.svelte +46 -0
  66. package/dist/data/Meter.svelte.d.ts +9 -0
  67. package/dist/data/StackedBar.svelte +64 -0
  68. package/dist/data/StackedBar.svelte.d.ts +14 -0
  69. package/dist/data/Swatch.svelte +56 -0
  70. package/dist/data/Swatch.svelte.d.ts +11 -0
  71. package/dist/data/Table.svelte +86 -0
  72. package/dist/data/Table.svelte.d.ts +16 -0
  73. package/dist/data/Value.svelte +32 -0
  74. package/dist/data/Value.svelte.d.ts +12 -0
  75. package/dist/data/cells.d.ts +27 -0
  76. package/dist/data/cells.js +41 -0
  77. package/dist/data/fit.d.ts +10 -0
  78. package/dist/data/fit.js +35 -0
  79. package/dist/gestures/drag.d.ts +28 -0
  80. package/dist/gestures/drag.js +110 -0
  81. package/dist/gestures/hold.d.ts +7 -0
  82. package/dist/gestures/hold.js +59 -0
  83. package/dist/gestures/pick.d.ts +5 -0
  84. package/dist/gestures/pick.js +60 -0
  85. package/dist/haptics.d.ts +5 -0
  86. package/dist/haptics.js +16 -0
  87. package/dist/icons/Icon.svelte +52 -0
  88. package/dist/icons/Icon.svelte.d.ts +17 -0
  89. package/dist/icons/material.d.ts +68 -0
  90. package/dist/icons/material.js +69 -0
  91. package/dist/index.d.ts +75 -0
  92. package/dist/index.js +91 -0
  93. package/dist/layout/Alert.svelte +46 -0
  94. package/dist/layout/Alert.svelte.d.ts +12 -0
  95. package/dist/layout/Block.svelte +166 -0
  96. package/dist/layout/Block.svelte.d.ts +22 -0
  97. package/dist/layout/Panes.svelte +41 -0
  98. package/dist/layout/Panes.svelte.d.ts +9 -0
  99. package/dist/layout/Rows.svelte +37 -0
  100. package/dist/layout/Rows.svelte.d.ts +8 -0
  101. package/dist/layout/Split.svelte +18 -0
  102. package/dist/layout/Split.svelte.d.ts +4 -0
  103. package/dist/layout/Stage.svelte +59 -0
  104. package/dist/layout/Stage.svelte.d.ts +10 -0
  105. package/dist/layout/Unfold.svelte +25 -0
  106. package/dist/layout/Unfold.svelte.d.ts +9 -0
  107. package/dist/lists/ListItem.svelte +75 -0
  108. package/dist/lists/ListItem.svelte.d.ts +13 -0
  109. package/dist/lists/SwipeRow.svelte +158 -0
  110. package/dist/lists/SwipeRow.svelte.d.ts +21 -0
  111. package/dist/lists/UndoRow.svelte +37 -0
  112. package/dist/lists/UndoRow.svelte.d.ts +10 -0
  113. package/dist/motion/FlipCard.svelte +197 -0
  114. package/dist/motion/FlipCard.svelte.d.ts +34 -0
  115. package/dist/motion/Hero.svelte +59 -0
  116. package/dist/motion/Hero.svelte.d.ts +9 -0
  117. package/dist/motion/ShuffleText.svelte +42 -0
  118. package/dist/motion/ShuffleText.svelte.d.ts +13 -0
  119. package/dist/motion/TypeText.svelte +68 -0
  120. package/dist/motion/TypeText.svelte.d.ts +11 -0
  121. package/dist/motion/shuffle.d.ts +24 -0
  122. package/dist/motion/shuffle.js +58 -0
  123. package/dist/motion/still.d.ts +2 -0
  124. package/dist/motion/still.js +7 -0
  125. package/dist/motion/sweep.d.ts +14 -0
  126. package/dist/motion/sweep.js +59 -0
  127. package/dist/motion/typing.d.ts +9 -0
  128. package/dist/motion/typing.js +19 -0
  129. package/dist/motion/unfold.d.ts +4 -0
  130. package/dist/motion/unfold.js +13 -0
  131. package/dist/nav/Hang.svelte +194 -0
  132. package/dist/nav/Hang.svelte.d.ts +15 -0
  133. package/dist/nav/Pager.svelte +89 -0
  134. package/dist/nav/Pager.svelte.d.ts +43 -0
  135. package/dist/nav/Pane.svelte +93 -0
  136. package/dist/nav/Pane.svelte.d.ts +15 -0
  137. package/dist/nav/Shell.svelte +40 -0
  138. package/dist/nav/Shell.svelte.d.ts +34 -0
  139. package/dist/nav/TabBar.svelte +139 -0
  140. package/dist/nav/TabBar.svelte.d.ts +15 -0
  141. package/dist/styles/base.css +87 -0
  142. package/dist/styles/tokens.css +253 -0
  143. package/dist/text/Fields.svelte +28 -0
  144. package/dist/text/Fields.svelte.d.ts +8 -0
  145. package/dist/text/fields.d.ts +6 -0
  146. package/dist/text/fields.js +16 -0
  147. package/dist/theme/FlavourButton.svelte +55 -0
  148. package/dist/theme/FlavourButton.svelte.d.ts +13 -0
  149. package/dist/theme/Theme.svelte +48 -0
  150. package/dist/theme/Theme.svelte.d.ts +15 -0
  151. package/dist/theme/palette.d.ts +23 -0
  152. package/dist/theme/palette.js +55 -0
  153. package/dist/theme/reveal.d.ts +10 -0
  154. package/dist/theme/reveal.js +92 -0
  155. package/dist/theme/theme.d.ts +15 -0
  156. package/dist/theme/theme.js +21 -0
  157. package/package.json +72 -4
@@ -0,0 +1,59 @@
1
+ <script lang="ts">
2
+ import type { Snippet } from 'svelte'
3
+ import type { HTMLAttributes } from 'svelte/elements'
4
+
5
+ // A setting on a line: its name at the left, its control (a Toggle, a Cycle, a word) at
6
+ // the right, and an optional `hint` under it in the muted colour. `value` sits after the
7
+ // name, for a reading beside the control ("always", "90%"). Line them up in Rows.
8
+ interface Props extends HTMLAttributes<HTMLDivElement> {
9
+ label: string
10
+ value?: Snippet
11
+ hint?: Snippet
12
+ children?: Snippet
13
+ }
14
+
15
+ let { label, value, hint, children, class: className, ...rest }: Props = $props()
16
+ </script>
17
+
18
+ <div {...rest} class={['tui-row', 'tui-setting', className]}>
19
+ <span class="label">{label}</span>
20
+ <span class="value">{@render value?.()}</span>
21
+ <span class="controls">{@render children?.()}</span>
22
+ </div>
23
+ {#if hint}<p class="tui-hint">{@render hint()}</p>{/if}
24
+
25
+ <style>
26
+ @layer tuidroid {
27
+ .tui-setting {
28
+ display: flex;
29
+ align-items: center;
30
+ gap: 1ch;
31
+ min-height: 2em;
32
+ }
33
+
34
+ .label {
35
+ grid-column: label;
36
+ }
37
+
38
+ .value {
39
+ grid-column: value;
40
+ flex: 1;
41
+ min-width: 0;
42
+ }
43
+
44
+ .controls {
45
+ grid-column: controls;
46
+ justify-self: end;
47
+ display: inline-flex;
48
+ align-items: center;
49
+ gap: 0.5ch;
50
+ /* A word button's bracket meets the line's end, as text would. */
51
+ margin-right: -0.3ch;
52
+ }
53
+
54
+ .tui-hint {
55
+ margin: 0 0 0.4em;
56
+ color: var(--tui-muted);
57
+ }
58
+ }
59
+ </style>
@@ -0,0 +1,11 @@
1
+ import type { Snippet } from 'svelte';
2
+ import type { HTMLAttributes } from 'svelte/elements';
3
+ interface Props extends HTMLAttributes<HTMLDivElement> {
4
+ label: string;
5
+ value?: Snippet;
6
+ hint?: Snippet;
7
+ children?: Snippet;
8
+ }
9
+ declare const SettingRow: import("svelte").Component<Props, {}, "">;
10
+ type SettingRow = ReturnType<typeof SettingRow>;
11
+ export default SettingRow;
@@ -0,0 +1,151 @@
1
+ <script lang="ts" module>
2
+ import type { Snippet } from 'svelte'
3
+ import type { HTMLAttributes } from 'svelte/elements'
4
+
5
+ export interface StepperProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
6
+ label: string
7
+ value?: string | number
8
+ children?: Snippet
9
+ width?: number // the value's width in characters, so nothing moves as it changes
10
+ onstep: (direction: -1 | 1, repeating: boolean) => void
11
+ atStart?: boolean
12
+ atEnd?: boolean
13
+ words?: [string, string] // what < and > do, for their names: "earlier", "later"
14
+ stacked?: boolean
15
+ scrubPx?: number
16
+ }
17
+ </script>
18
+
19
+ <script lang="ts">
20
+ import { drag, stepsAt } from '../gestures/drag'
21
+ import { hold } from '../gestures/hold'
22
+ import { tick } from '../haptics'
23
+ import ShuffleText from '../motion/ShuffleText.svelte'
24
+ import Button from './Button.svelte'
25
+
26
+ // A value set with < > instead of typing, TUI style: a label, the value at a fixed width
27
+ // (or `children`, when it needs markup), and the two glyph buttons, which repeat while
28
+ // held. A sideways drag across the row scrubs it: a step every `scrubPx`, right for
29
+ // more, with a haptic tick. `onstep` is told whether a step is one of a repeat or a
30
+ // scrub rather than a tap. `stacked`, it is one of a row of them: its label over < value >.
31
+ // NumberStepper and OptionStepper hold the value themselves; this one leaves it to you.
32
+ let {
33
+ label,
34
+ value = '',
35
+ children,
36
+ width = 10,
37
+ onstep,
38
+ atStart = false,
39
+ atEnd = false,
40
+ words = ['less', 'more'],
41
+ stacked = false,
42
+ scrubPx = 28,
43
+ class: className,
44
+ ...rest
45
+ }: StepperProps = $props()
46
+
47
+ // A tapped step shuffles the value into place; a held or scrubbed one just shows it, as a
48
+ // shuffle at that pace would only flicker.
49
+ let quick = $state(false)
50
+ function step(direction: -1 | 1, repeating: boolean) {
51
+ quick = repeating
52
+ onstep(direction, repeating)
53
+ }
54
+
55
+ let taken = 0 // steps the scrub has applied so far
56
+ const scrub = drag({
57
+ axis: 'x',
58
+ onStart: () => (taken = 0),
59
+ onMove: (dx) => {
60
+ const want = stepsAt(dx, scrubPx)
61
+ while (taken !== want) {
62
+ const direction = want > taken ? 1 : -1
63
+ if ((direction > 0 && atEnd) || (direction < 0 && atStart)) return
64
+ step(direction, true)
65
+ taken += direction
66
+ tick()
67
+ }
68
+ },
69
+ onEnd: () => (taken = 0),
70
+ })
71
+ </script>
72
+
73
+ {#snippet shown()}<span class="value" style:min-width="{width}ch"
74
+ >{#if children}{@render children()}{:else}<ShuffleText text={value} plain={quick} />{/if}</span
75
+ >{/snippet}
76
+
77
+ {#snippet less()}<Button
78
+ variant="glyph"
79
+ aria-label="{label} {words[0]}"
80
+ title="{label} {words[0]}"
81
+ disabled={atStart}
82
+ {@attach hold((repeating) => step(-1, repeating))}>&lt;</Button
83
+ >{/snippet}
84
+
85
+ {#snippet more()}<Button
86
+ variant="glyph"
87
+ aria-label="{label} {words[1]}"
88
+ title="{label} {words[1]}"
89
+ disabled={atEnd}
90
+ {@attach hold((repeating) => step(1, repeating))}>&gt;</Button
91
+ >{/snippet}
92
+
93
+ <div {...rest} class={['tui-stepper', className, { stacked, 'tui-row': !stacked }]} {@attach scrub}>
94
+ {#if stacked}
95
+ <span class="label">{label}</span>
96
+ <span class="dial">{@render less()}{@render shown()}{@render more()}</span>
97
+ {:else}
98
+ <span class="label">{label}</span>{@render shown()}<span class="controls">{@render less()}{@render more()}</span>
99
+ {/if}
100
+ </div>
101
+
102
+ <style>
103
+ @layer tuidroid {
104
+ .tui-stepper {
105
+ touch-action: pan-y;
106
+ display: flex;
107
+ align-items: center;
108
+ gap: 1ch;
109
+ min-height: 2em;
110
+ }
111
+
112
+ .label {
113
+ grid-column: label;
114
+ flex: none;
115
+ }
116
+
117
+ .value {
118
+ grid-column: value;
119
+ flex: 1;
120
+ white-space: pre;
121
+ color: var(--tui-accent);
122
+ }
123
+
124
+ .controls {
125
+ grid-column: controls;
126
+ display: inline-flex;
127
+ margin-right: -0.6ch;
128
+ }
129
+
130
+ /* Stacked, one of a row: the label over < value >, all centred. */
131
+ .stacked {
132
+ display: inline-flex;
133
+ flex-direction: column;
134
+ gap: 0;
135
+
136
+ & .value {
137
+ flex: none;
138
+ text-align: center;
139
+ }
140
+
141
+ & .dial {
142
+ display: flex;
143
+ align-items: center;
144
+ }
145
+
146
+ & :global(.tui-button.glyph) {
147
+ min-width: 1.8em;
148
+ }
149
+ }
150
+ }
151
+ </style>
@@ -0,0 +1,17 @@
1
+ import type { Snippet } from 'svelte';
2
+ import type { HTMLAttributes } from 'svelte/elements';
3
+ export interface StepperProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
4
+ label: string;
5
+ value?: string | number;
6
+ children?: Snippet;
7
+ width?: number;
8
+ onstep: (direction: -1 | 1, repeating: boolean) => void;
9
+ atStart?: boolean;
10
+ atEnd?: boolean;
11
+ words?: [string, string];
12
+ stacked?: boolean;
13
+ scrubPx?: number;
14
+ }
15
+ declare const Stepper: import("svelte").Component<StepperProps, {}, "">;
16
+ type Stepper = ReturnType<typeof Stepper>;
17
+ export default Stepper;
@@ -0,0 +1,176 @@
1
+ <script lang="ts">
2
+ import type { HTMLInputAttributes } from 'svelte/elements'
3
+ import Icon, { type IconPath } from '../icons/Icon.svelte'
4
+ import type { IconName } from '../icons/material'
5
+
6
+ // A text field in the grid's font: the page's background in a button's border, an
7
+ // `icon` before it (⌕ for a search). With `suggest` it offers to finish what is typed:
8
+ // the rest of the suggestion shows greyed out behind the text, and Tab, → at the end, or
9
+ // the button at the field's right takes it. bind:value.
10
+ interface Props extends Omit<HTMLInputAttributes, 'value'> {
11
+ value: string
12
+ icon?: IconName | IconPath
13
+ suggest?: (typed: string) => string | null
14
+ completeLabel?: string
15
+ }
16
+
17
+ let {
18
+ value = $bindable(''),
19
+ icon,
20
+ suggest,
21
+ completeLabel = 'Complete',
22
+ class: className,
23
+ onkeydown,
24
+ oninput,
25
+ onscroll,
26
+ ...rest
27
+ }: Props = $props()
28
+
29
+ let input = $state<HTMLInputElement>()
30
+ let scroll = $state(0) // how far the text has scrolled in the field, which the grey text follows
31
+ const suggestion = $derived(suggest?.(value) ?? null)
32
+ const ghost = $derived(suggestion?.toLowerCase().startsWith(value.toLowerCase()) ? suggestion.slice(value.length) : '')
33
+ const follow = () => (scroll = input?.scrollLeft ?? 0)
34
+
35
+ function take() {
36
+ if (!suggestion || !input) return
37
+ value = suggestion
38
+ const field = input
39
+ field.focus()
40
+ requestAnimationFrame(() => {
41
+ field.setSelectionRange(field.value.length, field.value.length)
42
+ follow()
43
+ })
44
+ }
45
+
46
+ function keydown(event: KeyboardEvent & { currentTarget: EventTarget & HTMLInputElement }) {
47
+ onkeydown?.(event)
48
+ if (!ghost || !input || event.defaultPrevented) return
49
+ const atEnd = input.selectionStart === value.length && input.selectionEnd === value.length
50
+ if ((event.key === 'Tab' && !event.shiftKey) || (event.key === 'ArrowRight' && atEnd)) {
51
+ event.preventDefault()
52
+ take()
53
+ }
54
+ }
55
+ </script>
56
+
57
+ <span class={['tui-input', className, { 'with-icon': icon, completing: ghost }]}>
58
+ {#if icon}<span class="lead"><Icon {icon} /></span>{/if}
59
+ {#if suggest}<span class="behind" aria-hidden="true"
60
+ ><span class="ghost" style:transform="translateX({-scroll}px)"><span class="typed">{value}</span>{ghost}</span></span
61
+ >{/if}
62
+ <input
63
+ type="text"
64
+ {...rest}
65
+ bind:this={input}
66
+ bind:value
67
+ onkeydown={keydown}
68
+ oninput={(event) => {
69
+ follow()
70
+ oninput?.(event)
71
+ }}
72
+ onscroll={(event) => {
73
+ follow()
74
+ onscroll?.(event)
75
+ }}
76
+ />
77
+ {#if ghost}
78
+ <!-- Keeps the keyboard up: the press does not take the focus from the field. -->
79
+ <button
80
+ type="button"
81
+ class="take"
82
+ aria-label="{completeLabel}: {suggestion}"
83
+ title={completeLabel}
84
+ onpointerdown={(event) => event.preventDefault()}
85
+ onclick={take}><Icon icon="keyboard_tab" /></button
86
+ >
87
+ {/if}
88
+ </span>
89
+
90
+ <style>
91
+ @layer tuidroid {
92
+ .tui-input {
93
+ position: relative;
94
+ display: flex;
95
+ align-items: center;
96
+ min-width: 0;
97
+ background: var(--tui-bg);
98
+ border: 1px solid var(--tui-button-border);
99
+ border-radius: var(--tui-radius);
100
+ transition: border-color var(--tui-fade) ease;
101
+
102
+ &:focus-within {
103
+ border-color: var(--tui-accent);
104
+ }
105
+ }
106
+
107
+ input {
108
+ flex: 1;
109
+ min-width: 0;
110
+ position: relative;
111
+ font: inherit;
112
+ color: inherit;
113
+ background: transparent;
114
+ border: none;
115
+ outline: none;
116
+ padding: 0.3em 1ch;
117
+ }
118
+
119
+ input::placeholder {
120
+ color: var(--tui-muted);
121
+ opacity: 1;
122
+ }
123
+
124
+ .with-icon input {
125
+ padding-left: 0.6ch;
126
+ }
127
+
128
+ .completing input {
129
+ padding-right: 3.5ch;
130
+ }
131
+
132
+ .lead {
133
+ padding-left: 1ch;
134
+ color: var(--tui-accent);
135
+ }
136
+
137
+ /* Inside the field where its text sits; what scrolls out of the field is cut off. */
138
+ .behind {
139
+ position: absolute;
140
+ inset: 1px 3.5ch 1px 1px;
141
+ padding: 0 1ch;
142
+ display: flex;
143
+ align-items: center;
144
+ overflow: hidden;
145
+ color: var(--tui-muted);
146
+ pointer-events: none;
147
+ }
148
+
149
+ /* The lead's room (1ch and the icon) and the field's own padding. */
150
+ .with-icon .behind {
151
+ padding-left: calc(1.6ch + 1em);
152
+ }
153
+
154
+ .ghost {
155
+ white-space: pre;
156
+ }
157
+
158
+ /* What is typed holds its place, unseen: the field draws it. */
159
+ .typed {
160
+ visibility: hidden;
161
+ }
162
+
163
+ .take {
164
+ position: absolute;
165
+ right: 0.4ch;
166
+ top: 50%;
167
+ transform: translateY(-50%);
168
+ padding: 0.2em 0.6ch;
169
+ font: inherit;
170
+ color: var(--tui-accent);
171
+ background: none;
172
+ border: none;
173
+ cursor: pointer;
174
+ }
175
+ }
176
+ </style>
@@ -0,0 +1,12 @@
1
+ import type { HTMLInputAttributes } from 'svelte/elements';
2
+ import { type IconPath } from '../icons/Icon.svelte';
3
+ import type { IconName } from '../icons/material';
4
+ interface Props extends Omit<HTMLInputAttributes, 'value'> {
5
+ value: string;
6
+ icon?: IconName | IconPath;
7
+ suggest?: (typed: string) => string | null;
8
+ completeLabel?: string;
9
+ }
10
+ declare const TextInput: import("svelte").Component<Props, {}, "value">;
11
+ type TextInput = ReturnType<typeof TextInput>;
12
+ export default TextInput;
@@ -0,0 +1,22 @@
1
+ <script lang="ts">
2
+ import ShuffleText from '../motion/ShuffleText.svelte'
3
+ import Button, { type ButtonProps } from './Button.svelte'
4
+
5
+ // A setting that is on or off, as a word: [ on ] in the accent, [ off ] muted, its word
6
+ // shuffling as it flips. bind:checked. `labels` are its two words.
7
+ interface Props extends Omit<ButtonProps, 'variant' | 'children' | 'onchange'> {
8
+ checked: boolean
9
+ labels?: [on: string, off: string]
10
+ onchange?: (checked: boolean) => void
11
+ }
12
+
13
+ let { checked = $bindable(), labels = ['on', 'off'], onchange, onclick, ...rest }: Props = $props()
14
+
15
+ function flip(event: MouseEvent & { currentTarget: EventTarget & HTMLButtonElement }) {
16
+ checked = !checked
17
+ onchange?.(checked)
18
+ onclick?.(event)
19
+ }
20
+ </script>
21
+
22
+ <Button {...rest} variant="word" aria-pressed={checked} onclick={flip}><ShuffleText text={checked ? labels[0] : labels[1]} /></Button>
@@ -0,0 +1,9 @@
1
+ import { type ButtonProps } from './Button.svelte';
2
+ interface Props extends Omit<ButtonProps, 'variant' | 'children' | 'onchange'> {
3
+ checked: boolean;
4
+ labels?: [on: string, off: string];
5
+ onchange?: (checked: boolean) => void;
6
+ }
7
+ declare const Toggle: import("svelte").Component<Props, {}, "checked">;
8
+ type Toggle = ReturnType<typeof Toggle>;
9
+ export default Toggle;
@@ -0,0 +1,75 @@
1
+ <script lang="ts" module>
2
+ export interface BarRow {
3
+ label: string
4
+ value: number
5
+ colour?: string
6
+ }
7
+ </script>
8
+
9
+ <script lang="ts">
10
+ import type { HTMLAttributes } from 'svelte/elements'
11
+ import { FILL, SHADE } from './cells'
12
+ import { fit } from './fit'
13
+
14
+ // Values side by side as text bars, a row each: the label muted at the left, the bar
15
+ // filling the middle against the largest (or `max`), the value at the right through
16
+ // `format`. Length bands, coverage by rank. A value above nothing shows a cell at least.
17
+ interface Props extends HTMLAttributes<HTMLDivElement> {
18
+ rows: readonly BarRow[]
19
+ max?: number
20
+ format?: (value: number) => string
21
+ colour?: string
22
+ }
23
+
24
+ let { rows, max, format = String, colour = 'var(--tui-accent)', class: className, ...rest }: Props = $props()
25
+
26
+ let cells = $state(0)
27
+ const top = $derived(max ?? Math.max(1, ...rows.map((r) => r.value)))
28
+ const filled = (value: number) => (value > 0 ? Math.max(1, Math.min(cells, Math.round((value / top) * cells))) : 0)
29
+ </script>
30
+
31
+ <div {...rest} class={['tui-barrows', className]}>
32
+ {#each rows as row, i (row.label)}
33
+ {const n = $derived(filled(row.value))}
34
+ <span class="label">{row.label}</span>
35
+ <span class="bar" role="img" aria-label="{row.label}: {format(row.value)}" {@attach i === 0 && fit((f) => (cells = f.cells))}
36
+ ><span style:color={row.colour ?? colour}>{FILL.repeat(n)}</span><span class="shade">{SHADE.repeat(Math.max(0, cells - n))}</span
37
+ ></span
38
+ >
39
+ <span class="value" aria-hidden="true">{format(row.value)}</span>
40
+ {/each}
41
+ </div>
42
+
43
+ <style>
44
+ @layer tuidroid {
45
+ .tui-barrows {
46
+ display: grid;
47
+ grid-template-columns: max-content minmax(0, 1fr) max-content;
48
+ column-gap: 1ch;
49
+ align-items: center;
50
+ font-variant-ligatures: none;
51
+ }
52
+
53
+ .label {
54
+ color: var(--tui-muted);
55
+ white-space: pre;
56
+ }
57
+
58
+ .bar {
59
+ position: relative;
60
+ display: block;
61
+ overflow: hidden;
62
+ white-space: pre;
63
+ line-height: 1.3;
64
+ }
65
+
66
+ .shade {
67
+ color: var(--tui-shade, var(--tui-button-border));
68
+ }
69
+
70
+ .value {
71
+ text-align: right;
72
+ white-space: pre;
73
+ }
74
+ }
75
+ </style>
@@ -0,0 +1,15 @@
1
+ export interface BarRow {
2
+ label: string;
3
+ value: number;
4
+ colour?: string;
5
+ }
6
+ import type { HTMLAttributes } from 'svelte/elements';
7
+ interface Props extends HTMLAttributes<HTMLDivElement> {
8
+ rows: readonly BarRow[];
9
+ max?: number;
10
+ format?: (value: number) => string;
11
+ colour?: string;
12
+ }
13
+ declare const BarRows: import("svelte").Component<Props, {}, "">;
14
+ type BarRows = ReturnType<typeof BarRows>;
15
+ export default BarRows;
@@ -0,0 +1,55 @@
1
+ <script lang="ts">
2
+ import type { HTMLAttributes } from 'svelte/elements'
3
+ import { progressCells, type Stop } from './cells'
4
+ import { fit } from './fit'
5
+
6
+ // A share as a line of text cells: the filled ones █ in the accent, or each in the colour
7
+ // of the stop it falls in (a fast's stages), the rest ░, or ╱ hatched with `hatchRest`
8
+ // (a near miss). `cells` across, or as many as fit the width it is given.
9
+ interface Props extends HTMLAttributes<HTMLSpanElement> {
10
+ value: number // 0 to 1
11
+ cells?: number
12
+ stops?: readonly Stop[]
13
+ colour?: string
14
+ hatchRest?: boolean
15
+ label?: string // what it measures, for a screen reader
16
+ }
17
+
18
+ let { value, cells, stops, colour, hatchRest = false, label, class: className, ...rest }: Props = $props()
19
+
20
+ let fitted = $state(0)
21
+ const count = $derived(cells ?? fitted)
22
+ const runs = $derived(progressCells(value, { cells: count, stops, colour, hatchRest }))
23
+ </script>
24
+
25
+ <span
26
+ {...rest}
27
+ class={['tui-cellbar', className, { fill: cells === undefined }]}
28
+ role="meter"
29
+ aria-label={label}
30
+ aria-valuemin={0}
31
+ aria-valuemax={100}
32
+ aria-valuenow={Math.round(Math.min(1, Math.max(0, value)) * 100)}
33
+ {@attach cells === undefined && fit((f) => (fitted = f.cells))}
34
+ >{#each runs as run, i (i)}<span class={{ shade: run.colour === null }} style:color={run.colour}>{run.text}</span>{/each}</span
35
+ >
36
+
37
+ <style>
38
+ @layer tuidroid {
39
+ .tui-cellbar {
40
+ position: relative;
41
+ white-space: pre;
42
+ font-variant-ligatures: none;
43
+ line-height: 1.2;
44
+
45
+ &.fill {
46
+ display: block;
47
+ overflow: hidden;
48
+ }
49
+ }
50
+
51
+ .shade {
52
+ color: var(--tui-shade, var(--tui-button-border));
53
+ }
54
+ }
55
+ </style>
@@ -0,0 +1,13 @@
1
+ import type { HTMLAttributes } from 'svelte/elements';
2
+ import { type Stop } from './cells';
3
+ interface Props extends HTMLAttributes<HTMLSpanElement> {
4
+ value: number;
5
+ cells?: number;
6
+ stops?: readonly Stop[];
7
+ colour?: string;
8
+ hatchRest?: boolean;
9
+ label?: string;
10
+ }
11
+ declare const CellBar: import("svelte").Component<Props, {}, "">;
12
+ type CellBar = ReturnType<typeof CellBar>;
13
+ export default CellBar;
@@ -0,0 +1,28 @@
1
+ <script lang="ts">
2
+ import type { HTMLAttributes } from 'svelte/elements'
3
+
4
+ // How a value moved against the one before it: ▲ in --tui-ok when it rose, ▼ in
5
+ // --tui-bad when it fell, and nothing when it held or there is nothing to set it
6
+ // against. With `invert`, falling is the good direction (a weight, a time taken).
7
+ // It draws the mark alone; put it after a space, which collapses when it is absent.
8
+ interface Props extends HTMLAttributes<HTMLSpanElement> {
9
+ value: number
10
+ before?: number | null
11
+ invert?: boolean
12
+ rose?: string // what a screen reader hears
13
+ fell?: string
14
+ }
15
+
16
+ let { value, before, invert = false, rose = 'up on before', fell = 'down on before', class: className, ...rest }: Props = $props()
17
+
18
+ const up = $derived(before != null && value > before)
19
+ const moved = $derived(before != null && value !== before)
20
+ </script>
21
+
22
+ {#if moved}<span
23
+ {...rest}
24
+ class={['tui-delta', className]}
25
+ role="img"
26
+ aria-label={up ? rose : fell}
27
+ style:color={up !== invert ? 'var(--tui-ok)' : 'var(--tui-bad)'}>{up ? '▲' : '▼'}</span
28
+ >{/if}
@@ -0,0 +1,11 @@
1
+ import type { HTMLAttributes } from 'svelte/elements';
2
+ interface Props extends HTMLAttributes<HTMLSpanElement> {
3
+ value: number;
4
+ before?: number | null;
5
+ invert?: boolean;
6
+ rose?: string;
7
+ fell?: string;
8
+ }
9
+ declare const Delta: import("svelte").Component<Props, {}, "">;
10
+ type Delta = ReturnType<typeof Delta>;
11
+ export default Delta;
@@ -0,0 +1,9 @@
1
+ <script lang="ts">
2
+ // Diagonal lines in a colour, as an SVG pattern to fill with (fill="url(#id)"): what
3
+ // fills a near miss, within its outline. Goes inside an <svg>'s <defs>.
4
+ let { id, colour = 'currentColor', pitch = 3 }: { id: string; colour?: string; pitch?: number } = $props()
5
+ </script>
6
+
7
+ <pattern {id} width={pitch} height={pitch} patternUnits="userSpaceOnUse" patternTransform="rotate(45)">
8
+ <rect width={pitch * 0.4} height={pitch} style:fill={colour} />
9
+ </pattern>
@@ -0,0 +1,8 @@
1
+ type $$ComponentProps = {
2
+ id: string;
3
+ colour?: string;
4
+ pitch?: number;
5
+ };
6
+ declare const Hatch: import("svelte").Component<$$ComponentProps, {}, "">;
7
+ type Hatch = ReturnType<typeof Hatch>;
8
+ export default Hatch;