@0djek/sveltix 0.0.6
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 +103 -0
- package/dist/button/Button.svelte +24 -0
- package/dist/button/Button.svelte.d.ts +4 -0
- package/dist/button/ButtonComponent.svelte.d.ts +15 -0
- package/dist/button/ButtonComponent.svelte.js +26 -0
- package/dist/button/ButtonStyles.d.ts +11 -0
- package/dist/button/ButtonStyles.js +2 -0
- package/dist/button/__tests__/builders/ButtonBuilder.d.ts +23 -0
- package/dist/button/__tests__/builders/ButtonBuilder.js +61 -0
- package/dist/button/__tests__/builders/ButtonStory.svelte +27 -0
- package/dist/button/__tests__/builders/ButtonStory.svelte.d.ts +14 -0
- package/dist/button/__tests__/pom/ButtonPom.d.ts +6 -0
- package/dist/button/__tests__/pom/ButtonPom.js +14 -0
- package/dist/button/buttonDefaults.d.ts +9 -0
- package/dist/button/buttonDefaults.js +9 -0
- package/dist/button/index.d.ts +5 -0
- package/dist/button/index.js +9 -0
- package/dist/button/internal/DefaultButtonStyles.d.ts +15 -0
- package/dist/button/internal/DefaultButtonStyles.js +64 -0
- package/dist/button/models/ButtonProps.d.ts +45 -0
- package/dist/button/models/ButtonProps.js +1 -0
- package/dist/button/models/ButtonSize.d.ts +6 -0
- package/dist/button/models/ButtonSize.js +7 -0
- package/dist/button/models/ButtonVariant.d.ts +5 -0
- package/dist/button/models/ButtonVariant.js +6 -0
- package/dist/button/models/index.d.ts +3 -0
- package/dist/button/models/index.js +3 -0
- package/dist/cache/Cache.d.ts +18 -0
- package/dist/cache/Cache.js +20 -0
- package/dist/cache/MappedCache.d.ts +7 -0
- package/dist/cache/MappedCache.js +35 -0
- package/dist/cache/__tests__/builders/CacheBuilder.d.ts +7 -0
- package/dist/cache/__tests__/builders/CacheBuilder.js +18 -0
- package/dist/cache/__tests__/builders/MappedCacheBuilder.d.ts +7 -0
- package/dist/cache/__tests__/builders/MappedCacheBuilder.js +18 -0
- package/dist/cache/index.d.ts +2 -0
- package/dist/cache/index.js +2 -0
- package/dist/datagrid/SveltixGrid.svelte.d.ts +35 -0
- package/dist/datagrid/SveltixGrid.svelte.js +90 -0
- package/dist/datagrid/SveltixGridGlobal.d.ts +9 -0
- package/dist/datagrid/SveltixGridGlobal.js +12 -0
- package/dist/datagrid/components/Datagrid.svelte +114 -0
- package/dist/datagrid/components/Datagrid.svelte.d.ts +39 -0
- package/dist/datagrid/core-modules/columns/Column.svelte.d.ts +79 -0
- package/dist/datagrid/core-modules/columns/Column.svelte.js +322 -0
- package/dist/datagrid/core-modules/columns/ColumnsModule.svelte.d.ts +26 -0
- package/dist/datagrid/core-modules/columns/ColumnsModule.svelte.js +77 -0
- package/dist/datagrid/core-modules/columns/components/CalculateCellWidth.svelte +18 -0
- package/dist/datagrid/core-modules/columns/components/CalculateCellWidth.svelte.d.ts +25 -0
- package/dist/datagrid/core-modules/columns/index.d.ts +5 -0
- package/dist/datagrid/core-modules/columns/index.js +11 -0
- package/dist/datagrid/core-modules/columns/models/ColumnOptions.d.ts +2 -0
- package/dist/datagrid/core-modules/columns/models/ColumnOptions.js +1 -0
- package/dist/datagrid/core-modules/custom/CustomComponentsModule.svelte.d.ts +27 -0
- package/dist/datagrid/core-modules/custom/CustomComponentsModule.svelte.js +58 -0
- package/dist/datagrid/core-modules/custom/components/CustomComponents.svelte +36 -0
- package/dist/datagrid/core-modules/custom/components/CustomComponents.svelte.d.ts +30 -0
- package/dist/datagrid/core-modules/custom/index.d.ts +3 -0
- package/dist/datagrid/core-modules/custom/index.js +10 -0
- package/dist/datagrid/core-modules/custom/models/CustomComponentPosition.d.ts +21 -0
- package/dist/datagrid/core-modules/custom/models/CustomComponentPosition.js +22 -0
- package/dist/datagrid/core-modules/index.d.ts +4 -0
- package/dist/datagrid/core-modules/index.js +4 -0
- package/dist/datagrid/core-modules/pipelines/PipelinesModule.svelte.d.ts +12 -0
- package/dist/datagrid/core-modules/pipelines/PipelinesModule.svelte.js +58 -0
- package/dist/datagrid/core-modules/pipelines/index.d.ts +4 -0
- package/dist/datagrid/core-modules/pipelines/index.js +11 -0
- package/dist/datagrid/core-modules/pipelines/models/CallbackSignature.d.ts +9 -0
- package/dist/datagrid/core-modules/pipelines/models/CallbackSignature.js +1 -0
- package/dist/datagrid/core-modules/rows/Cell.svelte.d.ts +27 -0
- package/dist/datagrid/core-modules/rows/Cell.svelte.js +103 -0
- package/dist/datagrid/core-modules/rows/Row.svelte.d.ts +24 -0
- package/dist/datagrid/core-modules/rows/Row.svelte.js +117 -0
- package/dist/datagrid/core-modules/rows/RowsModule.svelte.d.ts +33 -0
- package/dist/datagrid/core-modules/rows/RowsModule.svelte.js +115 -0
- package/dist/datagrid/core-modules/rows/components/body/BodyCell.svelte +31 -0
- package/dist/datagrid/core-modules/rows/components/body/BodyCell.svelte.d.ts +30 -0
- package/dist/datagrid/core-modules/rows/components/body/GroupCell.svelte +26 -0
- package/dist/datagrid/core-modules/rows/components/body/GroupCell.svelte.d.ts +25 -0
- package/dist/datagrid/core-modules/rows/index.d.ts +8 -0
- package/dist/datagrid/core-modules/rows/index.js +13 -0
- package/dist/datagrid/core-modules/rows/internal/CreateRowOptions.d.ts +15 -0
- package/dist/datagrid/core-modules/rows/internal/CreateRowOptions.js +1 -0
- package/dist/datagrid/core-modules/rows/models/RowsOptions.d.ts +3 -0
- package/dist/datagrid/core-modules/rows/models/RowsOptions.js +1 -0
- package/dist/datagrid/core-modules/rows/models/index.d.ts +1 -0
- package/dist/datagrid/core-modules/rows/models/index.js +1 -0
- package/dist/datagrid/events/generateEvents.d.ts +2 -0
- package/dist/datagrid/events/generateEvents.js +16 -0
- package/dist/datagrid/events/index.d.ts +2 -0
- package/dist/datagrid/events/index.js +2 -0
- package/dist/datagrid/events/models/RowUpdatedArgs.d.ts +5 -0
- package/dist/datagrid/events/models/RowUpdatedArgs.js +1 -0
- package/dist/datagrid/events/models/SveltixEvents.d.ts +20 -0
- package/dist/datagrid/events/models/SveltixEvents.js +1 -0
- package/dist/datagrid/events/models/index.d.ts +2 -0
- package/dist/datagrid/events/models/index.js +2 -0
- package/dist/datagrid/index.d.ts +5 -0
- package/dist/datagrid/index.js +5 -0
- package/dist/datagrid/interfaces/ISveltixGrid.d.ts +22 -0
- package/dist/datagrid/interfaces/ISveltixGrid.js +1 -0
- package/dist/datagrid/interfaces/Module.d.ts +11 -0
- package/dist/datagrid/interfaces/Module.js +13 -0
- package/dist/datagrid/interfaces/index.d.ts +2 -0
- package/dist/datagrid/interfaces/index.js +2 -0
- package/dist/datagrid/models/BaseColumn.d.ts +23 -0
- package/dist/datagrid/models/BaseColumn.js +1 -0
- package/dist/datagrid/models/Formatter.d.ts +32 -0
- package/dist/datagrid/models/Formatter.js +7 -0
- package/dist/datagrid/models/SveltixGridOptions.d.ts +12 -0
- package/dist/datagrid/models/SveltixGridOptions.js +1 -0
- package/dist/datagrid/models/Value.d.ts +21 -0
- package/dist/datagrid/models/Value.js +6 -0
- package/dist/datagrid/models/index.d.ts +4 -0
- package/dist/datagrid/models/index.js +4 -0
- package/dist/datagrid/models/module/ModuleConstructor.d.ts +5 -0
- package/dist/datagrid/models/module/ModuleConstructor.js +1 -0
- package/dist/datagrid/models/module/ModuleRegistrationEntry.d.ts +6 -0
- package/dist/datagrid/models/module/ModuleRegistrationEntry.js +1 -0
- package/dist/datagrid/models/module/index.d.ts +2 -0
- package/dist/datagrid/models/module/index.js +2 -0
- package/dist/datagrid/modules/flash/FlashModule.svelte.d.ts +9 -0
- package/dist/datagrid/modules/flash/FlashModule.svelte.js +33 -0
- package/dist/datagrid/modules/flash/index.d.ts +5 -0
- package/dist/datagrid/modules/flash/index.js +10 -0
- package/dist/datagrid/modules/flash/models/FlashModuleOptions.d.ts +4 -0
- package/dist/datagrid/modules/flash/models/FlashModuleOptions.js +1 -0
- package/dist/datagrid/modules/flash/models/index.d.ts +1 -0
- package/dist/datagrid/modules/flash/models/index.js +1 -0
- package/dist/datagrid/modules/resize/ResizeModule.svelte.d.ts +14 -0
- package/dist/datagrid/modules/resize/ResizeModule.svelte.js +68 -0
- package/dist/datagrid/modules/resize/components/ResizeCustomComponent.svelte +15 -0
- package/dist/datagrid/modules/resize/components/ResizeCustomComponent.svelte.d.ts +25 -0
- package/dist/datagrid/modules/resize/components/ResizeHandle.svelte +29 -0
- package/dist/datagrid/modules/resize/components/ResizeHandle.svelte.d.ts +28 -0
- package/dist/datagrid/modules/resize/index.d.ts +5 -0
- package/dist/datagrid/modules/resize/index.js +12 -0
- package/dist/datagrid/modules/resize/models/ResizeModuleOptions.d.ts +15 -0
- package/dist/datagrid/modules/resize/models/ResizeModuleOptions.js +1 -0
- package/dist/datagrid/modules/resize/models/index.d.ts +1 -0
- package/dist/datagrid/modules/resize/models/index.js +1 -0
- package/dist/deep-equal/deepEqual.d.ts +7 -0
- package/dist/deep-equal/deepEqual.js +79 -0
- package/dist/deep-equal/index.d.ts +1 -0
- package/dist/deep-equal/index.js +1 -0
- package/dist/di/DiContainer.d.ts +20 -0
- package/dist/di/DiContainer.js +42 -0
- package/dist/event-bus/EventBus.d.ts +9 -0
- package/dist/event-bus/EventBus.js +38 -0
- package/dist/event-bus/createEventDefinition.d.ts +1 -0
- package/dist/event-bus/createEventDefinition.js +5 -0
- package/dist/event-bus/index.d.ts +3 -0
- package/dist/event-bus/index.js +3 -0
- package/dist/event-bus/models/Event.d.ts +6 -0
- package/dist/event-bus/models/Event.js +1 -0
- package/dist/event-bus/models/SubscriberEntry.d.ts +5 -0
- package/dist/event-bus/models/SubscriberEntry.js +1 -0
- package/dist/event-bus/models/SubscriberSignature.d.ts +3 -0
- package/dist/event-bus/models/SubscriberSignature.js +1 -0
- package/dist/event-bus/models/UnsubscribeSignature.d.ts +3 -0
- package/dist/event-bus/models/UnsubscribeSignature.js +1 -0
- package/dist/event-bus/models/index.d.ts +4 -0
- package/dist/event-bus/models/index.js +4 -0
- package/dist/groupBy/groupBy.d.ts +2 -0
- package/dist/groupBy/groupBy.js +22 -0
- package/dist/groupBy/index.d.ts +2 -0
- package/dist/groupBy/index.js +2 -0
- package/dist/groupBy/models/Grouping.d.ts +4 -0
- package/dist/groupBy/models/Grouping.js +1 -0
- package/dist/groupBy/models/index.d.ts +1 -0
- package/dist/groupBy/models/index.js +1 -0
- package/dist/heading/Heading.svelte +28 -0
- package/dist/heading/Heading.svelte.d.ts +4 -0
- package/dist/heading/HeadingComponent.svelte.d.ts +13 -0
- package/dist/heading/HeadingComponent.svelte.js +20 -0
- package/dist/heading/HeadingStyles.d.ts +11 -0
- package/dist/heading/HeadingStyles.js +1 -0
- package/dist/heading/__tests__/HeadingBuilder.d.ts +12 -0
- package/dist/heading/__tests__/HeadingBuilder.js +34 -0
- package/dist/heading/__tests__/HeadingStory.svelte +16 -0
- package/dist/heading/__tests__/HeadingStory.svelte.d.ts +10 -0
- package/dist/heading/headingClasses.d.ts +8 -0
- package/dist/heading/headingClasses.js +8 -0
- package/dist/heading/index.d.ts +5 -0
- package/dist/heading/index.js +8 -0
- package/dist/heading/internal/DefaultHeadingStyles.d.ts +15 -0
- package/dist/heading/internal/DefaultHeadingStyles.js +75 -0
- package/dist/heading/models/Align.d.ts +8 -0
- package/dist/heading/models/Align.js +9 -0
- package/dist/heading/models/HeadingProps.d.ts +25 -0
- package/dist/heading/models/HeadingProps.js +1 -0
- package/dist/heading/models/HeadingTag.d.ts +1 -0
- package/dist/heading/models/HeadingTag.js +1 -0
- package/dist/heading/models/index.d.ts +3 -0
- package/dist/heading/models/index.js +3 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/ordered-map/OrderedMap.svelte.d.ts +27 -0
- package/dist/ordered-map/OrderedMap.svelte.js +138 -0
- package/dist/ordered-map/__tests__/builders/OrderedMapBuilder.d.ts +9 -0
- package/dist/ordered-map/__tests__/builders/OrderedMapBuilder.js +26 -0
- package/dist/ordered-map/index.d.ts +1 -0
- package/dist/ordered-map/index.js +1 -0
- package/dist/paragraph/P.svelte +21 -0
- package/dist/paragraph/P.svelte.d.ts +4 -0
- package/dist/paragraph/PComponents.svelte.d.ts +13 -0
- package/dist/paragraph/PComponents.svelte.js +20 -0
- package/dist/paragraph/ParagraphStyles.d.ts +11 -0
- package/dist/paragraph/ParagraphStyles.js +1 -0
- package/dist/paragraph/__tests__/PStory.svelte +15 -0
- package/dist/paragraph/__tests__/PStory.svelte.d.ts +10 -0
- package/dist/paragraph/__tests__/ParagraphBuilder.d.ts +10 -0
- package/dist/paragraph/__tests__/ParagraphBuilder.js +28 -0
- package/dist/paragraph/index.d.ts +5 -0
- package/dist/paragraph/index.js +8 -0
- package/dist/paragraph/internal/DefaultParagraphStyles.d.ts +15 -0
- package/dist/paragraph/internal/DefaultParagraphStyles.js +61 -0
- package/dist/paragraph/internal/classes.d.ts +6 -0
- package/dist/paragraph/internal/classes.js +7 -0
- package/dist/paragraph/models/PFont.d.ts +4 -0
- package/dist/paragraph/models/PFont.js +5 -0
- package/dist/paragraph/models/PProps.d.ts +12 -0
- package/dist/paragraph/models/PProps.js +1 -0
- package/dist/paragraph/models/PSize.d.ts +6 -0
- package/dist/paragraph/models/PSize.js +7 -0
- package/dist/paragraph/models/index.d.ts +3 -0
- package/dist/paragraph/models/index.js +3 -0
- package/dist/theme/Component.svelte.d.ts +13 -0
- package/dist/theme/Component.svelte.js +20 -0
- package/dist/theme/index.d.ts +2 -0
- package/dist/theme/index.js +2 -0
- package/dist/theme/models/ThemableComponent.d.ts +6 -0
- package/dist/theme/models/ThemableComponent.js +1 -0
- package/dist/theme/models/Theme.d.ts +9 -0
- package/dist/theme/models/Theme.js +10 -0
- package/dist/theme/models/index.d.ts +2 -0
- package/dist/theme/models/index.js +2 -0
- package/dist/theme/themeDefaults.d.ts +2 -0
- package/dist/theme/themeDefaults.js +2 -0
- package/dist/types/KeysOfType.d.ts +3 -0
- package/dist/types/KeysOfType.js +1 -0
- package/dist/types/SurfaceContainerStyles.d.ts +4 -0
- package/dist/types/SurfaceContainerStyles.js +1 -0
- package/package.json +82 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
export class DefaultHeadingStyles {
|
|
2
|
+
_base = 'font-heading';
|
|
3
|
+
_themes = {
|
|
4
|
+
Primary: {
|
|
5
|
+
onContainer: 'text-primary-on',
|
|
6
|
+
onSurface: 'text-primary-on-surface',
|
|
7
|
+
},
|
|
8
|
+
Secondary: {
|
|
9
|
+
onContainer: 'text-secondary-on',
|
|
10
|
+
onSurface: 'text-secondary-on-surface',
|
|
11
|
+
},
|
|
12
|
+
Neutral: {
|
|
13
|
+
onContainer: 'text-neutral-on',
|
|
14
|
+
onSurface: 'text-neutral-on-surface',
|
|
15
|
+
},
|
|
16
|
+
Info: {
|
|
17
|
+
onContainer: 'text-info-on',
|
|
18
|
+
onSurface: 'text-info-on-surface',
|
|
19
|
+
},
|
|
20
|
+
Negative: {
|
|
21
|
+
onContainer: 'text-negative-on',
|
|
22
|
+
onSurface: 'text-negative-on-surface',
|
|
23
|
+
},
|
|
24
|
+
Positive: {
|
|
25
|
+
onContainer: 'text-positive-on',
|
|
26
|
+
onSurface: 'text-positive-on-surface',
|
|
27
|
+
},
|
|
28
|
+
Warning: {
|
|
29
|
+
onContainer: 'text-warning-on',
|
|
30
|
+
onSurface: 'text-warning-on-surface',
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
_tags = {
|
|
34
|
+
1: 'scroll-m-20 text-heading-1 font-extrabold tracking-tight',
|
|
35
|
+
2: 'scroll-m-20 text-heading-2 font-semibold tracking-tight',
|
|
36
|
+
3: 'scroll-m-20 text-heading-3 font-semibold tracking-tight',
|
|
37
|
+
4: 'scroll-m-20 text-heading-4 font-semibold tracking-tight',
|
|
38
|
+
5: 'scroll-m-20 text-heading-5 font-semibold tracking-tight',
|
|
39
|
+
6: 'scroll-m-20 text-heading-6 font-semibold tracking-tight',
|
|
40
|
+
};
|
|
41
|
+
getBase() {
|
|
42
|
+
return this._base;
|
|
43
|
+
}
|
|
44
|
+
setBase(classes) {
|
|
45
|
+
this._base = classes;
|
|
46
|
+
}
|
|
47
|
+
getTheme(theme, onContainer) {
|
|
48
|
+
return this._themes[theme][onContainer ? 'onContainer' : 'onSurface'];
|
|
49
|
+
}
|
|
50
|
+
setTheme(theme, onContainer, classes) {
|
|
51
|
+
this._themes[theme][onContainer ? 'onContainer' : 'onSurface'] = classes;
|
|
52
|
+
}
|
|
53
|
+
getTag(tag) {
|
|
54
|
+
return this._tags[tag];
|
|
55
|
+
}
|
|
56
|
+
setTag(tag, classes) {
|
|
57
|
+
this._tags[tag] = classes;
|
|
58
|
+
}
|
|
59
|
+
getDom(tag) {
|
|
60
|
+
switch (tag) {
|
|
61
|
+
case 1:
|
|
62
|
+
return 'h1';
|
|
63
|
+
case 2:
|
|
64
|
+
return 'h2';
|
|
65
|
+
case 3:
|
|
66
|
+
return 'h3';
|
|
67
|
+
case 4:
|
|
68
|
+
return 'h4';
|
|
69
|
+
case 5:
|
|
70
|
+
return 'h5';
|
|
71
|
+
case 6:
|
|
72
|
+
return 'h6';
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ThemableComponent } from '../../theme';
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import type { HeadingTag } from './HeadingTag';
|
|
4
|
+
import type { Align } from './Align';
|
|
5
|
+
import type { HeadingStyles } from '../HeadingStyles';
|
|
6
|
+
export interface HeadingProps extends ThemableComponent<HeadingStyles> {
|
|
7
|
+
/**
|
|
8
|
+
* Which heading to use
|
|
9
|
+
* @default 1
|
|
10
|
+
*/
|
|
11
|
+
tag?: HeadingTag;
|
|
12
|
+
/**
|
|
13
|
+
* Is the heading on surface or on container.
|
|
14
|
+
* @default false
|
|
15
|
+
*/
|
|
16
|
+
onContainer?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Heading's text to render.
|
|
19
|
+
*/
|
|
20
|
+
children?: Snippet;
|
|
21
|
+
/**
|
|
22
|
+
* How to align heading.
|
|
23
|
+
*/
|
|
24
|
+
align?: Align;
|
|
25
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type HeadingTag = 1 | 2 | 3 | 4 | 5 | 6;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
interface Entry<TValue> {
|
|
2
|
+
key: string;
|
|
3
|
+
value: TValue;
|
|
4
|
+
}
|
|
5
|
+
export declare class OrderedMap<TValue> {
|
|
6
|
+
get entries(): TValue[];
|
|
7
|
+
private _map;
|
|
8
|
+
private _entries;
|
|
9
|
+
private _batchedAdd;
|
|
10
|
+
static create<TValue>(): OrderedMap<TValue>;
|
|
11
|
+
getByKey(key: string): TValue | undefined;
|
|
12
|
+
setByKey(key: string, value: TValue): void;
|
|
13
|
+
getByIndex(index: number): TValue | undefined;
|
|
14
|
+
clear(): void;
|
|
15
|
+
addBatched(key: string, value: TValue): void;
|
|
16
|
+
batchedFinish(): void;
|
|
17
|
+
addMultiple(entries: Entry<TValue>[]): void;
|
|
18
|
+
add(key: string, value: TValue): void;
|
|
19
|
+
addStart(key: string, value: TValue): void;
|
|
20
|
+
addEnd(key: string, value: TValue): void;
|
|
21
|
+
addAfter(key: string, value: TValue, after: string): void;
|
|
22
|
+
addBefore(key: string, value: TValue, after: string): void;
|
|
23
|
+
move(from: string, to: string, after: boolean): void;
|
|
24
|
+
remove(key: string): TValue | undefined;
|
|
25
|
+
private fixIndices;
|
|
26
|
+
}
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
export class OrderedMap {
|
|
2
|
+
get entries() {
|
|
3
|
+
return this._entries.map((entry) => entry.value);
|
|
4
|
+
}
|
|
5
|
+
_map = new Map();
|
|
6
|
+
_entries = $state.raw([]);
|
|
7
|
+
_batchedAdd = [];
|
|
8
|
+
static create() {
|
|
9
|
+
return new OrderedMap();
|
|
10
|
+
}
|
|
11
|
+
getByKey(key) {
|
|
12
|
+
const index = this._map.get(key);
|
|
13
|
+
if (index == null) {
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
return this.getByIndex(index);
|
|
17
|
+
}
|
|
18
|
+
setByKey(key, value) {
|
|
19
|
+
const index = this._map.get(key);
|
|
20
|
+
if (index == null) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
this._entries[index].value = value;
|
|
24
|
+
}
|
|
25
|
+
getByIndex(index) {
|
|
26
|
+
return this._entries.at(index)?.value;
|
|
27
|
+
}
|
|
28
|
+
clear() {
|
|
29
|
+
this._entries = [];
|
|
30
|
+
this._map.clear();
|
|
31
|
+
}
|
|
32
|
+
addBatched(key, value) {
|
|
33
|
+
this._batchedAdd.push({
|
|
34
|
+
key,
|
|
35
|
+
value,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
batchedFinish() {
|
|
39
|
+
const lengthToStartFrom = this._entries.length - 1;
|
|
40
|
+
// TODO: Maybe batch this for big arrays?
|
|
41
|
+
this._entries.push(...this._batchedAdd);
|
|
42
|
+
this.fixIndices(lengthToStartFrom);
|
|
43
|
+
this._batchedAdd = [];
|
|
44
|
+
}
|
|
45
|
+
addMultiple(entries) {
|
|
46
|
+
for (const entry of entries) {
|
|
47
|
+
this.addBatched(entry.key, entry.value);
|
|
48
|
+
}
|
|
49
|
+
this.batchedFinish();
|
|
50
|
+
}
|
|
51
|
+
add(key, value) {
|
|
52
|
+
this._entries = [...this._entries, { key, value }];
|
|
53
|
+
this._map.set(key, this._entries.length - 1);
|
|
54
|
+
}
|
|
55
|
+
addStart(key, value) {
|
|
56
|
+
this._entries = [{ key, value }, ...this._entries];
|
|
57
|
+
this._map.set(key, this._entries.length - 1);
|
|
58
|
+
this.fixIndices();
|
|
59
|
+
}
|
|
60
|
+
addEnd(key, value) {
|
|
61
|
+
this._entries = [...this._entries, { key, value }];
|
|
62
|
+
this._map.set(key, this._entries.length - 1);
|
|
63
|
+
this.fixIndices(this._entries.length - 2);
|
|
64
|
+
}
|
|
65
|
+
addAfter(key, value, after) {
|
|
66
|
+
let indexToAddAfter = this._map.get(after);
|
|
67
|
+
if (indexToAddAfter == null) {
|
|
68
|
+
this.add(key, value);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
indexToAddAfter = Math.max(indexToAddAfter + 1, this._entries.length - 1);
|
|
72
|
+
const firstPart = this._entries.slice(0, indexToAddAfter - 1);
|
|
73
|
+
const secondPart = this._entries.slice(indexToAddAfter, this._entries.length);
|
|
74
|
+
this._entries = [...firstPart, { key, value }, ...secondPart];
|
|
75
|
+
this.fixIndices(indexToAddAfter);
|
|
76
|
+
}
|
|
77
|
+
addBefore(key, value, after) {
|
|
78
|
+
let indexToAddBefore = this._map.get(after);
|
|
79
|
+
if (indexToAddBefore == null) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
indexToAddBefore = Math.min(indexToAddBefore - 1, 0);
|
|
83
|
+
const firstPart = this._entries.slice(0, indexToAddBefore - 1);
|
|
84
|
+
const secondPart = this._entries.slice(indexToAddBefore, this._entries.length);
|
|
85
|
+
this._entries = [...firstPart, { key, value }, ...secondPart];
|
|
86
|
+
this.fixIndices(indexToAddBefore);
|
|
87
|
+
}
|
|
88
|
+
move(from, to, after) {
|
|
89
|
+
const fromIndex = this._map.get(from);
|
|
90
|
+
if (fromIndex == null) {
|
|
91
|
+
console.log('From index is null');
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
let toIndex = this._map.get(to);
|
|
95
|
+
if (toIndex == null) {
|
|
96
|
+
console.log('To index is null');
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
if (after) {
|
|
100
|
+
toIndex += 1;
|
|
101
|
+
}
|
|
102
|
+
const itemToMove = this._entries[fromIndex];
|
|
103
|
+
const testArray = this._entries;
|
|
104
|
+
testArray.splice(fromIndex, 1);
|
|
105
|
+
testArray.splice(toIndex, 0, itemToMove);
|
|
106
|
+
this._entries = [...testArray];
|
|
107
|
+
this.fixIndices(fromIndex, toIndex);
|
|
108
|
+
}
|
|
109
|
+
remove(key) {
|
|
110
|
+
const index = this._map.get(key);
|
|
111
|
+
if (index == null) {
|
|
112
|
+
return undefined;
|
|
113
|
+
}
|
|
114
|
+
const entries = this._entries;
|
|
115
|
+
const removedEntry = entries.splice(index, 1);
|
|
116
|
+
this._entries = [...entries];
|
|
117
|
+
this._map.delete(key);
|
|
118
|
+
this.fixIndices(index);
|
|
119
|
+
return removedEntry[0].value;
|
|
120
|
+
}
|
|
121
|
+
fixIndices(startIndex, endIndex) {
|
|
122
|
+
if (startIndex == null || startIndex < 0) {
|
|
123
|
+
startIndex = 0;
|
|
124
|
+
}
|
|
125
|
+
if (endIndex == null) {
|
|
126
|
+
endIndex = this._entries.length;
|
|
127
|
+
}
|
|
128
|
+
for (let index = startIndex; index < endIndex; index++) {
|
|
129
|
+
try {
|
|
130
|
+
const entry = this._entries[index];
|
|
131
|
+
this._map.set(entry.key, index);
|
|
132
|
+
}
|
|
133
|
+
catch (error) {
|
|
134
|
+
console.error(error);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { OrderedMap, type Child } from '../../OrderedMap.svelte';
|
|
2
|
+
export declare class OrderedMapBuilder<TValue> {
|
|
3
|
+
private _entriesToAdd;
|
|
4
|
+
private _child?;
|
|
5
|
+
static create<TValue>(): OrderedMapBuilder<TValue>;
|
|
6
|
+
entryToAdd(key: string, value: TValue): OrderedMapBuilder<TValue>;
|
|
7
|
+
withChild(child: Child<TValue>): OrderedMapBuilder<TValue>;
|
|
8
|
+
build(): OrderedMap<TValue>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { OrderedMap } from '../../OrderedMap.svelte';
|
|
2
|
+
export class OrderedMapBuilder {
|
|
3
|
+
_entriesToAdd = [];
|
|
4
|
+
_child;
|
|
5
|
+
static create() {
|
|
6
|
+
return new OrderedMapBuilder();
|
|
7
|
+
}
|
|
8
|
+
entryToAdd(key, value) {
|
|
9
|
+
this._entriesToAdd.push({ key, value });
|
|
10
|
+
return this;
|
|
11
|
+
}
|
|
12
|
+
withChild(child) {
|
|
13
|
+
this._child = child;
|
|
14
|
+
return this;
|
|
15
|
+
}
|
|
16
|
+
build() {
|
|
17
|
+
const map = OrderedMap.create();
|
|
18
|
+
if (this._child != null) {
|
|
19
|
+
map.child = this._child;
|
|
20
|
+
}
|
|
21
|
+
for (const entry of this._entriesToAdd) {
|
|
22
|
+
map.add(entry.key, entry.value);
|
|
23
|
+
}
|
|
24
|
+
return map;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './OrderedMap.svelte';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './OrderedMap.svelte';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { pKey } from '.';
|
|
3
|
+
import type { PProps } from './models/PProps';
|
|
4
|
+
import { PComponent } from './PComponents.svelte';
|
|
5
|
+
|
|
6
|
+
const props: PProps = $props();
|
|
7
|
+
|
|
8
|
+
const p = new PComponent(() => props, pKey);
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
<p
|
|
12
|
+
class={[
|
|
13
|
+
p.getStyles().getTheme(p.getTheme(), p.getOnContainer()),
|
|
14
|
+
p.getStyles().getSize(p.getSize()),
|
|
15
|
+
p.getStyles().getFont(p.getFont()),
|
|
16
|
+
{
|
|
17
|
+
italic: p.getItalic(),
|
|
18
|
+
},
|
|
19
|
+
]}>
|
|
20
|
+
{@render props.children?.()}
|
|
21
|
+
</p>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Component } from '../theme';
|
|
2
|
+
import { PFont, PSize, type PProps } from './models';
|
|
3
|
+
import type { ParagraphStyles } from './ParagraphStyles';
|
|
4
|
+
export declare class PComponent extends Component<ParagraphStyles, PProps> {
|
|
5
|
+
private readonly _size;
|
|
6
|
+
private readonly _onContainer;
|
|
7
|
+
private readonly _font;
|
|
8
|
+
private readonly _italic;
|
|
9
|
+
getSize(): PSize;
|
|
10
|
+
getOnContainer(): boolean;
|
|
11
|
+
getFont(): PFont;
|
|
12
|
+
getItalic(): boolean;
|
|
13
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Component } from '../theme';
|
|
2
|
+
import { PFont, PSize } from './models';
|
|
3
|
+
export class PComponent extends Component {
|
|
4
|
+
_size = $derived.by(() => this._getProps().size ?? PSize.Default);
|
|
5
|
+
_onContainer = $derived.by(() => this._getProps().onContainer ?? false);
|
|
6
|
+
_font = $derived.by(() => this._getProps().font ?? PFont.Default);
|
|
7
|
+
_italic = $derived.by(() => this._getProps().italic ?? false);
|
|
8
|
+
getSize() {
|
|
9
|
+
return this._size;
|
|
10
|
+
}
|
|
11
|
+
getOnContainer() {
|
|
12
|
+
return this._onContainer;
|
|
13
|
+
}
|
|
14
|
+
getFont() {
|
|
15
|
+
return this._font;
|
|
16
|
+
}
|
|
17
|
+
getItalic() {
|
|
18
|
+
return this._italic;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Theme } from '../theme';
|
|
2
|
+
import type { PFont } from './models';
|
|
3
|
+
import type { PSize } from './models/PSize';
|
|
4
|
+
export interface ParagraphStyles {
|
|
5
|
+
getTheme(theme: Theme, onSurface: boolean): string;
|
|
6
|
+
setTheme(theme: Theme, onSurface: boolean, classes: string): void;
|
|
7
|
+
getSize(size: PSize): string;
|
|
8
|
+
setSize(size: PSize, classes: string): void;
|
|
9
|
+
getFont(font: PFont): string;
|
|
10
|
+
setFont(font: PFont, classes: string): void;
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Theme } from '../../theme';
|
|
3
|
+
import { P, PFont } from '..';
|
|
4
|
+
|
|
5
|
+
interface Props {
|
|
6
|
+
message: string;
|
|
7
|
+
theme?: Theme;
|
|
8
|
+
font?: PFont;
|
|
9
|
+
}
|
|
10
|
+
const { message, theme, font }: Props = $props();
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<P
|
|
14
|
+
{theme}
|
|
15
|
+
{font}>{message}</P>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Theme } from '../../theme';
|
|
2
|
+
import { PFont } from '..';
|
|
3
|
+
interface Props {
|
|
4
|
+
message: string;
|
|
5
|
+
theme?: Theme;
|
|
6
|
+
font?: PFont;
|
|
7
|
+
}
|
|
8
|
+
declare const PStory: import("svelte").Component<Props, {}, "">;
|
|
9
|
+
type PStory = ReturnType<typeof PStory>;
|
|
10
|
+
export default PStory;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Theme } from '../../theme';
|
|
2
|
+
import { PFont } from '../models';
|
|
3
|
+
export declare class ParagraphBuilder {
|
|
4
|
+
private _theme;
|
|
5
|
+
private _font;
|
|
6
|
+
static create(): ParagraphBuilder;
|
|
7
|
+
withTheme(theme: Theme): ParagraphBuilder;
|
|
8
|
+
withFont(font: PFont): ParagraphBuilder;
|
|
9
|
+
build(): Promise<void>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { render } from 'vitest-browser-svelte';
|
|
2
|
+
import PStory from './PStory.svelte';
|
|
3
|
+
import { DEFAULT_THEME } from '../../theme/themeDefaults';
|
|
4
|
+
import { PFont } from '../models';
|
|
5
|
+
export class ParagraphBuilder {
|
|
6
|
+
_theme = DEFAULT_THEME;
|
|
7
|
+
_font = PFont.Default;
|
|
8
|
+
static create() {
|
|
9
|
+
return new ParagraphBuilder();
|
|
10
|
+
}
|
|
11
|
+
withTheme(theme) {
|
|
12
|
+
this._theme = theme;
|
|
13
|
+
return this;
|
|
14
|
+
}
|
|
15
|
+
withFont(font) {
|
|
16
|
+
this._font = font;
|
|
17
|
+
return this;
|
|
18
|
+
}
|
|
19
|
+
async build() {
|
|
20
|
+
await render(PStory, {
|
|
21
|
+
props: {
|
|
22
|
+
theme: this._theme,
|
|
23
|
+
message: 'test message',
|
|
24
|
+
font: this._font,
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { sveltix } from '..';
|
|
2
|
+
import { createKey } from '../di/DiContainer';
|
|
3
|
+
import { DefaultParagraphStyles } from './internal/DefaultParagraphStyles';
|
|
4
|
+
import P from './P.svelte';
|
|
5
|
+
export { P };
|
|
6
|
+
export * from './models';
|
|
7
|
+
export const pKey = createKey(DefaultParagraphStyles);
|
|
8
|
+
sveltix.registerSingleton(pKey);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Theme } from '../../theme';
|
|
2
|
+
import type { PFont } from '../models';
|
|
3
|
+
import type { PSize } from '../models/PSize';
|
|
4
|
+
import type { ParagraphStyles } from '../ParagraphStyles';
|
|
5
|
+
export declare class DefaultParagraphStyles implements ParagraphStyles {
|
|
6
|
+
private _themes;
|
|
7
|
+
private _sizes;
|
|
8
|
+
private _fonts;
|
|
9
|
+
getTheme(theme: Theme, onContainer: boolean): string;
|
|
10
|
+
setTheme(theme: Theme, onContainer: boolean, classes: string): void;
|
|
11
|
+
getSize(size: PSize): string;
|
|
12
|
+
setSize(size: PSize, classes: string): void;
|
|
13
|
+
getFont(font: PFont): string;
|
|
14
|
+
setFont(font: PFont, classes: string): void;
|
|
15
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { pClasses } from './classes';
|
|
2
|
+
export class DefaultParagraphStyles {
|
|
3
|
+
_themes = {
|
|
4
|
+
Primary: {
|
|
5
|
+
onContainer: 'text-primary-on',
|
|
6
|
+
onSurface: 'text-primary-on-surface',
|
|
7
|
+
},
|
|
8
|
+
Secondary: {
|
|
9
|
+
onContainer: 'text-secondary-on',
|
|
10
|
+
onSurface: 'text-secondary-on-surface',
|
|
11
|
+
},
|
|
12
|
+
Neutral: {
|
|
13
|
+
onContainer: 'text-neutral-on',
|
|
14
|
+
onSurface: 'text-neutral-on-surface',
|
|
15
|
+
},
|
|
16
|
+
Info: {
|
|
17
|
+
onContainer: 'text-info-on',
|
|
18
|
+
onSurface: 'text-info-on-surface',
|
|
19
|
+
},
|
|
20
|
+
Negative: {
|
|
21
|
+
onContainer: 'text-negative-on',
|
|
22
|
+
onSurface: 'text-negative-on-surface',
|
|
23
|
+
},
|
|
24
|
+
Positive: {
|
|
25
|
+
onContainer: 'text-positive-on',
|
|
26
|
+
onSurface: 'text-positive-on-surface',
|
|
27
|
+
},
|
|
28
|
+
Warning: {
|
|
29
|
+
onContainer: 'text-warning-on',
|
|
30
|
+
onSurface: 'text-warning-on-surface',
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
_sizes = {
|
|
34
|
+
Xs: 'text-p-xs',
|
|
35
|
+
S: 'text-p-sm',
|
|
36
|
+
Default: 'text-p-md',
|
|
37
|
+
Lg: 'text-p-lg',
|
|
38
|
+
};
|
|
39
|
+
_fonts = {
|
|
40
|
+
Default: pClasses.fonts.default,
|
|
41
|
+
Mono: pClasses.fonts.mono,
|
|
42
|
+
};
|
|
43
|
+
getTheme(theme, onContainer) {
|
|
44
|
+
return this._themes[theme][onContainer ? 'onContainer' : 'onSurface'];
|
|
45
|
+
}
|
|
46
|
+
setTheme(theme, onContainer, classes) {
|
|
47
|
+
this._themes[theme][onContainer ? 'onContainer' : 'onSurface'] = classes;
|
|
48
|
+
}
|
|
49
|
+
getSize(size) {
|
|
50
|
+
return this._sizes[size];
|
|
51
|
+
}
|
|
52
|
+
setSize(size, classes) {
|
|
53
|
+
this._sizes[size] = classes;
|
|
54
|
+
}
|
|
55
|
+
getFont(font) {
|
|
56
|
+
return this._fonts[font];
|
|
57
|
+
}
|
|
58
|
+
setFont(font, classes) {
|
|
59
|
+
this._fonts[font] = classes;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ThemableComponent } from '../../theme';
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import type { PSize } from './PSize';
|
|
4
|
+
import type { PFont } from './PFont';
|
|
5
|
+
import type { ParagraphStyles } from '../ParagraphStyles';
|
|
6
|
+
export interface PProps extends ThemableComponent<ParagraphStyles> {
|
|
7
|
+
size?: PSize;
|
|
8
|
+
onContainer?: boolean;
|
|
9
|
+
children?: Snippet;
|
|
10
|
+
font?: PFont;
|
|
11
|
+
italic?: boolean;
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|