@streamscloud/kit 0.10.1 → 0.10.3
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/dist/ui/page-toolbar/cmp.toolbar-value-stepper.svelte +84 -0
- package/dist/ui/page-toolbar/cmp.toolbar-value-stepper.svelte.d.ts +30 -0
- package/dist/ui/page-toolbar/index.d.ts +1 -0
- package/dist/ui/page-toolbar/index.js +1 -0
- package/dist/ui/page-toolbar/toolbar-value-stepper-localization.d.ts +5 -0
- package/dist/ui/page-toolbar/toolbar-value-stepper-localization.js +26 -0
- package/dist/ui/table/cmp.table.svelte +9 -1
- package/package.json +1 -1
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
<script lang="ts">import { Icon } from '../icon';
|
|
2
|
+
import { ToolbarValueStepperLocalization } from './toolbar-value-stepper-localization';
|
|
3
|
+
import IconChevronLeft from '@fluentui/svg-icons/icons/chevron_left_16_regular.svg?raw';
|
|
4
|
+
import IconChevronRight from '@fluentui/svg-icons/icons/chevron_right_16_regular.svg?raw';
|
|
5
|
+
const { value, min = 0, max = 100, step = 1, valueSuffix = '', size = 'sm', on } = $props();
|
|
6
|
+
const localization = new ToolbarValueStepperLocalization();
|
|
7
|
+
const atMin = $derived(value <= min);
|
|
8
|
+
const atMax = $derived(value >= max);
|
|
9
|
+
const decrease = () => {
|
|
10
|
+
on?.change?.(Math.max(min, value - step));
|
|
11
|
+
};
|
|
12
|
+
const increase = () => {
|
|
13
|
+
on?.change?.(Math.min(max, value + step));
|
|
14
|
+
};
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<div class="toolbar-value-stepper toolbar-value-stepper--{size}" role="group" aria-label={localization.value}>
|
|
18
|
+
<button type="button" class="toolbar-value-stepper__btn" onclick={decrease} disabled={atMin} aria-label={localization.decreaseValue}>
|
|
19
|
+
<Icon src={IconChevronLeft} />
|
|
20
|
+
</button>
|
|
21
|
+
<span class="toolbar-value-stepper__value">{value}{valueSuffix}</span>
|
|
22
|
+
<button type="button" class="toolbar-value-stepper__btn" onclick={increase} disabled={atMax} aria-label={localization.increaseValue}>
|
|
23
|
+
<Icon src={IconChevronRight} />
|
|
24
|
+
</button>
|
|
25
|
+
</div>
|
|
26
|
+
|
|
27
|
+
<!--
|
|
28
|
+
@component
|
|
29
|
+
A compact `[<] value [>]` stepper for toolbars — increment / decrement a numeric value between `min`
|
|
30
|
+
and `max` by `step`, with an optional `valueSuffix` (e.g. ` %`). Bound arrows disable at the limits.
|
|
31
|
+
Shares the field-height preset so it lines up with other toolbar controls.
|
|
32
|
+
|
|
33
|
+
### CSS Custom Properties
|
|
34
|
+
| Property | Description | Default |
|
|
35
|
+
|---|---|---|
|
|
36
|
+
| `--sc-kit--toolbar-value-stepper--value--min-inline-size` | Min width of the value readout (keeps arrows from shifting) | `2.25rem` |
|
|
37
|
+
| `--sc-kit--toolbar-value-stepper--icon--color` | Arrow icon color | `var(--sc-kit--color--accent)` |
|
|
38
|
+
-->
|
|
39
|
+
|
|
40
|
+
<style>.toolbar-value-stepper {
|
|
41
|
+
--_toolbar-value-stepper--value--min-inline-size: var(--sc-kit--toolbar-value-stepper--value--min-inline-size, 2.25rem);
|
|
42
|
+
--_toolbar-value-stepper--icon--color: var(--sc-kit--toolbar-value-stepper--icon--color, var(--sc-kit--color--accent));
|
|
43
|
+
--sc-kit--icon--color: var(--_toolbar-value-stepper--icon--color);
|
|
44
|
+
display: inline-flex;
|
|
45
|
+
align-items: center;
|
|
46
|
+
gap: var(--sc-kit--space--1);
|
|
47
|
+
block-size: var(--_toolbar-value-stepper--height);
|
|
48
|
+
padding-inline: var(--sc-kit--space--2);
|
|
49
|
+
border: 1px solid var(--sc-kit--color--border--field);
|
|
50
|
+
border-radius: var(--sc-kit--radius--md);
|
|
51
|
+
background: var(--sc-kit--color--bg--field);
|
|
52
|
+
}
|
|
53
|
+
.toolbar-value-stepper--sm {
|
|
54
|
+
--_toolbar-value-stepper--height: var(--sc-kit--field--height--sm);
|
|
55
|
+
--_toolbar-value-stepper--font-size: var(--sc-kit--font-size--sm);
|
|
56
|
+
}
|
|
57
|
+
.toolbar-value-stepper--md {
|
|
58
|
+
--_toolbar-value-stepper--height: var(--sc-kit--field--height--md);
|
|
59
|
+
--_toolbar-value-stepper--font-size: var(--sc-kit--font-size--md);
|
|
60
|
+
}
|
|
61
|
+
.toolbar-value-stepper--lg {
|
|
62
|
+
--_toolbar-value-stepper--height: var(--sc-kit--field--height--lg);
|
|
63
|
+
--_toolbar-value-stepper--font-size: var(--sc-kit--font-size--lg);
|
|
64
|
+
}
|
|
65
|
+
.toolbar-value-stepper__btn {
|
|
66
|
+
display: inline-flex;
|
|
67
|
+
align-items: center;
|
|
68
|
+
padding-inline: var(--sc-kit--space--1);
|
|
69
|
+
border: 0;
|
|
70
|
+
background: none;
|
|
71
|
+
cursor: pointer;
|
|
72
|
+
transition: opacity var(--sc-kit--duration--base) var(--sc-kit--ease--default);
|
|
73
|
+
}
|
|
74
|
+
.toolbar-value-stepper__btn:disabled {
|
|
75
|
+
cursor: default;
|
|
76
|
+
opacity: 0.4;
|
|
77
|
+
}
|
|
78
|
+
.toolbar-value-stepper__value {
|
|
79
|
+
min-inline-size: var(--_toolbar-value-stepper--value--min-inline-size);
|
|
80
|
+
text-align: center;
|
|
81
|
+
font-size: var(--_toolbar-value-stepper--font-size);
|
|
82
|
+
color: var(--sc-kit--color--text--primary);
|
|
83
|
+
font-variant-numeric: tabular-nums;
|
|
84
|
+
}</style>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
type Props = {
|
|
2
|
+
value: number;
|
|
3
|
+
/** @default 0 */
|
|
4
|
+
min?: number;
|
|
5
|
+
/** @default 100 */
|
|
6
|
+
max?: number;
|
|
7
|
+
/** @default 1 */
|
|
8
|
+
step?: number;
|
|
9
|
+
/** Suffix appended to the displayed value (e.g. ' %'). @default '' */
|
|
10
|
+
valueSuffix?: string;
|
|
11
|
+
/** Size preset (shared with Input / DatePicker / Select). @default 'sm' */
|
|
12
|
+
size?: 'sm' | 'md' | 'lg';
|
|
13
|
+
on?: {
|
|
14
|
+
change?: (value: number) => void;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* A compact `[<] value [>]` stepper for toolbars — increment / decrement a numeric value between `min`
|
|
19
|
+
* and `max` by `step`, with an optional `valueSuffix` (e.g. ` %`). Bound arrows disable at the limits.
|
|
20
|
+
* Shares the field-height preset so it lines up with other toolbar controls.
|
|
21
|
+
*
|
|
22
|
+
* ### CSS Custom Properties
|
|
23
|
+
* | Property | Description | Default |
|
|
24
|
+
* |---|---|---|
|
|
25
|
+
* | `--sc-kit--toolbar-value-stepper--value--min-inline-size` | Min width of the value readout (keeps arrows from shifting) | `2.25rem` |
|
|
26
|
+
* | `--sc-kit--toolbar-value-stepper--icon--color` | Arrow icon color | `var(--sc-kit--color--accent)` |
|
|
27
|
+
*/
|
|
28
|
+
declare const Cmp: import("svelte").Component<Props, {}, "">;
|
|
29
|
+
type Cmp = ReturnType<typeof Cmp>;
|
|
30
|
+
export default Cmp;
|
|
@@ -7,4 +7,5 @@ export { default as ToolbarSearchInput } from './cmp.toolbar-search-input.svelte
|
|
|
7
7
|
export { default as ToolbarSegmentedControl } from './cmp.toolbar-segmented-control.svelte';
|
|
8
8
|
export { default as ToolbarSwitchItem } from './cmp.toolbar-switch-item.svelte';
|
|
9
9
|
export { default as ToolbarToggleItem } from './cmp.toolbar-toggle-item.svelte';
|
|
10
|
+
export { default as ToolbarValueStepper } from './cmp.toolbar-value-stepper.svelte';
|
|
10
11
|
export type { ReorderableToggleItem } from './types';
|
|
@@ -7,3 +7,4 @@ export { default as ToolbarSearchInput } from './cmp.toolbar-search-input.svelte
|
|
|
7
7
|
export { default as ToolbarSegmentedControl } from './cmp.toolbar-segmented-control.svelte';
|
|
8
8
|
export { default as ToolbarSwitchItem } from './cmp.toolbar-switch-item.svelte';
|
|
9
9
|
export { default as ToolbarToggleItem } from './cmp.toolbar-toggle-item.svelte';
|
|
10
|
+
export { default as ToolbarValueStepper } from './cmp.toolbar-value-stepper.svelte';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { AppLocale } from '../../core/locale';
|
|
2
|
+
const loc = {
|
|
3
|
+
value: {
|
|
4
|
+
en: 'Value',
|
|
5
|
+
no: 'Verdi'
|
|
6
|
+
},
|
|
7
|
+
decreaseValue: {
|
|
8
|
+
en: 'Decrease value',
|
|
9
|
+
no: 'Reduser verdi'
|
|
10
|
+
},
|
|
11
|
+
increaseValue: {
|
|
12
|
+
en: 'Increase value',
|
|
13
|
+
no: 'Øk verdi'
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
export class ToolbarValueStepperLocalization {
|
|
17
|
+
get value() {
|
|
18
|
+
return loc.value[AppLocale.current];
|
|
19
|
+
}
|
|
20
|
+
get decreaseValue() {
|
|
21
|
+
return loc.decreaseValue[AppLocale.current];
|
|
22
|
+
}
|
|
23
|
+
get increaseValue() {
|
|
24
|
+
return loc.increaseValue[AppLocale.current];
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -150,7 +150,15 @@ const getEditorColumnOrDefault = (column, editMode) => {
|
|
|
150
150
|
</tr>
|
|
151
151
|
</thead>
|
|
152
152
|
<tbody
|
|
153
|
-
use:dndzone={{
|
|
153
|
+
use:dndzone={{
|
|
154
|
+
items: model.items,
|
|
155
|
+
dragDisabled: !rowsDraggable,
|
|
156
|
+
dropFromOthersDisabled: true,
|
|
157
|
+
flipDurationMs,
|
|
158
|
+
dropTargetStyle: {},
|
|
159
|
+
transformDraggedElement,
|
|
160
|
+
type: 'table'
|
|
161
|
+
}}
|
|
154
162
|
onconsider={handleConsider}
|
|
155
163
|
onfinalize={handleFinalize}>
|
|
156
164
|
{#if showPlaceholder || showNoItemsPlaceholder}
|