svelte-tweakpane-ui 1.5.19 → 1.6.0-preview.10

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,69 @@
1
+ <script context="module"></script>
2
+
3
+ <script>
4
+ import { BROWSER } from 'esm-env'
5
+ import * as pluginModule from 'tweakpane-plugin-color-plus/lite'
6
+ import { ColorPlusModel } from 'tweakpane-plugin-color-plus/lite'
7
+ import ClsPad from '../internal/ClsPad.svelte'
8
+ import GenericInputFolding from '../internal/GenericInputFolding.svelte'
9
+ import { fillWith } from '../utils.js'
10
+ export let value
11
+ export let expanded = void 0
12
+ export let type = void 0
13
+ export let alpha = void 0
14
+ export let constrain = void 0
15
+ export let formatLocked = void 0
16
+ export let gamutLabel = void 0
17
+ export let gamutLines = void 0
18
+ export let gamuts = void 0
19
+ export let paletteChannels = void 0
20
+ export let paletteProjection = void 0
21
+ export let swatchFallback = void 0
22
+ export let textFields = void 0
23
+ let options
24
+ let ref
25
+ const buttonClass = 'tp-colswv_b'
26
+ $: options = {
27
+ color: {
28
+ alpha,
29
+ formatLocked,
30
+ type,
31
+ },
32
+ constrain,
33
+ gamutLabel,
34
+ gamutLines,
35
+ gamuts,
36
+ paletteChannels,
37
+ paletteProjection,
38
+ swatchFallback,
39
+ textFields,
40
+ view: 'color-plus',
41
+ }
42
+ </script>
43
+
44
+ <GenericInputFolding
45
+ bind:value
46
+ bind:expanded
47
+ bind:ref
48
+ on:change
49
+ {buttonClass}
50
+ {options}
51
+ plugin={pluginModule}
52
+ {...$$restProps}
53
+ />
54
+ {#if !BROWSER && expanded && $$props.picker === 'inline'}
55
+ <!-- Main swatch -->
56
+ <ClsPad
57
+ keysAdd={fillWith('containerUnitSize', textFields === false ? 5 : 6)}
58
+ theme={$$props.theme}
59
+ />
60
+ <ClsPad
61
+ keysAdd={fillWith('containerUnitSpacing', textFields === false ? 2 : 3)}
62
+ theme={$$props.theme}
63
+ />
64
+ <!-- Detect alpha slider... -->
65
+ {#if alpha === true || ColorPlusModel.getFormat(value, alpha, type)?.alpha}
66
+ <ClsPad keysAdd={fillWith('containerUnitSize', 1)} theme={$$props.theme} />
67
+ <ClsPad extra={2} keysAdd={fillWith('containerVerticalPadding', 2)} theme={$$props.theme} />
68
+ {/if}
69
+ {/if}
@@ -0,0 +1,325 @@
1
+ import { SvelteComponent } from 'svelte'
2
+ import type { ColorPlusValue } from 'tweakpane-plugin-color-plus/lite'
3
+ import type { ValueChangeEvent } from '../utils.js'
4
+ export type { ColorPlusValue } from 'tweakpane-plugin-color-plus/lite'
5
+ export type ColorPlusChangeEvent = ValueChangeEvent<ColorPlusValue>
6
+ import type { ColorPlusInputParams as ColorPlusOptions } from 'tweakpane-plugin-color-plus/lite'
7
+ declare const __propDef: {
8
+ props: Omit<
9
+ Omit<
10
+ {
11
+ /**
12
+ * The binding's target object with values to manipulate.
13
+ *
14
+ * @bindable
15
+ */
16
+ object: import('@tweakpane/core').Bindable & Record<string, ColorPlusValue>
17
+ /**
18
+ * The key for the value in the target `object` that the control should
19
+ * manipulate.
20
+ */
21
+ key: string
22
+ /**
23
+ * Prevent interactivity and gray out the control.
24
+ *
25
+ * @default `false`
26
+ */
27
+ disabled?: boolean
28
+ /**
29
+ * Text displayed next to control.
30
+ *
31
+ * @default `undefined`
32
+ */
33
+ label?: string | undefined
34
+ /**
35
+ * Tweakpane's internal options object.
36
+ *
37
+ * See
38
+ * [`BindingParams`](https://tweakpane.github.io/docs/api/types/BindingParams.html).
39
+ *
40
+ * Valid types are contingent on the type of the value `key` points to in
41
+ * `object`.
42
+ *
43
+ * This is intended internal use, when implementing convenience components
44
+ * wrapping Binding's functionality. Options of interest are instead exposed
45
+ * as top-level props in _Svelte Tweakpane UI_.
46
+ *
47
+ * @default `undefined`
48
+ */
49
+ options?: ColorPlusOptions | undefined
50
+ /**
51
+ * Custom color scheme.
52
+ *
53
+ * If undefined, inherits default Tweakpane theme equivalent to
54
+ * `ThemeUtils.presets.standard`, or the theme set with
55
+ * `setGlobalDefaultTheme()`.
56
+ *
57
+ * @default `undefined`
58
+ */
59
+ theme?: import('..').Theme | undefined
60
+ /**
61
+ * Reference to internal Tweakpane
62
+ * [`BindingApi`](https://tweakpane.github.io/docs/api/classes/_internal_.BindingApi.html)
63
+ * for this control.
64
+ *
65
+ * This property is exposed for advanced use cases only, such as when
66
+ * implementing convenience components wrapping `<Binding>`'s functionality.
67
+ *
68
+ * Direct manipulation of Tweakpane's internals can break _Svelte Tweakpane
69
+ * UI_ abstractions.
70
+ *
71
+ * @bindable
72
+ * @readonly
73
+ */
74
+ ref?: import('../internal/GenericInput.svelte').GenericInputRef | undefined
75
+ /**
76
+ * Imported Tweakpane `TpPluginBundle` (aliased as `Plugin`) module to
77
+ * automatically register in the `<Binding>`'s containing `<Pane>`.
78
+ *
79
+ * This property is exposed for advanced use cases only, such as when
80
+ * implementing convenience components wrapping `<Binding>`'s functionality in
81
+ * combination with a Tweakpane plugin.
82
+ *
83
+ * Direct manipulation of Tweakpane's internals can break _Svelte Tweakpane
84
+ * UI_ abstractions.
85
+ *
86
+ * @default `undefined`
87
+ */
88
+ plugin?: import('../utils.js').Plugin | undefined
89
+ },
90
+ 'object' | 'key'
91
+ > & {
92
+ /**
93
+ * A color value to control.
94
+ *
95
+ * Use either a color-like string (e.g. #ff00ff), a number, an object with
96
+ * `r`, `b`, `g`, and optional `a` keys, or a tuple.
97
+ *
98
+ * @bindable
99
+ */
100
+ value: ColorPlusValue
101
+ } & {
102
+ /**
103
+ * DOM class name of the button used to expand and collapse the input's
104
+ * picker.
105
+ *
106
+ * @default `undefined`
107
+ */
108
+ buttonClass?: string
109
+ /**
110
+ * Expand or collapse the input's picker.
111
+ *
112
+ * @default `false`
113
+ * @bindable
114
+ */
115
+ expanded?: boolean
116
+ /**
117
+ * The style of value "picker" to use in the input.
118
+ *
119
+ * @default `'popup'`
120
+ */
121
+ picker?: 'inline' | 'popup'
122
+ /**
123
+ * Allow users to interactively expand / contract the picker.
124
+ *
125
+ * @default `true`
126
+ */
127
+ userExpandable?: boolean
128
+ },
129
+ 'ref' | 'options' | 'plugin' | 'buttonClass'
130
+ > & {
131
+ /**
132
+ * For number values only: Whether to treat the number as carrying an alpha
133
+ * component in its lowest byte (e.g. `0xff00667f`). (TODO not sure this is
134
+ * a good idea to expose...)
135
+ *
136
+ * @default `false`
137
+ */
138
+ alpha?: boolean
139
+ /**
140
+ * Keep the color inside the widest gamut configured in `gamuts`.
141
+ *
142
+ * Picks on the palette plane snap to the in-gamut frontier, while slider
143
+ * moves, typed text, and externally bound values shed chroma (at constant
144
+ * lightness and hue) to fit.
145
+ *
146
+ * Set to `false` to allow out-of-gamut colors.
147
+ *
148
+ * @default `true`
149
+ */
150
+ constrain?: boolean
151
+ /**
152
+ * Whether a valid color entered in the picker's text field is converted
153
+ * back to the bound value's original format.
154
+ *
155
+ * Set to `false` to let a typed value switch the binding's format to match
156
+ * what was typed. _(Experimental!)_
157
+ *
158
+ * @default `true`
159
+ */
160
+ formatLocked?: boolean
161
+ /**
162
+ * Draw the name of the narrowest configured gamut that holds the current
163
+ * color in the picker plane's bottom-left corner.
164
+ *
165
+ * The default adapts to the bound color's model: `true` when it's wide or
166
+ * perceptual, `false` when it's sRGB-bound.
167
+ *
168
+ * @default `true` (`false` for sRGB-bound color models)
169
+ */
170
+ gamutLabel?: boolean
171
+ /**
172
+ * Which configured gamut boundaries are stroked over the picker plane.
173
+ *
174
+ * `'inner'` draws the narrower gamuts' lines, `'outer'` draws the widest
175
+ * gamut's line (otherwise redundant with the drawn plane's own edge),
176
+ * `'all'` draws both, and `'none'` hides every line.
177
+ *
178
+ * @default `'inner'`
179
+ */
180
+ gamutLines?: 'all' | 'inner' | 'none' | 'outer'
181
+ /**
182
+ * RGB gamuts whose boundaries the OKLCH picker draws, as an array of ids.
183
+ *
184
+ * Both colorjs ids and their CSS aliases are accepted: `'srgb'`, `'p3'` /
185
+ * `'display-p3'`, `'a98rgb'` / `'a98-rgb'`, `'rec2020'`, and `'prophoto'` /
186
+ * `'prophoto-rgb'`.
187
+ *
188
+ * The default adapts to the bound color's model: `['srgb', 'p3']` when it's
189
+ * wide or perceptual, `['srgb']` when it's sRGB-bound.
190
+ *
191
+ * @default `['srgb', 'p3']` (`['srgb']` for sRGB-bound color models)
192
+ */
193
+ gamuts?: string[]
194
+ /**
195
+ * Which OKLCH channels map to the picker plane's axes and the slider, as
196
+ * `[X][Y]_[slider]`.
197
+ *
198
+ * @default `'CL_H'`
199
+ */
200
+ paletteChannels?: 'CH_L' | 'CL_H' | 'HC_L' | 'HL_C' | 'LC_H' | 'LH_C'
201
+ /**
202
+ * How the picker plane projects the gamut volume onto its rectangle.
203
+ *
204
+ * `'okhsv'` uses an OKHSV saturation / value projection on lightness ×
205
+ * chroma layouts (the most similar to Tweakpane's built-in palette),
206
+ * falling back to `'stretch'` behavior on other layouts. `'perceptual'`
207
+ * keeps absolute OKLCH spacing, so the gamut sits as an irregular region
208
+ * within the plane. `'stretch'` fills the plane with the widest gamut, row
209
+ * by row.
210
+ *
211
+ * @default `'okhsv'`
212
+ */
213
+ paletteProjection?: 'okhsv' | 'perceptual' | 'stretch'
214
+ /**
215
+ * How the swatch preview's fallback triangle forces an out-of-gamut color
216
+ * into sRGB.
217
+ *
218
+ * `'clip'` clamps each channel to its range, matching what the browser
219
+ * paints on screen. `'css'` applies the [CSS Color 4 gamut-mapping
220
+ * algorithm](https://www.w3.org/TR/css-color-4/#gamut-mapping) (chroma
221
+ * reduction at constant lightness and hue), which can disagree with
222
+ * on-screen rendering.
223
+ *
224
+ * Only affects the swatch preview, never the color value itself.
225
+ *
226
+ * @default `'clip'`
227
+ */
228
+ swatchFallback?: 'clip' | 'css'
229
+ /**
230
+ * Show the color model drop-down and per-channel text inputs below the
231
+ * picker palette.
232
+ *
233
+ * Set to `false` to hide them for a more compact, pointer-only picker. (The
234
+ * alpha slider's text input, if present, is unaffected.)
235
+ *
236
+ * @default `true`
237
+ */
238
+ textFields?: boolean
239
+ /**
240
+ * Whether to treat values as floats from 0.0 to 1.0, or integers from 0 to
241
+ * 255.
242
+ *
243
+ * @default `'int'`
244
+ */
245
+ type?: 'float' | 'int'
246
+ /**
247
+ * A color value to control.
248
+ *
249
+ * Use either a color-like string (e.g. #ff00ff), a number, an object with
250
+ * `r`, `b`, `g`, and optional `a` keys, or a tuple.
251
+ *
252
+ * @bindable
253
+ */
254
+ value: ColorPlusValue
255
+ }
256
+ slots: {}
257
+ events: {
258
+ /**
259
+ * Fires when `value` changes.
260
+ *
261
+ * _This event is provided for advanced use cases. It's usually preferred to
262
+ * bind to the `value` prop instead._
263
+ *
264
+ * The `event.details` payload includes a copy of the value and an `origin`
265
+ * field to distinguish between user-interactive changes (`internal`) and
266
+ * changes resulting from programmatic manipulation of the `value`
267
+ * (`external`).
268
+ *
269
+ * @extends ValueChangeEvent
270
+ * @event
271
+ */
272
+ change: ColorPlusChangeEvent
273
+ }
274
+ }
275
+ export type ColorPlusProps = typeof __propDef.props
276
+ export type ColorPlusEvents = typeof __propDef.events
277
+ export type ColorPlusSlots = typeof __propDef.slots
278
+ /**
279
+ * A color picker with support for additional color value formats.
280
+ *
281
+ * Integrates the color control from the [Color Plus
282
+ * plugin](https://github.com/kitschpatrol/tweakpane-plugin-color-plus).
283
+ *
284
+ * This component looks very similar to the Tweakpane-native `<Color>` control, but it adds support for all [CSS Color Module Level 4](https://www.w3.org/TR/css-color-4/) color string formats, color arrays, a wider range of color objects, and a revised color picker with support for wide-gamut color spaces.
285
+ *
286
+ * The plugin on which `<ColorPlus>` is based is still under active development, but can generally be used as a drop-in replacement for the `Color` control. Please report any issues you might encountered.
287
+ *
288
+ * `<ColorPlus>` might replace the `<Color>` control entirely in the next major version of `svelte-tweakpane-ui`.
289
+ *
290
+ * Usage outside of a `<Pane>` component will implicitly wrap the color picker in `<Pane
291
+ * position="inline">`.
292
+ *
293
+ * @emits {ColorPlusChangeEvent} change - When `value` changes. (This event is provided for advanced use cases. Prefer binding to `value`.)
294
+ *
295
+ * @example
296
+ * ```svelte
297
+ * <script lang="ts">
298
+ * import { ColorPlus } from 'svelte-tweakpane-ui'
299
+ *
300
+ * let startColor = 'oklch(93.7% 0.199 105deg / 1)'
301
+ * let endColor = 'oklch(70.2% 0.322 328deg / 1)'
302
+ * </script>
303
+ *
304
+ * <ColorPlus bind:value={startColor} label="Start Color" />
305
+ * <ColorPlus bind:value={endColor} label="End Color" />
306
+ *
307
+ * <div class="demo" style:--a={startColor} style:--b={endColor}></div>
308
+ *
309
+ * <style>
310
+ * .demo {
311
+ * aspect-ratio: 1;
312
+ * width: 100%;
313
+ * background: linear-gradient(to top, var(--a), var(--b));
314
+ * }
315
+ * </style>
316
+ * ```
317
+ *
318
+ * @sourceLink
319
+ * [ColorPlus.svelte](https://github.com/kitschpatrol/svelte-tweakpane-ui/blob/main/src/lib/control/ColorPlus.svelte)
320
+ */
321
+ export default class ColorPlus extends SvelteComponent<
322
+ ColorPlusProps,
323
+ ColorPlusEvents,
324
+ ColorPlusSlots
325
+ > {}
package/dist/index.d.ts CHANGED
@@ -14,6 +14,8 @@ export type {
14
14
  ColorValueRgbTuple,
15
15
  ColorValueString,
16
16
  } from './control/Color.svelte'
17
+ export { default as ColorPlus } from './control/ColorPlus.svelte'
18
+ export type { ColorPlusChangeEvent, ColorPlusValue } from './control/ColorPlus.svelte'
17
19
  export { default as CubicBezier } from './control/CubicBezier.svelte'
18
20
  export type {
19
21
  CubicBezierChangeEvent,
package/dist/index.js CHANGED
@@ -2,6 +2,7 @@ export { default as Button } from './control/Button.svelte'
2
2
  export { default as ButtonGrid } from './control/ButtonGrid.svelte'
3
3
  export { default as Checkbox } from './control/Checkbox.svelte'
4
4
  export { default as Color } from './control/Color.svelte'
5
+ export { default as ColorPlus } from './control/ColorPlus.svelte'
5
6
  export { default as CubicBezier } from './control/CubicBezier.svelte'
6
7
  export { default as File } from './control/File.svelte'
7
8
  export { default as Image } from './control/Image.svelte'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte-tweakpane-ui",
3
- "version": "1.5.19",
3
+ "version": "1.6.0-preview.10",
4
4
  "description": "A Svelte component library wrapping UI elements from Tweakpane, plus some additional functionality for convenience and flexibility.",
5
5
  "keywords": [
6
6
  "components",
@@ -70,6 +70,10 @@
70
70
  "types": "./dist/control/Color.svelte.d.ts",
71
71
  "svelte": "./dist/control/Color.svelte"
72
72
  },
73
+ "./ColorPlus.svelte": {
74
+ "types": "./dist/control/ColorPlus.svelte.d.ts",
75
+ "svelte": "./dist/control/ColorPlus.svelte"
76
+ },
73
77
  "./CubicBezier.svelte": {
74
78
  "types": "./dist/control/CubicBezier.svelte.d.ts",
75
79
  "svelte": "./dist/control/CubicBezier.svelte"
@@ -199,7 +203,8 @@
199
203
  "fast-equals": "^6.0.0",
200
204
  "nanoid": "^6.0.0",
201
205
  "svelte-persisted-store": "0.12.0",
202
- "tweakpane": "4.0.5"
206
+ "tweakpane": "4.0.5",
207
+ "tweakpane-plugin-color-plus": "0.5.0"
203
208
  },
204
209
  "devDependencies": {
205
210
  "@kitschpatrol/shared-config": "^8.1.0",
@@ -207,7 +212,7 @@
207
212
  "@playwright/test": "^1.61.1",
208
213
  "@stkb/rewrap": "^0.1.0",
209
214
  "@sveltejs/adapter-static": "^3.0.10",
210
- "@sveltejs/kit": "^2.69.1",
215
+ "@sveltejs/kit": "^2.69.2",
211
216
  "@sveltejs/package": "^2.5.8",
212
217
  "@sveltejs/vite-plugin-svelte": "^3.1.2",
213
218
  "@types/node": "^20.19.43",
@@ -250,7 +255,7 @@
250
255
  "kit-dev": "vite dev",
251
256
  "kit-preview": "vite preview",
252
257
  "lint": "ksc lint --skip repo && svelte-kit sync && svelte-check --tsconfig ./tsconfig.build.json",
253
- "release": "pnpm build && bumpp --commit 'Release: %s' && NPM_AUTH_TOKEN=$(op read 'op://Personal/npm/token') pnpm publish --ignore-scripts",
258
+ "release": "pnpm build && bumpp --preid preview --commit 'Release: %s' && NPM_AUTH_TOKEN=$(op read 'op://Personal/npm/token') pnpm publish --tag preview --ignore-scripts",
254
259
  "rewrap": "rewrap -i --column 100 `find src \\( -name '*.svelte' -o -name '*.ts' -o -name '*.html' \\) -type f | grep -v src/examples`",
255
260
  "test": "pnpm run --sequential /^test:/",
256
261
  "test:integration": "playwright test"
package/readme.md CHANGED
@@ -33,7 +33,7 @@
33
33
 
34
34
  ## Overview
35
35
 
36
- 🎛️ **_Svelte Tweakpane UI_** wraps user-interface elements from the excellent [Tweakpane](https://tweakpane.github.io/docs/) library in a collection of <!-- component-count -->33<!-- /component-count --> idiomatic, reactive, type-safe, carefully-crafted, and obsessively-documented [Svelte](https://svelte.dev) components.
36
+ 🎛️ **_Svelte Tweakpane UI_** wraps user-interface elements from the excellent [Tweakpane](https://tweakpane.github.io/docs/) library in a collection of <!-- component-count -->34<!-- /component-count --> idiomatic, reactive, type-safe, carefully-crafted, and obsessively-documented [Svelte](https://svelte.dev) components.
37
37
 
38
38
  The library makes it easy to quickly and declaratively add knobs and dials to your projects using components that feel like they were made for Svelte. It also augments Tweakpane with a few [extra features](https://kitschpatrol.com/svelte-tweakpane-ui/docs/features) for your convenience and enjoyment.
39
39
 
@@ -99,6 +99,8 @@ npm install svelte-tweakpane-ui
99
99
  A checkbox.
100
100
  - **[Color](https://kitschpatrol.com/svelte-tweakpane-ui/docs/components/color)**\
101
101
  A color picker.
102
+ - **[ColorPlus](https://kitschpatrol.com/svelte-tweakpane-ui/docs/components/colorplus)**\
103
+ A color picker with support for additional color value formats.
102
104
  - **[CubicBezier](https://kitschpatrol.com/svelte-tweakpane-ui/docs/components/cubicbezier)**\
103
105
  A control for editing a bezier curve. Ideal for tweaking animation easing values.
104
106
  - **[File](https://kitschpatrol.com/svelte-tweakpane-ui/docs/components/file)**\