windmill-components 1.35.42 → 1.36.0
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/components/AppConnect.svelte +85 -59
- package/components/ArgInput.svelte +50 -33
- package/components/ArgInput.svelte.d.ts +1 -1
- package/components/Button.svelte +15 -48
- package/components/Button.svelte.d.ts +1 -1
- package/components/CronInput.svelte +1 -1
- package/components/DisplayResult.svelte +75 -67
- package/components/Dropdown.svelte +9 -7
- package/components/Editor.svelte +187 -178
- package/components/Editor.svelte.d.ts +4 -2
- package/components/EditorBar.svelte +135 -98
- package/components/EditorBar.svelte.d.ts +2 -1
- package/components/FlowBuilder.svelte +115 -134
- package/components/FlowJobResult.svelte +4 -5
- package/components/FlowModulesViewer.svelte +89 -7
- package/components/FlowModulesViewer.svelte.d.ts +1 -0
- package/components/FlowPreviewContent.svelte +88 -27
- package/components/FlowPreviewContent.svelte.d.ts +1 -1
- package/components/FlowStatusViewer.svelte +39 -24
- package/components/FlowStatusViewer.svelte.d.ts +0 -1
- package/components/FlowViewer.svelte +17 -11
- package/components/GroupModal.svelte +10 -1
- package/components/HighlightCode.svelte +22 -0
- package/components/HighlightCode.svelte.d.ts +17 -0
- package/components/IconedPath.svelte +9 -7
- package/components/InputTransformForm.svelte +97 -115
- package/components/InputTransformForm.svelte.d.ts +0 -1
- package/components/InputTransformsViewer.svelte +1 -1
- package/components/InviteGlobalUser.svelte +8 -8
- package/components/InviteUser.svelte +9 -9
- package/components/ItemPicker.svelte +37 -30
- package/components/ItemPicker.svelte.d.ts +2 -1
- package/components/JobStatus.svelte +2 -1
- package/components/LogViewer.svelte +23 -0
- package/components/LogViewer.svelte.d.ts +19 -0
- package/components/ModulePreview.svelte +107 -0
- package/components/ModulePreview.svelte.d.ts +24 -0
- package/components/Path.svelte +1 -1
- package/components/RadioButton.svelte +3 -2
- package/components/ResourceEditor.svelte +22 -34
- package/components/ResourceTypePicker.svelte +23 -34
- package/components/RunForm.svelte +34 -31
- package/components/RunForm.svelte.d.ts +6 -2
- package/components/SchemaEditor.svelte +19 -11
- package/components/SchemaForm.svelte +3 -3
- package/components/SchemaForm.svelte.d.ts +1 -1
- package/components/SchemaModal.svelte +18 -7
- package/components/ScriptBuilder.svelte +99 -83
- package/components/ScriptBuilder.svelte.d.ts +2 -4
- package/components/ScriptEditor.svelte +71 -143
- package/components/ScriptEditor.svelte.d.ts +0 -5
- package/components/ScriptPicker.svelte +24 -14
- package/components/ScriptPicker.svelte.d.ts +2 -1
- package/components/ScriptSchema.svelte +8 -11
- package/components/ScriptSchema.svelte.d.ts +0 -1
- package/components/ShareModal.svelte +6 -6
- package/components/SharedBadge.svelte +5 -13
- package/components/SimpleEditor.svelte +14 -10
- package/components/StringTypeNarrowing.svelte +24 -30
- package/components/TestJobLoader.svelte +106 -0
- package/components/TestJobLoader.svelte.d.ts +26 -0
- package/components/Tooltip.svelte +3 -2
- package/components/VariableEditor.svelte +15 -24
- package/components/common/actionRow/ActionRow.svelte +31 -0
- package/components/common/actionRow/ActionRow.svelte.d.ts +22 -0
- package/components/common/alert/Alert.svelte +53 -0
- package/components/common/alert/Alert.svelte.d.ts +20 -0
- package/components/common/alert/model.d.ts +1 -0
- package/components/common/alert/model.js +1 -0
- package/components/common/badge/Badge.svelte +76 -0
- package/components/common/badge/Badge.svelte.d.ts +28 -0
- package/components/common/badge/model.d.ts +8 -0
- package/components/common/badge/model.js +1 -0
- package/components/common/button/Button.svelte +110 -0
- package/components/common/button/Button.svelte.d.ts +39 -0
- package/components/common/button/model.d.ts +6 -0
- package/components/common/button/model.js +1 -0
- package/components/common/confirmationModal/ConfirmationModal.svelte +72 -0
- package/components/common/confirmationModal/ConfirmationModal.svelte.d.ts +23 -0
- package/components/common/confirmationModal/UnsavedConfirmationModal.svelte +41 -0
- package/components/common/confirmationModal/UnsavedConfirmationModal.svelte.d.ts +14 -0
- package/components/common/confirmationModal/dirtyStore.d.ts +1 -0
- package/components/common/confirmationModal/dirtyStore.js +2 -0
- package/components/common/drawer/Drawer.svelte +3 -0
- package/components/common/drawer/Drawer.svelte.d.ts +2 -0
- package/components/common/index.d.ts +14 -0
- package/components/common/index.js +14 -0
- package/components/common/tabs/TabContent.svelte +3 -2
- package/components/common/tabs/TabContent.svelte.d.ts +1 -0
- package/components/common/tabs/Tabs.svelte +8 -1
- package/components/common/tabs/Tabs.svelte.d.ts +2 -0
- package/components/common/toggleButton/ToggleButton.svelte +20 -0
- package/components/common/toggleButton/ToggleButton.svelte.d.ts +19 -0
- package/components/common/toggleButton/ToggleButtonGroup.svelte +33 -0
- package/components/common/toggleButton/ToggleButtonGroup.svelte.d.ts +24 -0
- package/components/flows/FlowEditor.svelte +30 -0
- package/components/{FlowEditor.svelte.d.ts → flows/FlowEditor.svelte.d.ts} +1 -6
- package/components/flows/common/FlowCard.svelte +9 -0
- package/components/flows/common/FlowCard.svelte.d.ts +21 -0
- package/components/flows/common/FlowCardHeader.svelte +39 -0
- package/components/flows/common/FlowCardHeader.svelte.d.ts +20 -0
- package/components/flows/content/CopyFirstStepSchema.svelte +13 -0
- package/components/flows/{CopyFirstStepSchema.svelte.d.ts → content/CopyFirstStepSchema.svelte.d.ts} +0 -0
- package/components/flows/{DynamicInputHelpBox.svelte → content/DynamicInputHelpBox.svelte} +0 -0
- package/components/flows/{DynamicInputHelpBox.svelte.d.ts → content/DynamicInputHelpBox.svelte.d.ts} +0 -0
- package/components/flows/content/FlowEditorPanel.svelte +25 -0
- package/components/flows/content/FlowEditorPanel.svelte.d.ts +16 -0
- package/components/flows/content/FlowFailureModule.svelte +15 -0
- package/components/flows/content/FlowFailureModule.svelte.d.ts +14 -0
- package/components/flows/content/FlowInput.svelte +26 -0
- package/components/flows/{FlowInput.svelte.d.ts → content/FlowInput.svelte.d.ts} +0 -0
- package/components/flows/content/FlowInputs.svelte +91 -0
- package/components/flows/{FlowInputs.svelte.d.ts → content/FlowInputs.svelte.d.ts} +1 -0
- package/components/flows/content/FlowLoop.svelte +168 -0
- package/components/flows/content/FlowLoop.svelte.d.ts +18 -0
- package/components/flows/content/FlowLoopWrapper.svelte +9 -0
- package/components/flows/content/FlowLoopWrapper.svelte.d.ts +14 -0
- package/components/flows/content/FlowModule.svelte +211 -0
- package/components/flows/content/FlowModule.svelte.d.ts +29 -0
- package/components/flows/content/FlowModuleEarlyStop.svelte +76 -0
- package/components/flows/content/FlowModuleEarlyStop.svelte.d.ts +17 -0
- package/components/flows/content/FlowModuleHeader.svelte +157 -0
- package/components/flows/{FlowModuleHeader.svelte.d.ts → content/FlowModuleHeader.svelte.d.ts} +5 -3
- package/components/flows/content/FlowModuleScript.svelte +21 -0
- package/components/flows/content/FlowModuleScript.svelte.d.ts +17 -0
- package/components/flows/content/FlowModuleSuspend.svelte +27 -0
- package/components/flows/content/FlowModuleSuspend.svelte.d.ts +17 -0
- package/components/flows/content/FlowModuleWrapper.svelte +45 -0
- package/components/flows/content/FlowModuleWrapper.svelte.d.ts +14 -0
- package/components/flows/content/FlowRetries.svelte +80 -0
- package/components/flows/content/FlowRetries.svelte.d.ts +17 -0
- package/components/flows/content/FlowSchedules.svelte +18 -0
- package/components/flows/content/FlowSchedules.svelte.d.ts +14 -0
- package/components/flows/content/FlowSettings.svelte +78 -0
- package/components/flows/{FlowSettings.svelte.d.ts → content/FlowSettings.svelte.d.ts} +2 -6
- package/components/flows/content/RemoveStepConfirmationModal.svelte +32 -0
- package/components/flows/content/RemoveStepConfirmationModal.svelte.d.ts +19 -0
- package/components/flows/flowState.d.ts +8 -7
- package/components/flows/flowState.js +25 -46
- package/components/flows/flowStateUtils.d.ts +16 -14
- package/components/flows/flowStateUtils.js +81 -73
- package/components/flows/flowStore.js +7 -4
- package/components/flows/header/FlowImportExportMenu.svelte +55 -0
- package/components/flows/header/FlowImportExportMenu.svelte.d.ts +14 -0
- package/components/flows/header/FlowPreviewButtons.svelte +57 -0
- package/components/flows/header/FlowPreviewButtons.svelte.d.ts +14 -0
- package/components/flows/map/FlowErrorHandlerItem.svelte +60 -0
- package/components/flows/map/FlowErrorHandlerItem.svelte.d.ts +14 -0
- package/components/flows/map/FlowModuleSchemaItem.svelte +80 -0
- package/components/flows/map/FlowModuleSchemaItem.svelte.d.ts +32 -0
- package/components/flows/map/FlowModuleSchemaMap.svelte +241 -0
- package/components/flows/map/FlowModuleSchemaMap.svelte.d.ts +20 -0
- package/components/flows/pickers/PickHubScript.svelte +5 -3
- package/components/flows/pickers/PickHubScript.svelte.d.ts +2 -1
- package/components/flows/pickers/PickScript.svelte +4 -12
- package/components/flows/pickers/PickScript.svelte.d.ts +1 -1
- package/components/flows/propPicker/PropPickerWrapper.svelte +44 -0
- package/components/flows/propPicker/PropPickerWrapper.svelte.d.ts +33 -0
- package/components/flows/scheduleUtils.d.ts +0 -1
- package/components/flows/scheduleUtils.js +0 -1
- package/components/flows/types.d.ts +8 -0
- package/components/flows/types.js +1 -0
- package/components/flows/utils.d.ts +3 -1
- package/components/flows/utils.js +26 -10
- package/components/icons/AirtableIcon.svelte +1 -1
- package/components/icons/DiscordIcon.svelte +1 -1
- package/components/icons/GCloudIcon.svelte +1 -1
- package/components/icons/GItlabIcon.svelte +1 -1
- package/components/icons/GSheetsIcon.svelte +1 -1
- package/components/icons/GcalIcon.svelte +1 -1
- package/components/icons/GdriveIcon.svelte +1 -1
- package/components/icons/GithubIcon.svelte +1 -1
- package/components/icons/GmailIcon.svelte +1 -1
- package/components/icons/HatIcon.svelte +19 -0
- package/components/icons/HatIcon.svelte.d.ts +16 -0
- package/components/icons/MastodonIcon.svelte +1 -1
- package/components/icons/MatrixIcon.svelte +1 -1
- package/components/icons/PostgresIcon.svelte +1 -1
- package/components/icons/S3Icon.svelte +1 -1
- package/components/icons/Slack.svelte +1 -1
- package/components/icons/TogglIcon.svelte +8 -46
- package/components/jobs/JobDetail.svelte +1 -1
- package/components/landing/FlowGettingStarted.svelte +22 -68
- package/components/landing/FlowLandingBox.svelte +1 -1
- package/components/landing/RessourceGettingStarted.svelte +7 -37
- package/components/landing/ScriptBox.svelte +33 -60
- package/components/landing/ScriptGettingStarted.svelte +23 -69
- package/components/propertyPicker/ObjectViewer.svelte +18 -12
- package/components/propertyPicker/ObjectViewer.svelte.d.ts +1 -0
- package/components/propertyPicker/PropPicker.svelte +108 -11
- package/components/propertyPicker/WarningMessage.svelte +2 -15
- package/components/script_editor/LogPanel.svelte +108 -119
- package/components/script_editor/LogPanel.svelte.d.ts +2 -0
- package/components/sidebar/SidebarContent.svelte +2 -2
- package/editorUtils.d.ts +3 -0
- package/editorUtils.js +1 -0
- package/gen/core/OpenAPI.js +1 -1
- package/gen/index.d.ts +1 -0
- package/gen/models/CompletedJob.d.ts +2 -1
- package/gen/models/CompletedJob.js +1 -0
- package/gen/models/FlowModule.d.ts +3 -0
- package/gen/models/FlowStatus.d.ts +3 -0
- package/gen/models/FlowStatusModule.d.ts +1 -1
- package/gen/models/Preview.d.ts +2 -1
- package/gen/models/Preview.js +1 -0
- package/gen/models/QueuedJob.d.ts +2 -1
- package/gen/models/QueuedJob.js +1 -0
- package/gen/models/RawScript.d.ts +2 -1
- package/gen/models/RawScript.js +1 -0
- package/gen/models/Retry.d.ts +11 -0
- package/gen/models/Retry.js +4 -0
- package/gen/models/Script.d.ts +9 -2
- package/gen/models/Script.js +8 -0
- package/gen/services/JobService.d.ts +40 -0
- package/gen/services/JobService.js +70 -0
- package/gen/services/ScriptService.d.ts +14 -3
- package/gen/services/ScriptService.js +13 -0
- package/infer.d.ts +1 -1
- package/infer.js +6 -1
- package/package.json +71 -38
- package/script_helpers.d.ts +8 -2
- package/script_helpers.js +88 -16
- package/stores.d.ts +1 -1
- package/utils.d.ts +8 -6
- package/utils.js +57 -21
- package/components/FlowEditor.svelte +0 -55
- package/components/FlowPreview.svelte +0 -107
- package/components/FlowPreview.svelte.d.ts +0 -23
- package/components/ModuleStep.svelte +0 -131
- package/components/ModuleStep.svelte.d.ts +0 -25
- package/components/flows/CopyFirstStepSchema.svelte +0 -13
- package/components/flows/FlowBox.svelte +0 -16
- package/components/flows/FlowBox.svelte.d.ts +0 -23
- package/components/flows/FlowBoxHeader.svelte +0 -16
- package/components/flows/FlowBoxHeader.svelte.d.ts +0 -21
- package/components/flows/FlowInput.svelte +0 -22
- package/components/flows/FlowInputs.svelte +0 -65
- package/components/flows/FlowModuleHeader.svelte +0 -109
- package/components/flows/FlowSettings.svelte +0 -165
- package/components/flows/FlowTimeline.svelte +0 -169
- package/components/flows/FlowTimeline.svelte.d.ts +0 -21
- package/components/flows/stepOpenedStore.d.ts +0 -1
- package/components/flows/stepOpenedStore.js +0 -6
- package/components/propertyPicker/OverlayPropertyPicker.svelte +0 -69
- package/components/propertyPicker/OverlayPropertyPicker.svelte.d.ts +0 -24
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
<script>import { classNames } from '../../../utils';
|
|
2
|
+
import { faCheckCircle, faInfoCircle, faWarning } from '@fortawesome/free-solid-svg-icons';
|
|
3
|
+
import Icon from 'svelte-awesome';
|
|
4
|
+
export let type = 'info';
|
|
5
|
+
export let title;
|
|
6
|
+
const icons = {
|
|
7
|
+
info: faInfoCircle,
|
|
8
|
+
warning: faWarning,
|
|
9
|
+
error: faWarning,
|
|
10
|
+
success: faCheckCircle
|
|
11
|
+
};
|
|
12
|
+
const classes = {
|
|
13
|
+
info: {
|
|
14
|
+
bgClass: 'bg-blue-50',
|
|
15
|
+
iconClass: 'text-blue-500',
|
|
16
|
+
titleClass: 'text-blue-800',
|
|
17
|
+
descriptionClass: 'text-blue-700'
|
|
18
|
+
},
|
|
19
|
+
warning: {
|
|
20
|
+
bgClass: 'bg-yellow-50',
|
|
21
|
+
iconClass: 'text-yellow-500',
|
|
22
|
+
titleClass: 'text-yellow-800',
|
|
23
|
+
descriptionClass: 'text-yellow-700'
|
|
24
|
+
},
|
|
25
|
+
error: {
|
|
26
|
+
bgClass: 'bg-red-50',
|
|
27
|
+
iconClass: 'text-red-500',
|
|
28
|
+
titleClass: 'text-red-800',
|
|
29
|
+
descriptionClass: 'text-red-700'
|
|
30
|
+
},
|
|
31
|
+
success: {
|
|
32
|
+
bgClass: 'bg-green-50',
|
|
33
|
+
iconClass: 'text-green-500',
|
|
34
|
+
titleClass: 'text-green-800',
|
|
35
|
+
descriptionClass: 'text-green-700'
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
</script>
|
|
39
|
+
|
|
40
|
+
<div class={classNames('rounded-md p-4', classes[type].bgClass)}>
|
|
41
|
+
<div class="flex">
|
|
42
|
+
<div class="flex h-8 w-8 items-center justify-center rounded-full">
|
|
43
|
+
<Icon data={icons[type]} class={classes[type].iconClass} />
|
|
44
|
+
</div>
|
|
45
|
+
|
|
46
|
+
<div class="ml-2 w-full">
|
|
47
|
+
<span class={classNames('text-sm font-medium', classes[type].titleClass)}>{title}</span>
|
|
48
|
+
<div class={classNames('mt-2 text-sm', classes[type].descriptionClass)}>
|
|
49
|
+
<slot />
|
|
50
|
+
</div>
|
|
51
|
+
</div>
|
|
52
|
+
</div>
|
|
53
|
+
</div>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import type { AlertType } from './model';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
type?: AlertType | undefined;
|
|
6
|
+
title: string;
|
|
7
|
+
};
|
|
8
|
+
events: {
|
|
9
|
+
[evt: string]: CustomEvent<any>;
|
|
10
|
+
};
|
|
11
|
+
slots: {
|
|
12
|
+
default: {};
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export declare type AlertProps = typeof __propDef.props;
|
|
16
|
+
export declare type AlertEvents = typeof __propDef.events;
|
|
17
|
+
export declare type AlertSlots = typeof __propDef.slots;
|
|
18
|
+
export default class Alert extends SvelteComponentTyped<AlertProps, AlertEvents, AlertSlots> {
|
|
19
|
+
}
|
|
20
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare type AlertType = 'success' | 'error' | 'warning' | 'info';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
<script>import { classNames } from '../../../utils';
|
|
2
|
+
import { CloseButton } from 'flowbite-svelte';
|
|
3
|
+
import Icon from 'svelte-awesome';
|
|
4
|
+
import { ColorModifier } from './model';
|
|
5
|
+
export let color = 'gray';
|
|
6
|
+
export let large = false;
|
|
7
|
+
export let href = '';
|
|
8
|
+
export let rounded = false;
|
|
9
|
+
export let index = false;
|
|
10
|
+
export let dismissable = false;
|
|
11
|
+
export let baseClass = 'text-center -mb-0.5';
|
|
12
|
+
export let capitalize = false;
|
|
13
|
+
export let icon = undefined;
|
|
14
|
+
let defaulIconProps = {
|
|
15
|
+
data: undefined,
|
|
16
|
+
position: 'left',
|
|
17
|
+
scale: 0.7
|
|
18
|
+
};
|
|
19
|
+
let hidden = false;
|
|
20
|
+
const colors = {
|
|
21
|
+
gray: 'bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300',
|
|
22
|
+
blue: 'bg-blue-100 text-blue-800 dark:bg-blue-200 dark:text-blue-800',
|
|
23
|
+
red: 'bg-red-100 text-red-800 dark:bg-red-200 dark:text-red-900',
|
|
24
|
+
green: 'bg-green-100 text-green-800 dark:bg-green-200 dark:text-green-900',
|
|
25
|
+
yellow: 'bg-yellow-100 text-yellow-800 dark:bg-yellow-200 dark:text-yellow-900',
|
|
26
|
+
indigo: 'bg-indigo-100 text-indigo-800 dark:bg-indigo-200 dark:text-indigo-900',
|
|
27
|
+
['dark-gray']: 'bg-gray-500 text-gray-100',
|
|
28
|
+
['dark-blue']: 'bg-blue-500 text-blue-100',
|
|
29
|
+
['dark-red']: 'bg-red-500 text-white',
|
|
30
|
+
['dark-green']: 'bg-green-500 text-green-100',
|
|
31
|
+
['dark-yellow']: 'bg-yellow-300 text-yellow-800',
|
|
32
|
+
['dark-indigo']: 'bg-indigo-500 text-indigo-100'
|
|
33
|
+
};
|
|
34
|
+
const hovers = {
|
|
35
|
+
gray: 'hover:bg-gray-200 dark:hover:bg-gray-300',
|
|
36
|
+
blue: 'hover:bg-blue-200 dark:hover:bg-blue-300',
|
|
37
|
+
red: 'hover:bg-red-200 dark:hover:bg-red-300',
|
|
38
|
+
green: 'hover:bg-green-200 dark:hover:bg-green-300',
|
|
39
|
+
yellow: 'hover:bg-yellow-200 dark:hover:bg-yellow-300',
|
|
40
|
+
indigo: 'hover:bg-indigo-200 dark:hover:bg-indigo-300'
|
|
41
|
+
};
|
|
42
|
+
$: badgeClass = classNames(baseClass, large ? 'text-sm font-medium' : 'text-xs font-semibold', colors[color], href &&
|
|
43
|
+
(color.startsWith(ColorModifier) ? hovers[color.replace(ColorModifier, '')] : hovers[color]), rounded ? 'rounded-full px-2 py-1' : 'rounded px-2.5 py-0.5', index
|
|
44
|
+
? 'absolute flex justify-center items-center font-bold overflow-hidden border-2 border-white dark:border-gray-900 ' +
|
|
45
|
+
(large ? 'w-7 h-7 -top-3.5 -right-3.5' : 'w-6 h-6 -top-3 -right-3')
|
|
46
|
+
: '', $$props.class);
|
|
47
|
+
$: iconProps = icon ? { ...defaulIconProps, ...icon } : { data: undefined };
|
|
48
|
+
const handleHide = () => (hidden = !hidden);
|
|
49
|
+
</script>
|
|
50
|
+
|
|
51
|
+
<span class="inline-flex justify-center items-center">
|
|
52
|
+
<svelte:element
|
|
53
|
+
this={href ? 'a' : 'span'}
|
|
54
|
+
{href}
|
|
55
|
+
{...$$restProps}
|
|
56
|
+
class={badgeClass}
|
|
57
|
+
class:hidden
|
|
58
|
+
class:capitalize
|
|
59
|
+
>
|
|
60
|
+
{#if iconProps.data && iconProps.position === 'left'}
|
|
61
|
+
<Icon {...iconProps} />
|
|
62
|
+
{/if}
|
|
63
|
+
<slot />
|
|
64
|
+
{#if iconProps.data && iconProps.position === 'right'}
|
|
65
|
+
<Icon {...iconProps} />
|
|
66
|
+
{/if}
|
|
67
|
+
{#if dismissable}
|
|
68
|
+
<CloseButton
|
|
69
|
+
{color}
|
|
70
|
+
on:click={handleHide}
|
|
71
|
+
size={large ? 'sm' : 'xs'}
|
|
72
|
+
class="ml-1.5 -mr-1.5"
|
|
73
|
+
/>
|
|
74
|
+
{/if}
|
|
75
|
+
</svelte:element>
|
|
76
|
+
</span>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import { type BadgeColor, type BadgeIconProps } from './model';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
[x: string]: any;
|
|
6
|
+
color?: BadgeColor | undefined;
|
|
7
|
+
large?: boolean | undefined;
|
|
8
|
+
href?: string | undefined;
|
|
9
|
+
rounded?: boolean | undefined;
|
|
10
|
+
index?: boolean | undefined;
|
|
11
|
+
dismissable?: boolean | undefined;
|
|
12
|
+
baseClass?: string | undefined;
|
|
13
|
+
capitalize?: boolean | undefined;
|
|
14
|
+
icon?: BadgeIconProps | undefined;
|
|
15
|
+
};
|
|
16
|
+
events: {
|
|
17
|
+
[evt: string]: CustomEvent<any>;
|
|
18
|
+
};
|
|
19
|
+
slots: {
|
|
20
|
+
default: {};
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
export declare type BadgeProps = typeof __propDef.props;
|
|
24
|
+
export declare type BadgeEvents = typeof __propDef.events;
|
|
25
|
+
export declare type BadgeSlots = typeof __propDef.slots;
|
|
26
|
+
export default class Badge extends SvelteComponentTyped<BadgeProps, BadgeEvents, BadgeSlots> {
|
|
27
|
+
}
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { IconProps } from 'svelte-awesome/components/Icon.svelte';
|
|
2
|
+
declare type BaseColor = 'blue' | 'gray' | 'red' | 'green' | 'yellow' | 'indigo';
|
|
3
|
+
export declare const ColorModifier = "dark-";
|
|
4
|
+
export declare type BadgeColor = BaseColor | `${typeof ColorModifier}${BaseColor}`;
|
|
5
|
+
export interface BadgeIconProps extends IconProps {
|
|
6
|
+
position?: 'left' | 'right';
|
|
7
|
+
}
|
|
8
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const ColorModifier = 'dark-';
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
<script>import { goto } from '$app/navigation';
|
|
2
|
+
import { classNames } from '../../../utils';
|
|
3
|
+
import Icon from 'svelte-awesome';
|
|
4
|
+
export let size = 'md';
|
|
5
|
+
export let spacingSize = size;
|
|
6
|
+
export let color = 'blue';
|
|
7
|
+
export let variant = 'contained';
|
|
8
|
+
export let btnClasses = '';
|
|
9
|
+
export let disabled = false;
|
|
10
|
+
export let href = undefined;
|
|
11
|
+
export let target = '_self';
|
|
12
|
+
export let iconOnly = false;
|
|
13
|
+
export let id = '';
|
|
14
|
+
export let startIcon = undefined;
|
|
15
|
+
export let endIcon = undefined;
|
|
16
|
+
// Order of classes: border, border modifier, bg, bg modifier, text, text modifier, everything else
|
|
17
|
+
const colorVariants = {
|
|
18
|
+
blue: {
|
|
19
|
+
border: 'border-blue-500 hover:border-blue-700 bg-white hover:bg-blue-100 text-blue-500 hover:text-blue-700 focus:ring-blue-300',
|
|
20
|
+
contained: 'bg-blue-500 hover:bg-blue-700 text-white focus:ring-blue-300'
|
|
21
|
+
},
|
|
22
|
+
red: {
|
|
23
|
+
border: 'border-red-600 hover:border-red-700 bg-white hover:bg-red-100 text-red-600 hover:text-red-700 focus:ring-red-300',
|
|
24
|
+
contained: 'bg-red-600 hover:bg-red-700 text-white focus:ring-red-300'
|
|
25
|
+
},
|
|
26
|
+
dark: {
|
|
27
|
+
border: 'border-gray-800 hover:border-gray-900 bg-white hover:bg-gray-200 text-gray-800 hover:text-gray-900 focus:ring-gray-300',
|
|
28
|
+
contained: 'bg-gray-700 hover:bg-gray-900 text-white focus:ring-gray-300'
|
|
29
|
+
},
|
|
30
|
+
light: {
|
|
31
|
+
border: 'border bg-white hover:bg-gray-100 text-gray-700 hover:text-gray-800 focus:ring-gray-300',
|
|
32
|
+
contained: 'bg-white hover:bg-gray-100 text-gray-700 focus:ring-gray-300'
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
const fontSizeClasses = {
|
|
36
|
+
xs: 'text-xs',
|
|
37
|
+
sm: 'text-sm',
|
|
38
|
+
md: 'text-md',
|
|
39
|
+
lg: 'text-lg',
|
|
40
|
+
xl: 'text-xl'
|
|
41
|
+
};
|
|
42
|
+
const spacingClasses = {
|
|
43
|
+
xs: 'px-3 py-1.5',
|
|
44
|
+
sm: 'px-3 py-1.5',
|
|
45
|
+
md: 'px-4 py-2',
|
|
46
|
+
lg: 'px-4 py-2',
|
|
47
|
+
xl: 'px-4 py-2'
|
|
48
|
+
};
|
|
49
|
+
const iconScale = {
|
|
50
|
+
xs: 0.6,
|
|
51
|
+
sm: 0.8,
|
|
52
|
+
md: 1,
|
|
53
|
+
lg: 1.1,
|
|
54
|
+
xl: 1.2
|
|
55
|
+
};
|
|
56
|
+
$: buttonProps = {
|
|
57
|
+
class: classNames(colorVariants[color][variant], variant === 'border' ? 'border' : '', fontSizeClasses[size], spacingClasses[spacingSize], 'focus:ring-4 font-medium', 'rounded-md', 'flex justify-center items-center text-center whitespace-nowrap', btnClasses, disabled ? 'pointer-events-none cursor-default filter grayscale' : ''),
|
|
58
|
+
disabled
|
|
59
|
+
};
|
|
60
|
+
$: isSmall = size === 'xs' || size === 'sm';
|
|
61
|
+
</script>
|
|
62
|
+
|
|
63
|
+
{#if href}
|
|
64
|
+
<button
|
|
65
|
+
{id}
|
|
66
|
+
type="button"
|
|
67
|
+
on:click|stopPropagation={() => goto(href ?? '#')}
|
|
68
|
+
{target}
|
|
69
|
+
tabindex={disabled ? -1 : 0}
|
|
70
|
+
{...buttonProps}
|
|
71
|
+
>
|
|
72
|
+
{#if startIcon}
|
|
73
|
+
<Icon
|
|
74
|
+
data={startIcon.icon}
|
|
75
|
+
class={classNames(iconOnly ? undefined : 'mr-2', startIcon.classes)}
|
|
76
|
+
scale={iconScale[size]}
|
|
77
|
+
/>
|
|
78
|
+
{/if}
|
|
79
|
+
{#if !iconOnly}
|
|
80
|
+
<slot />
|
|
81
|
+
{/if}
|
|
82
|
+
{#if endIcon}
|
|
83
|
+
<Icon
|
|
84
|
+
data={endIcon.icon}
|
|
85
|
+
class={classNames(iconOnly ? undefined : 'ml-2', endIcon.classes)}
|
|
86
|
+
scale={iconScale[size]}
|
|
87
|
+
/>
|
|
88
|
+
{/if}
|
|
89
|
+
</button>
|
|
90
|
+
{:else}
|
|
91
|
+
<button {id} type="button" on:click|stopPropagation {...buttonProps} {...$$restProps}>
|
|
92
|
+
{#if startIcon}
|
|
93
|
+
<Icon
|
|
94
|
+
data={startIcon.icon}
|
|
95
|
+
class={classNames(iconOnly ? undefined : 'mr-2', startIcon.classes)}
|
|
96
|
+
scale={iconScale[size]}
|
|
97
|
+
/>
|
|
98
|
+
{/if}
|
|
99
|
+
{#if !iconOnly}
|
|
100
|
+
<slot />
|
|
101
|
+
{/if}
|
|
102
|
+
{#if endIcon}
|
|
103
|
+
<Icon
|
|
104
|
+
data={endIcon.icon}
|
|
105
|
+
class={classNames(iconOnly ? undefined : 'ml-2', endIcon.classes)}
|
|
106
|
+
scale={iconScale[size]}
|
|
107
|
+
/>
|
|
108
|
+
{/if}
|
|
109
|
+
</button>
|
|
110
|
+
{/if}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import type { Button } from './model';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
[x: string]: any;
|
|
6
|
+
size?: Button.Size | undefined;
|
|
7
|
+
spacingSize?: Button.Size | undefined;
|
|
8
|
+
color?: Button.Color | undefined;
|
|
9
|
+
variant?: Button.Variant | undefined;
|
|
10
|
+
btnClasses?: string | undefined;
|
|
11
|
+
disabled?: boolean | undefined;
|
|
12
|
+
href?: string | undefined;
|
|
13
|
+
target?: Button.Target | undefined;
|
|
14
|
+
iconOnly?: boolean | undefined;
|
|
15
|
+
id?: string | undefined;
|
|
16
|
+
startIcon?: {
|
|
17
|
+
icon: any;
|
|
18
|
+
classes?: string;
|
|
19
|
+
} | undefined;
|
|
20
|
+
endIcon?: {
|
|
21
|
+
icon: any;
|
|
22
|
+
classes?: string;
|
|
23
|
+
} | undefined;
|
|
24
|
+
};
|
|
25
|
+
events: {
|
|
26
|
+
click: MouseEvent;
|
|
27
|
+
} & {
|
|
28
|
+
[evt: string]: CustomEvent<any>;
|
|
29
|
+
};
|
|
30
|
+
slots: {
|
|
31
|
+
default: {};
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
export declare type ButtonProps = typeof __propDef.props;
|
|
35
|
+
export declare type ButtonEvents = typeof __propDef.events;
|
|
36
|
+
export declare type ButtonSlots = typeof __propDef.slots;
|
|
37
|
+
export default class Button extends SvelteComponentTyped<ButtonProps, ButtonEvents, ButtonSlots> {
|
|
38
|
+
}
|
|
39
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
<script>import { classNames } from '../../../utils';
|
|
2
|
+
import { faWarning } from '@fortawesome/free-solid-svg-icons';
|
|
3
|
+
import { createEventDispatcher } from 'svelte';
|
|
4
|
+
import Icon from 'svelte-awesome';
|
|
5
|
+
import { fade } from 'svelte/transition';
|
|
6
|
+
import Button from '../button/Button.svelte';
|
|
7
|
+
import Badge from '../badge/Badge.svelte';
|
|
8
|
+
export let title;
|
|
9
|
+
export let confirmationText;
|
|
10
|
+
export let open = false;
|
|
11
|
+
const dispatch = createEventDispatcher();
|
|
12
|
+
function onKeyDown(event) {
|
|
13
|
+
if (open) {
|
|
14
|
+
switch (event.key) {
|
|
15
|
+
case 'Enter':
|
|
16
|
+
dispatch('confirmed');
|
|
17
|
+
break;
|
|
18
|
+
case 'Escape':
|
|
19
|
+
dispatch('canceled');
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<svelte:window on:keydown={onKeyDown} />
|
|
27
|
+
|
|
28
|
+
{#if open}
|
|
29
|
+
<div transition:fade={{ duration: 100 }} class={'relative z-50'} role="dialog">
|
|
30
|
+
<div
|
|
31
|
+
class={classNames(
|
|
32
|
+
'fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity',
|
|
33
|
+
open ? 'ease-out duration-300 opacity-100' : 'ease-in duration-200 opacity-0'
|
|
34
|
+
)}
|
|
35
|
+
/>
|
|
36
|
+
|
|
37
|
+
<div class="fixed inset-0 z-10 overflow-y-auto">
|
|
38
|
+
<div class="flex min-h-full items-center justify-center p-4">
|
|
39
|
+
<div
|
|
40
|
+
class={classNames(
|
|
41
|
+
'relative transform overflow-hidden rounded-lg bg-white px-4 pt-5 pb-4 text-left shadow-xl transition-all sm:my-8 sm:w-full sm:max-w-lg sm:p-6',
|
|
42
|
+
open
|
|
43
|
+
? 'ease-out duration-300 opacity-100 translate-y-0 sm:scale-100'
|
|
44
|
+
: 'ease-in duration-200 opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95'
|
|
45
|
+
)}
|
|
46
|
+
>
|
|
47
|
+
<div class="flex">
|
|
48
|
+
<div class="flex h-12 w-12 items-center justify-center rounded-full bg-red-100">
|
|
49
|
+
<Icon data={faWarning} class="text-red-500" />
|
|
50
|
+
</div>
|
|
51
|
+
<div class="ml-4 text-left flex-1">
|
|
52
|
+
<h3 class="text-lg font-medium text-gray-900">
|
|
53
|
+
{title}
|
|
54
|
+
</h3>
|
|
55
|
+
<div class="mt-2 text-sm text-gray-500">
|
|
56
|
+
<slot />
|
|
57
|
+
</div>
|
|
58
|
+
</div>
|
|
59
|
+
</div>
|
|
60
|
+
<div class="flex items-center space-x-2 flex-row-reverse space-x-reverse mt-4">
|
|
61
|
+
<Button on:click={() => dispatch('confirmed')} color="red" size="sm">
|
|
62
|
+
<span>{confirmationText} <Badge>Enter</Badge></span>
|
|
63
|
+
</Button>
|
|
64
|
+
<Button on:click={() => dispatch('canceled')} color="light" size="sm">
|
|
65
|
+
<span>Cancel <Badge color="dark-gray">Escape</Badge></span>
|
|
66
|
+
</Button>
|
|
67
|
+
</div>
|
|
68
|
+
</div>
|
|
69
|
+
</div>
|
|
70
|
+
</div>
|
|
71
|
+
</div>
|
|
72
|
+
{/if}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
title: string;
|
|
5
|
+
confirmationText: string;
|
|
6
|
+
open?: boolean | undefined;
|
|
7
|
+
};
|
|
8
|
+
events: {
|
|
9
|
+
confirmed: CustomEvent<any>;
|
|
10
|
+
canceled: CustomEvent<any>;
|
|
11
|
+
} & {
|
|
12
|
+
[evt: string]: CustomEvent<any>;
|
|
13
|
+
};
|
|
14
|
+
slots: {
|
|
15
|
+
default: {};
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export declare type ConfirmationModalProps = typeof __propDef.props;
|
|
19
|
+
export declare type ConfirmationModalEvents = typeof __propDef.events;
|
|
20
|
+
export declare type ConfirmationModalSlots = typeof __propDef.slots;
|
|
21
|
+
export default class ConfirmationModal extends SvelteComponentTyped<ConfirmationModalProps, ConfirmationModalEvents, ConfirmationModalSlots> {
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
<script>import ConfirmationModal from './ConfirmationModal.svelte';
|
|
2
|
+
import { beforeNavigate, goto } from '$app/navigation';
|
|
3
|
+
import { onDestroy } from 'svelte/internal';
|
|
4
|
+
import { dirtyStore } from './dirtyStore';
|
|
5
|
+
let navigationState = undefined;
|
|
6
|
+
$: open = Boolean(navigationState);
|
|
7
|
+
beforeNavigate((newNavigationState) => {
|
|
8
|
+
if (!navigationState &&
|
|
9
|
+
$dirtyStore &&
|
|
10
|
+
newNavigationState.to?.pathname !== newNavigationState.from.pathname) {
|
|
11
|
+
navigationState = newNavigationState;
|
|
12
|
+
newNavigationState.cancel();
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
onDestroy(() => {
|
|
16
|
+
$dirtyStore = false;
|
|
17
|
+
});
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<ConfirmationModal
|
|
21
|
+
{open}
|
|
22
|
+
title="Unsaved changes detected"
|
|
23
|
+
confirmationText="Discard changes"
|
|
24
|
+
on:canceled={() => {
|
|
25
|
+
if (navigationState) {
|
|
26
|
+
navigationState.cancel()
|
|
27
|
+
}
|
|
28
|
+
navigationState = undefined
|
|
29
|
+
}}
|
|
30
|
+
on:confirmed={() => {
|
|
31
|
+
if (navigationState?.to) {
|
|
32
|
+
goto(navigationState.to)
|
|
33
|
+
}
|
|
34
|
+
$dirtyStore = false
|
|
35
|
+
navigationState = undefined
|
|
36
|
+
}}
|
|
37
|
+
>
|
|
38
|
+
<div class="flex flex-col w-full space-y-4">
|
|
39
|
+
<span>Are you sure you want to discard change you have made?</span>
|
|
40
|
+
</div>
|
|
41
|
+
</ConfirmationModal>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {};
|
|
4
|
+
events: {
|
|
5
|
+
[evt: string]: CustomEvent<any>;
|
|
6
|
+
};
|
|
7
|
+
slots: {};
|
|
8
|
+
};
|
|
9
|
+
export declare type UnsavedConfirmationModalProps = typeof __propDef.props;
|
|
10
|
+
export declare type UnsavedConfirmationModalEvents = typeof __propDef.events;
|
|
11
|
+
export declare type UnsavedConfirmationModalSlots = typeof __propDef.slots;
|
|
12
|
+
export default class UnsavedConfirmationModal extends SvelteComponentTyped<UnsavedConfirmationModalProps, UnsavedConfirmationModalEvents, UnsavedConfirmationModalSlots> {
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const dirtyStore: import("svelte/store").Writable<boolean>;
|
|
@@ -4,6 +4,9 @@ export let open = false;
|
|
|
4
4
|
export let duration = 0.3;
|
|
5
5
|
export let placement = 'right';
|
|
6
6
|
export let size = '600px';
|
|
7
|
+
export function toggleDrawer() {
|
|
8
|
+
open = !open;
|
|
9
|
+
}
|
|
7
10
|
let mounted = false;
|
|
8
11
|
const dispatch = createEventDispatcher();
|
|
9
12
|
$: style = `--duration: ${duration}s; --size: ${size};`;
|
|
@@ -5,6 +5,7 @@ declare const __propDef: {
|
|
|
5
5
|
duration?: number | undefined;
|
|
6
6
|
placement?: string | undefined;
|
|
7
7
|
size?: string | undefined;
|
|
8
|
+
toggleDrawer?: (() => void) | undefined;
|
|
8
9
|
};
|
|
9
10
|
events: {
|
|
10
11
|
clickAway: CustomEvent<any>;
|
|
@@ -19,5 +20,6 @@ export declare type DrawerProps = typeof __propDef.props;
|
|
|
19
20
|
export declare type DrawerEvents = typeof __propDef.events;
|
|
20
21
|
export declare type DrawerSlots = typeof __propDef.slots;
|
|
21
22
|
export default class Drawer extends SvelteComponentTyped<DrawerProps, DrawerEvents, DrawerSlots> {
|
|
23
|
+
get toggleDrawer(): () => void;
|
|
22
24
|
}
|
|
23
25
|
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { default as ActionRow } from './actionRow/ActionRow.svelte';
|
|
2
|
+
export { default as Badge } from './badge/Badge.svelte';
|
|
3
|
+
export { default as Button } from './button/Button.svelte';
|
|
4
|
+
export { default as Drawer } from './drawer/Drawer.svelte';
|
|
5
|
+
export { default as DrawerContent } from './drawer/DrawerContent.svelte';
|
|
6
|
+
export { default as Menu } from './menu/Menu.svelte';
|
|
7
|
+
export { default as MenuItem } from './menu/MenuItem.svelte';
|
|
8
|
+
export { default as Tab } from './tabs/Tab.svelte';
|
|
9
|
+
export { default as TabContent } from './tabs/TabContent.svelte';
|
|
10
|
+
export { default as Tabs } from './tabs/Tabs.svelte';
|
|
11
|
+
export { default as ToggleButton } from './toggleButton/ToggleButton.svelte';
|
|
12
|
+
export { default as ToggleButtonGroup } from './toggleButton/ToggleButtonGroup.svelte';
|
|
13
|
+
export * from './badge/model';
|
|
14
|
+
export * from './button/model';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { default as ActionRow } from './actionRow/ActionRow.svelte';
|
|
2
|
+
export { default as Badge } from './badge/Badge.svelte';
|
|
3
|
+
export { default as Button } from './button/Button.svelte';
|
|
4
|
+
export { default as Drawer } from './drawer/Drawer.svelte';
|
|
5
|
+
export { default as DrawerContent } from './drawer/DrawerContent.svelte';
|
|
6
|
+
export { default as Menu } from './menu/Menu.svelte';
|
|
7
|
+
export { default as MenuItem } from './menu/MenuItem.svelte';
|
|
8
|
+
export { default as Tab } from './tabs/Tab.svelte';
|
|
9
|
+
export { default as TabContent } from './tabs/TabContent.svelte';
|
|
10
|
+
export { default as Tabs } from './tabs/Tabs.svelte';
|
|
11
|
+
export { default as ToggleButton } from './toggleButton/ToggleButton.svelte';
|
|
12
|
+
export { default as ToggleButtonGroup } from './toggleButton/ToggleButtonGroup.svelte';
|
|
13
|
+
export * from './badge/model';
|
|
14
|
+
export * from './button/model';
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
<script>import { getContext } from 'svelte';
|
|
2
2
|
export let value;
|
|
3
|
+
export let alwaysMounted = false;
|
|
3
4
|
let clazz = '';
|
|
4
5
|
export { clazz as class };
|
|
5
6
|
const { selected } = getContext('Tabs');
|
|
6
7
|
</script>
|
|
7
8
|
|
|
8
|
-
{#if value === $selected}
|
|
9
|
-
<div class={clazz}>
|
|
9
|
+
{#if value === $selected || alwaysMounted}
|
|
10
|
+
<div class={`${clazz} ${value === $selected ? 'visible' : 'hidden'}`}>
|
|
10
11
|
<slot />
|
|
11
12
|
</div>
|
|
12
13
|
{/if}
|
|
@@ -3,8 +3,12 @@
|
|
|
3
3
|
|
|
4
4
|
<script>import { setContext } from 'svelte';
|
|
5
5
|
import { writable } from 'svelte/store';
|
|
6
|
+
import { createEventDispatcher } from 'svelte';
|
|
7
|
+
const dispatch = createEventDispatcher();
|
|
6
8
|
export let selected;
|
|
9
|
+
$: selected && updateSelected();
|
|
7
10
|
const selectedContent = writable(selected);
|
|
11
|
+
$: $selectedContent && dispatch('selected', $selectedContent);
|
|
8
12
|
setContext('Tabs', {
|
|
9
13
|
selected: selectedContent,
|
|
10
14
|
update: (value) => {
|
|
@@ -12,9 +16,12 @@ setContext('Tabs', {
|
|
|
12
16
|
selected = value;
|
|
13
17
|
}
|
|
14
18
|
});
|
|
19
|
+
function updateSelected() {
|
|
20
|
+
selectedContent.set(selected);
|
|
21
|
+
}
|
|
15
22
|
</script>
|
|
16
23
|
|
|
17
|
-
<div class="border-b border-gray-200 flex flex-row
|
|
24
|
+
<div class="border-b border-gray-200 flex flex-row">
|
|
18
25
|
<slot />
|
|
19
26
|
</div>
|
|
20
27
|
<slot name="content" />
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<script>import { classNames } from '../../../utils';
|
|
2
|
+
import { getContext } from 'svelte';
|
|
3
|
+
export let value;
|
|
4
|
+
export let position;
|
|
5
|
+
const { select, selected } = getContext('ToggleButtonGroup');
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<button
|
|
9
|
+
type="button"
|
|
10
|
+
on:click={() => select(value)}
|
|
11
|
+
class={classNames(
|
|
12
|
+
'py-1 px-2 text-sm font-medium border-gray-200 ',
|
|
13
|
+
position === 'left' ? 'rounded-l-lg border' : '',
|
|
14
|
+
position === 'center' ? 'border-t border-b' : '',
|
|
15
|
+
position === 'right' ? 'rounded-r-md border border-l-0' : '',
|
|
16
|
+
$selected.includes(value) ? 'text-white bg-gray-900 ' : 'text-gray-900 bg-white '
|
|
17
|
+
)}
|
|
18
|
+
>
|
|
19
|
+
<slot />
|
|
20
|
+
</button>
|