@lavalogic/scoria 0.40.1 → 0.40.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/README.md +58 -58
- package/dist/Components/AccordionGroup.svelte +46 -46
- package/dist/Components/AccordionGroupButton.svelte +76 -76
- package/dist/Components/Action.svelte +136 -136
- package/dist/Components/AlertModal.svelte +195 -195
- package/dist/Components/AppointmentCalendar/AppointmentCalendar.svelte +729 -729
- package/dist/Components/Base/BaseModal.svelte +125 -125
- package/dist/Components/Base/ContextWrapper.svelte +72 -72
- package/dist/Components/Base/Pagination.svelte +198 -198
- package/dist/Components/Base/Snippets.svelte +36 -36
- package/dist/Components/BigRadioSet.svelte +38 -38
- package/dist/Components/Bubble.svelte +101 -101
- package/dist/Components/Button.svelte +209 -209
- package/dist/Components/Checkbox.svelte +86 -86
- package/dist/Components/CollapsibleCard.svelte +78 -78
- package/dist/Components/Contexts/ContextMenu.svelte +164 -164
- package/dist/Components/Contexts/ContextMenuDivider.svelte +15 -15
- package/dist/Components/Contexts/ContextMenuOption.svelte +60 -60
- package/dist/Components/Contexts/Toast.svelte +86 -86
- package/dist/Components/Contexts/ToastContainer.svelte +65 -65
- package/dist/Components/Contexts/Tooltip.svelte +37 -37
- package/dist/Components/DataMatrixIcon.svelte +112 -112
- package/dist/Components/DateInput.svelte +148 -148
- package/dist/Components/DatePicker.svelte +300 -300
- package/dist/Components/DesktopModal.svelte +90 -90
- package/dist/Components/Dial.svelte +204 -204
- package/dist/Components/DimensionInput.svelte +170 -170
- package/dist/Components/DragMenu/DragMenuHolder.svelte +119 -119
- package/dist/Components/DragMenu/DraggableCard.svelte +77 -77
- package/dist/Components/FileCard.svelte +24 -24
- package/dist/Components/FileUpload.svelte +236 -236
- package/dist/Components/GridInput.svelte +196 -196
- package/dist/Components/GridInputSet.svelte +29 -29
- package/dist/Components/HorizontalTabGroup.svelte +82 -82
- package/dist/Components/HorizontalTabGroupButton.svelte +44 -44
- package/dist/Components/Icon.svelte +128 -128
- package/dist/Components/Icons.js +357 -357
- package/dist/Components/InfoAlert.svelte +35 -35
- package/dist/Components/LoadingAnimation.svelte +29 -29
- package/dist/Components/LoadingModal.svelte +45 -45
- package/dist/Components/LoadingOverlay.svelte +25 -25
- package/dist/Components/Modal.svelte +258 -258
- package/dist/Components/MultiSelect.svelte +220 -220
- package/dist/Components/Nav/Nav.svelte +110 -110
- package/dist/Components/Nav/NavServiceMenuList.svelte +43 -43
- package/dist/Components/Nav/NavTab.svelte +62 -62
- package/dist/Components/Nav/ServiceMenuItem.svelte +112 -112
- package/dist/Components/Nav/ServicesNav.svelte +80 -80
- package/dist/Components/NumberInput.svelte +157 -157
- package/dist/Components/PageHeading.svelte +25 -25
- package/dist/Components/PasswordInput.svelte +88 -88
- package/dist/Components/Portal.svelte +36 -36
- package/dist/Components/ProgressBubble.svelte +107 -107
- package/dist/Components/QuerySelect.svelte +366 -366
- package/dist/Components/SingleSelect.svelte +250 -250
- package/dist/Components/StepButton.svelte +70 -70
- package/dist/Components/StepForm.svelte +140 -140
- package/dist/Components/Switch.svelte +69 -69
- package/dist/Components/Table/ARCHITECTURE.md +298 -298
- package/dist/Components/Table/Body/QuickSearchCell.svelte +679 -679
- package/dist/Components/Table/Body/Rows/ColumnHighlight.svelte +51 -51
- package/dist/Components/Table/Body/Rows/ColumnList.svelte +59 -59
- package/dist/Components/Table/Body/Rows/ColumnListRow.svelte +454 -454
- package/dist/Components/Table/Body/Rows/Columns/AccessorComponent.svelte +79 -79
- package/dist/Components/Table/Body/Rows/Columns/ActionsCell.svelte +185 -185
- package/dist/Components/Table/Body/Rows/Columns/BubbleCell.svelte +124 -124
- package/dist/Components/Table/Body/Rows/Columns/ExpandCell.svelte +163 -120
- package/dist/Components/Table/Body/Rows/Columns/FocusableImmutableCell.svelte +234 -234
- package/dist/Components/Table/Body/Rows/Columns/ProgressCell.svelte +105 -105
- package/dist/Components/Table/Body/Rows/Columns/TableAction.svelte +87 -87
- package/dist/Components/Table/Body/Rows/Columns/TableCheckbox.svelte +160 -126
- package/dist/Components/Table/Body/Rows/Columns/TableColumn.svelte +159 -159
- package/dist/Components/Table/Body/Rows/Columns/TableDatePicker.svelte +246 -246
- package/dist/Components/Table/Body/Rows/Columns/TableNumberInput.svelte +216 -216
- package/dist/Components/Table/Body/Rows/Columns/TableQuerySelect.svelte +252 -252
- package/dist/Components/Table/Body/Rows/Columns/TableRowSelectionCheckbox.svelte +179 -179
- package/dist/Components/Table/Body/Rows/Columns/TableSelect.svelte +221 -221
- package/dist/Components/Table/Body/Rows/Columns/TableTextInput.svelte +197 -197
- package/dist/Components/Table/Body/Rows/Columns/ValidityCell.svelte +190 -190
- package/dist/Components/Table/Body/Rows/TableRow.svelte +290 -290
- package/dist/Components/Table/Body/TableBody.svelte +155 -155
- package/dist/Components/Table/ColumnFactory.svelte.js +7 -0
- package/dist/Components/Table/Headers/HighlightAllHeader.svelte +41 -41
- package/dist/Components/Table/Headers/SelectAllHeader.svelte +30 -30
- package/dist/Components/Table/Headers/TableHead.svelte +415 -415
- package/dist/Components/Table/Misc/ColumnPanel.svelte +39 -39
- package/dist/Components/Table/Misc/ColumnPanelModal.svelte +39 -39
- package/dist/Components/Table/Misc/FilterInput.svelte +641 -641
- package/dist/Components/Table/Misc/FilterPanel.svelte +190 -190
- package/dist/Components/Table/Misc/FilterPanelModal.svelte +31 -31
- package/dist/Components/Table/Misc/ShareViewModal.svelte +291 -291
- package/dist/Components/Table/Misc/SidePanel.svelte +35 -35
- package/dist/Components/Table/Misc/TableConfigurationModal.svelte +644 -644
- package/dist/Components/Table/Misc/TableFooter.svelte +340 -340
- package/dist/Components/Table/Misc/TableHorizontalBar.svelte +140 -140
- package/dist/Components/Table/Misc/TableSidebar.svelte +200 -200
- package/dist/Components/Table/Misc/TableViewDropdown.svelte +105 -105
- package/dist/Components/Table/Misc/ToolboxPanel.svelte +100 -100
- package/dist/Components/Table/Misc/ToolboxPanelModal.svelte +107 -107
- package/dist/Components/Table/Misc/UpdateViewOptionsModal.svelte +192 -192
- package/dist/Components/Table/NestedTable.svelte +130 -130
- package/dist/Components/Table/Table.svelte +692 -692
- package/dist/Components/Table/Types/Columns/Definitions/Expand/ExpandDef.svelte.d.ts +9 -0
- package/dist/Components/Table/Types/Columns/Definitions/Expand/ExpandDef.svelte.js +6 -0
- package/dist/Components/Table/Types/Public/ColumnOptions.d.ts +19 -0
- package/dist/Components/Test/TestContextConsumer.svelte +13 -13
- package/dist/Components/TextArea.svelte +130 -130
- package/dist/Components/TextInput.svelte +176 -176
- package/dist/Components/ThreeStateRadio.svelte +131 -131
- package/dist/Components/Touch/BoolCard.svelte +45 -45
- package/dist/Components/Touch/DateModal.svelte +209 -209
- package/dist/Components/Touch/EditCard.svelte +59 -59
- package/dist/Components/Touch/InfoCard.svelte +31 -31
- package/dist/Components/Touch/InfoTextCard.svelte +28 -28
- package/dist/Components/Touch/ModalExplanation.svelte +17 -17
- package/dist/Components/Touch/NumberKeyboard.svelte +225 -225
- package/dist/Components/Touch/NumberModal.svelte +79 -79
- package/dist/Components/Touch/PlusMinusCard.svelte +46 -46
- package/dist/Components/Touch/SelectModal.svelte +127 -127
- package/dist/Components/Touch/SummaryCard.svelte +93 -93
- package/dist/Components/Touch/TextAreaModal.svelte +95 -95
- package/dist/Components/Touch/TextModal.svelte +106 -106
- package/dist/Components/Touch/TouchCard.svelte +33 -33
- package/dist/Components/Touch/TouchModal.svelte +274 -274
- package/dist/Components/Touch/UtilityButton.svelte +109 -109
- package/dist/Components/VerticalTabGroup.svelte +79 -79
- package/dist/Components/VerticalTabGroupButton.svelte +58 -58
- package/dist/Helpers/Datamatrix.d.ts +19 -19
- package/dist/Helpers/Datamatrix.js +291 -291
- package/dist/Types/Examples/ExampleModal.svelte +35 -35
- package/dist/scss/_basics.scss +12 -12
- package/dist/scss/_colours.scss +134 -134
- package/dist/scss/_mixins.scss +3392 -3392
- package/dist/scss/_motion.scss +57 -57
- package/dist/scss/_sizing.scss +85 -85
- package/dist/scss/_transitions.scss +8 -8
- package/package.json +1 -1
|
@@ -13,6 +13,8 @@ import { ColumnDef, type ColumnDefProps } from '../ColumnDef.svelte.js';
|
|
|
13
13
|
export interface ExpandDefProps<T extends object, R extends object, InnerIdType extends Primitive = Primitive, in FilterValueType = unknown> extends ColumnDefProps<T, FilterValueType> {
|
|
14
14
|
/** Per-row enable predicate for the expansion affordance. */
|
|
15
15
|
isEnabled: (item: T, index: number) => boolean | Promise<boolean>;
|
|
16
|
+
/** Per-row predicate for whether the toggle renders at all. */
|
|
17
|
+
isVisible?: (item: T, index: number) => boolean | Promise<boolean>;
|
|
16
18
|
/** Builds the inner table's column defs. Invoked per expansion. */
|
|
17
19
|
getInnerColumnDefs: (item: T, index: number) => DefsWrapper<R>;
|
|
18
20
|
/** Header icon name on the expand-toggle button. */
|
|
@@ -23,6 +25,9 @@ export interface ExpandDefProps<T extends object, R extends object, InnerIdType
|
|
|
23
25
|
innerTableOptions: TableInitOptions<R, InnerIdType>;
|
|
24
26
|
/** Accessor returning the inner-row array for a given outer row. */
|
|
25
27
|
accessorFn: (item: T, index: number) => ReadonlyArray<R> | Promise<ReadonlyArray<R>>;
|
|
28
|
+
/** Navigate-instead-of-expand callback. When set, the toggle invokes
|
|
29
|
+
* this rather than mounting the inner table. */
|
|
30
|
+
onActivate?: (item: T) => void | Promise<void>;
|
|
26
31
|
}
|
|
27
32
|
/**
|
|
28
33
|
* `ExpandDef<T, R, InnerIdType, FilterValueType>` is a column whose
|
|
@@ -46,6 +51,10 @@ export declare class ExpandDef<T extends object, R extends object, InnerIdType e
|
|
|
46
51
|
readonly headerIcon: IconProps['name'];
|
|
47
52
|
/** Per-row enable predicate for the expansion affordance. */
|
|
48
53
|
readonly isEnabled: (item: T, index: number) => boolean | Promise<boolean>;
|
|
54
|
+
/** Per-row predicate for whether the toggle renders at all. */
|
|
55
|
+
readonly isVisible?: (item: T, index: number) => boolean | Promise<boolean>;
|
|
49
56
|
/** Init options for the inner table. */
|
|
50
57
|
readonly innerTableOptions: TableInitOptions<R, InnerIdType>;
|
|
58
|
+
/** Navigate-instead-of-expand callback; undefined for normal expand. */
|
|
59
|
+
readonly onActivate?: (item: T) => void | Promise<void>;
|
|
51
60
|
}
|
|
@@ -16,6 +16,8 @@ export class ExpandDef extends ColumnDef {
|
|
|
16
16
|
this.getInnerColumnDefs = $derived(props.getInnerColumnDefs);
|
|
17
17
|
this.innerTableName = $derived(props.innerTableName);
|
|
18
18
|
this.innerTableOptions = $derived(props.innerTableOptions);
|
|
19
|
+
this.onActivate = $derived(props.onActivate);
|
|
20
|
+
this.isVisible = $derived(props.isVisible);
|
|
19
21
|
}
|
|
20
22
|
/** Expand columns are never filtered. */
|
|
21
23
|
filterFn = undefined;
|
|
@@ -27,6 +29,10 @@ export class ExpandDef extends ColumnDef {
|
|
|
27
29
|
headerIcon;
|
|
28
30
|
/** Per-row enable predicate for the expansion affordance. */
|
|
29
31
|
isEnabled;
|
|
32
|
+
/** Per-row predicate for whether the toggle renders at all. */
|
|
33
|
+
isVisible;
|
|
30
34
|
/** Init options for the inner table. */
|
|
31
35
|
innerTableOptions;
|
|
36
|
+
/** Navigate-instead-of-expand callback; undefined for normal expand. */
|
|
37
|
+
onActivate;
|
|
32
38
|
}
|
|
@@ -377,6 +377,15 @@ export interface ExpandColumnOptions<TRow extends object, TInner extends object,
|
|
|
377
377
|
* inner content. Async supported. Defaults to `() => true`.
|
|
378
378
|
*/
|
|
379
379
|
isEnabled?: (row: TRow, index: number) => boolean | Promise<boolean>;
|
|
380
|
+
/**
|
|
381
|
+
* Per-row predicate for whether the expand affordance renders at all.
|
|
382
|
+
* When it resolves to `false` the toggle is omitted entirely (not just
|
|
383
|
+
* disabled), so rows that can never expand show no icon. Use to surface
|
|
384
|
+
* only the rows that are actually expandable (vs `isEnabled`, which keeps
|
|
385
|
+
* the toggle visible but greyed). Async supported. Defaults to always
|
|
386
|
+
* visible.
|
|
387
|
+
*/
|
|
388
|
+
isVisible?: (row: TRow, index: number) => boolean | Promise<boolean>;
|
|
380
389
|
/**
|
|
381
390
|
* Inner-table configuration. Each field maps 1:1 onto the equivalent
|
|
382
391
|
* `CreateTableOptions` field that configures an outer Table; supply
|
|
@@ -384,6 +393,16 @@ export interface ExpandColumnOptions<TRow extends object, TInner extends object,
|
|
|
384
393
|
* See {@link ExpandInnerTableOptions}.
|
|
385
394
|
*/
|
|
386
395
|
inner?: ExpandInnerTableOptions;
|
|
396
|
+
/**
|
|
397
|
+
* Navigate instead of expand. When provided, clicking the per-row
|
|
398
|
+
* toggle invokes this callback rather than mounting the inner table —
|
|
399
|
+
* the consumer drives a drill-down navigation (e.g. replacing the
|
|
400
|
+
* current view with a related table and pushing a breadcrumb). The
|
|
401
|
+
* inner-table fields (`childRows` / `childColumns` / `childRowId`) are
|
|
402
|
+
* not used in this mode; pass trivial stubs. Useful when nesting could
|
|
403
|
+
* recurse arbitrarily deep and inline panels would starve the layout.
|
|
404
|
+
*/
|
|
405
|
+
onActivate?: (row: TRow) => void | Promise<void>;
|
|
387
406
|
}
|
|
388
407
|
/**
|
|
389
408
|
* Options for `col.filterOnly({ id, header, ... })`. Renders in the filter
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
<svelte:options runes />
|
|
2
|
-
|
|
3
|
-
<script lang="ts">
|
|
4
|
-
import { TestContext } from '../../Contexts/TestContext.svelte.js';
|
|
5
|
-
import { getContext } from 'svelte';
|
|
6
|
-
|
|
7
|
-
const testContext = getContext<TestContext>(TestContext.identifier);
|
|
8
|
-
</script>
|
|
9
|
-
|
|
10
|
-
<h1>counter 1: {testContext.value1.value}</h1>
|
|
11
|
-
<p>Ref wrapper 1 is incremented every time you click the button</p>
|
|
12
|
-
<h2>counter 2: {testContext.value2.value}</h2>
|
|
13
|
-
<p>ref wrapper 2 adds ref wrapper 1's value every time ref wrapper 1's value is divisible by 3</p>
|
|
1
|
+
<svelte:options runes />
|
|
2
|
+
|
|
3
|
+
<script lang="ts">
|
|
4
|
+
import { TestContext } from '../../Contexts/TestContext.svelte.js';
|
|
5
|
+
import { getContext } from 'svelte';
|
|
6
|
+
|
|
7
|
+
const testContext = getContext<TestContext>(TestContext.identifier);
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<h1>counter 1: {testContext.value1.value}</h1>
|
|
11
|
+
<p>Ref wrapper 1 is incremented every time you click the button</p>
|
|
12
|
+
<h2>counter 2: {testContext.value2.value}</h2>
|
|
13
|
+
<p>ref wrapper 2 adds ref wrapper 1's value every time ref wrapper 1's value is divisible by 3</p>
|
|
@@ -1,132 +1,132 @@
|
|
|
1
|
-
<svelte:options runes />
|
|
2
|
-
|
|
3
|
-
<script lang="ts">
|
|
4
|
-
import { cssLength } from '../Helpers/Helpers.svelte.js';
|
|
5
|
-
import { InputVariant } from '../Types/Internal/InputVariant.js';
|
|
6
|
-
import { Size } from '../Types/Internal/Size.js';
|
|
7
|
-
import Icon from './Icon.svelte';
|
|
8
|
-
import type { TextAreaProps } from './TextAreaProps.js';
|
|
9
|
-
|
|
10
|
-
let {
|
|
11
|
-
value = $bindable(''),
|
|
12
|
-
labelTop,
|
|
13
|
-
labelRight,
|
|
14
|
-
placeholder,
|
|
15
|
-
maxWidth = false,
|
|
16
|
-
required = false,
|
|
17
|
-
variant = InputVariant.Default,
|
|
18
|
-
selectNone = false,
|
|
19
|
-
noresize = false,
|
|
20
|
-
uppercase = false,
|
|
21
|
-
disabled,
|
|
22
|
-
invalid = false,
|
|
23
|
-
showErrorColours = true,
|
|
24
|
-
optional = false,
|
|
25
|
-
leftIcon,
|
|
26
|
-
rightIcon,
|
|
27
|
-
onLeftIconClick,
|
|
28
|
-
onRightIconClick,
|
|
29
|
-
rows = 4,
|
|
30
|
-
|
|
31
|
-
textAreaRef = $bindable(),
|
|
32
|
-
autocomplete,
|
|
33
|
-
spellcheck,
|
|
34
|
-
onblur,
|
|
35
|
-
onfocus,
|
|
36
|
-
// No default `onkeydown` - see TextInput.svelte for the rationale.
|
|
37
|
-
// The legacy default (`passthrough`) blurred the textarea on every
|
|
38
|
-
// alphanumeric keystroke and made the field unusable.
|
|
39
|
-
onkeydown,
|
|
40
|
-
oninput,
|
|
41
|
-
}: TextAreaProps = $props();
|
|
42
|
-
|
|
43
|
-
const isInvalid = $derived(showErrorColours && ((required && value.trim() === '') || invalid));
|
|
44
|
-
</script>
|
|
45
|
-
|
|
46
|
-
<label
|
|
47
|
-
class:for-modal={variant === InputVariant.Modal}
|
|
48
|
-
class:max-width={maxWidth}
|
|
49
|
-
>
|
|
50
|
-
{#if labelTop && variant !== InputVariant.Modal}
|
|
51
|
-
<span
|
|
52
|
-
class="top-label"
|
|
53
|
-
class:for-default={variant === InputVariant.Default}
|
|
54
|
-
class:invalid={isInvalid}
|
|
55
|
-
>{labelTop}{#if optional}<i> - optional</i>{/if}</span
|
|
56
|
-
>
|
|
57
|
-
{#if variant === InputVariant.Default}
|
|
58
|
-
<span
|
|
59
|
-
aria-hidden="true"
|
|
60
|
-
class="border"
|
|
61
|
-
class:invalid={isInvalid}
|
|
62
|
-
>{labelTop}{#if optional}<i> - optional</i>{/if}</span
|
|
63
|
-
>
|
|
64
|
-
{/if}
|
|
65
|
-
{/if}
|
|
66
|
-
<div
|
|
67
|
-
class="icon-container"
|
|
68
|
-
class:for-modal={variant == InputVariant.Modal}
|
|
69
|
-
>
|
|
70
|
-
{#if leftIcon}
|
|
71
|
-
<Icon
|
|
72
|
-
name={leftIcon.name}
|
|
73
|
-
size={leftIcon.size ?? Size.Medium}
|
|
74
|
-
colour={leftIcon.colour}
|
|
75
|
-
float
|
|
76
|
-
left={cssLength('0.75rem')}
|
|
77
|
-
top={cssLength('50%')}
|
|
78
|
-
anchorX={cssLength('0')}
|
|
79
|
-
anchorY={cssLength('-50%')}
|
|
80
|
-
clickable={!!onLeftIconClick}
|
|
81
|
-
onclick={onLeftIconClick}
|
|
82
|
-
/>
|
|
83
|
-
{/if}
|
|
84
|
-
<textarea
|
|
85
|
-
class:noresize
|
|
86
|
-
class:uppercase
|
|
87
|
-
class:invalid={isInvalid}
|
|
88
|
-
class:select-none={selectNone}
|
|
89
|
-
class:left-pad={leftIcon != undefined}
|
|
90
|
-
class:right-pad={rightIcon != undefined}
|
|
91
|
-
class:for-modal={variant == InputVariant.Modal}
|
|
92
|
-
class:max-width={maxWidth}
|
|
93
|
-
autocomplete={autocomplete ?? 'off'}
|
|
94
|
-
spellcheck={spellcheck ?? true}
|
|
95
|
-
aria-invalid={isInvalid || undefined}
|
|
96
|
-
bind:value
|
|
97
|
-
{onblur}
|
|
98
|
-
{onfocus}
|
|
99
|
-
{onkeydown}
|
|
100
|
-
{oninput}
|
|
101
|
-
{rows}
|
|
102
|
-
bind:this={textAreaRef}
|
|
103
|
-
{placeholder}
|
|
104
|
-
{required}
|
|
105
|
-
{disabled}
|
|
106
|
-
></textarea>
|
|
107
|
-
{#if rightIcon}
|
|
108
|
-
<Icon
|
|
109
|
-
name={rightIcon.name}
|
|
110
|
-
size={rightIcon.size ?? Size.Medium}
|
|
111
|
-
colour={rightIcon.colour}
|
|
112
|
-
float
|
|
113
|
-
right={cssLength(variant == InputVariant.Modal ? '1rem' : '0.5rem')}
|
|
114
|
-
top={cssLength('50%')}
|
|
115
|
-
anchorX={cssLength('0')}
|
|
116
|
-
anchorY={cssLength('-50%')}
|
|
117
|
-
clickable={!!onRightIconClick}
|
|
118
|
-
onclick={onRightIconClick}
|
|
119
|
-
/>
|
|
120
|
-
{/if}
|
|
121
|
-
{#if labelRight}
|
|
122
|
-
<span
|
|
123
|
-
class="right-label"
|
|
124
|
-
class:for-modal={variant == InputVariant.Modal}>{labelRight}</span
|
|
125
|
-
>
|
|
126
|
-
{/if}
|
|
127
|
-
</div>
|
|
128
|
-
</label>
|
|
129
|
-
|
|
1
|
+
<svelte:options runes />
|
|
2
|
+
|
|
3
|
+
<script lang="ts">
|
|
4
|
+
import { cssLength } from '../Helpers/Helpers.svelte.js';
|
|
5
|
+
import { InputVariant } from '../Types/Internal/InputVariant.js';
|
|
6
|
+
import { Size } from '../Types/Internal/Size.js';
|
|
7
|
+
import Icon from './Icon.svelte';
|
|
8
|
+
import type { TextAreaProps } from './TextAreaProps.js';
|
|
9
|
+
|
|
10
|
+
let {
|
|
11
|
+
value = $bindable(''),
|
|
12
|
+
labelTop,
|
|
13
|
+
labelRight,
|
|
14
|
+
placeholder,
|
|
15
|
+
maxWidth = false,
|
|
16
|
+
required = false,
|
|
17
|
+
variant = InputVariant.Default,
|
|
18
|
+
selectNone = false,
|
|
19
|
+
noresize = false,
|
|
20
|
+
uppercase = false,
|
|
21
|
+
disabled,
|
|
22
|
+
invalid = false,
|
|
23
|
+
showErrorColours = true,
|
|
24
|
+
optional = false,
|
|
25
|
+
leftIcon,
|
|
26
|
+
rightIcon,
|
|
27
|
+
onLeftIconClick,
|
|
28
|
+
onRightIconClick,
|
|
29
|
+
rows = 4,
|
|
30
|
+
|
|
31
|
+
textAreaRef = $bindable(),
|
|
32
|
+
autocomplete,
|
|
33
|
+
spellcheck,
|
|
34
|
+
onblur,
|
|
35
|
+
onfocus,
|
|
36
|
+
// No default `onkeydown` - see TextInput.svelte for the rationale.
|
|
37
|
+
// The legacy default (`passthrough`) blurred the textarea on every
|
|
38
|
+
// alphanumeric keystroke and made the field unusable.
|
|
39
|
+
onkeydown,
|
|
40
|
+
oninput,
|
|
41
|
+
}: TextAreaProps = $props();
|
|
42
|
+
|
|
43
|
+
const isInvalid = $derived(showErrorColours && ((required && value.trim() === '') || invalid));
|
|
44
|
+
</script>
|
|
45
|
+
|
|
46
|
+
<label
|
|
47
|
+
class:for-modal={variant === InputVariant.Modal}
|
|
48
|
+
class:max-width={maxWidth}
|
|
49
|
+
>
|
|
50
|
+
{#if labelTop && variant !== InputVariant.Modal}
|
|
51
|
+
<span
|
|
52
|
+
class="top-label"
|
|
53
|
+
class:for-default={variant === InputVariant.Default}
|
|
54
|
+
class:invalid={isInvalid}
|
|
55
|
+
>{labelTop}{#if optional}<i> - optional</i>{/if}</span
|
|
56
|
+
>
|
|
57
|
+
{#if variant === InputVariant.Default}
|
|
58
|
+
<span
|
|
59
|
+
aria-hidden="true"
|
|
60
|
+
class="border"
|
|
61
|
+
class:invalid={isInvalid}
|
|
62
|
+
>{labelTop}{#if optional}<i> - optional</i>{/if}</span
|
|
63
|
+
>
|
|
64
|
+
{/if}
|
|
65
|
+
{/if}
|
|
66
|
+
<div
|
|
67
|
+
class="icon-container"
|
|
68
|
+
class:for-modal={variant == InputVariant.Modal}
|
|
69
|
+
>
|
|
70
|
+
{#if leftIcon}
|
|
71
|
+
<Icon
|
|
72
|
+
name={leftIcon.name}
|
|
73
|
+
size={leftIcon.size ?? Size.Medium}
|
|
74
|
+
colour={leftIcon.colour}
|
|
75
|
+
float
|
|
76
|
+
left={cssLength('0.75rem')}
|
|
77
|
+
top={cssLength('50%')}
|
|
78
|
+
anchorX={cssLength('0')}
|
|
79
|
+
anchorY={cssLength('-50%')}
|
|
80
|
+
clickable={!!onLeftIconClick}
|
|
81
|
+
onclick={onLeftIconClick}
|
|
82
|
+
/>
|
|
83
|
+
{/if}
|
|
84
|
+
<textarea
|
|
85
|
+
class:noresize
|
|
86
|
+
class:uppercase
|
|
87
|
+
class:invalid={isInvalid}
|
|
88
|
+
class:select-none={selectNone}
|
|
89
|
+
class:left-pad={leftIcon != undefined}
|
|
90
|
+
class:right-pad={rightIcon != undefined}
|
|
91
|
+
class:for-modal={variant == InputVariant.Modal}
|
|
92
|
+
class:max-width={maxWidth}
|
|
93
|
+
autocomplete={autocomplete ?? 'off'}
|
|
94
|
+
spellcheck={spellcheck ?? true}
|
|
95
|
+
aria-invalid={isInvalid || undefined}
|
|
96
|
+
bind:value
|
|
97
|
+
{onblur}
|
|
98
|
+
{onfocus}
|
|
99
|
+
{onkeydown}
|
|
100
|
+
{oninput}
|
|
101
|
+
{rows}
|
|
102
|
+
bind:this={textAreaRef}
|
|
103
|
+
{placeholder}
|
|
104
|
+
{required}
|
|
105
|
+
{disabled}
|
|
106
|
+
></textarea>
|
|
107
|
+
{#if rightIcon}
|
|
108
|
+
<Icon
|
|
109
|
+
name={rightIcon.name}
|
|
110
|
+
size={rightIcon.size ?? Size.Medium}
|
|
111
|
+
colour={rightIcon.colour}
|
|
112
|
+
float
|
|
113
|
+
right={cssLength(variant == InputVariant.Modal ? '1rem' : '0.5rem')}
|
|
114
|
+
top={cssLength('50%')}
|
|
115
|
+
anchorX={cssLength('0')}
|
|
116
|
+
anchorY={cssLength('-50%')}
|
|
117
|
+
clickable={!!onRightIconClick}
|
|
118
|
+
onclick={onRightIconClick}
|
|
119
|
+
/>
|
|
120
|
+
{/if}
|
|
121
|
+
{#if labelRight}
|
|
122
|
+
<span
|
|
123
|
+
class="right-label"
|
|
124
|
+
class:for-modal={variant == InputVariant.Modal}>{labelRight}</span
|
|
125
|
+
>
|
|
126
|
+
{/if}
|
|
127
|
+
</div>
|
|
128
|
+
</label>
|
|
129
|
+
|
|
130
130
|
<style>textarea {
|
|
131
131
|
box-sizing: border-box;
|
|
132
132
|
height: 100%;
|
|
@@ -340,4 +340,4 @@ span.border.invalid {
|
|
|
340
340
|
.textarea-error-wrapper.for-modal {
|
|
341
341
|
position: relative;
|
|
342
342
|
height: 100%;
|
|
343
|
-
}</style>
|
|
343
|
+
}</style>
|