@invopop/popui 0.0.1
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 +146 -0
- package/dist/BaseButton.svelte +107 -0
- package/dist/BaseButton.svelte.d.ts +33 -0
- package/dist/BaseCard.svelte +50 -0
- package/dist/BaseCard.svelte.d.ts +25 -0
- package/dist/BaseCounter.svelte +16 -0
- package/dist/BaseCounter.svelte.d.ts +17 -0
- package/dist/BaseDropdown.svelte +46 -0
- package/dist/BaseDropdown.svelte.d.ts +24 -0
- package/dist/BaseFlag.svelte +14 -0
- package/dist/BaseFlag.svelte.d.ts +17 -0
- package/dist/BaseTable.svelte +148 -0
- package/dist/BaseTable.svelte.d.ts +33 -0
- package/dist/BaseTableActions.svelte +31 -0
- package/dist/BaseTableActions.svelte.d.ts +21 -0
- package/dist/BaseTableCell.svelte +90 -0
- package/dist/BaseTableCell.svelte.d.ts +26 -0
- package/dist/BaseTableHeader.svelte +75 -0
- package/dist/BaseTableHeader.svelte.d.ts +23 -0
- package/dist/BaseTableHeaderSortBy.svelte +22 -0
- package/dist/BaseTableHeaderSortBy.svelte.d.ts +20 -0
- package/dist/BaseTableRow.svelte +48 -0
- package/dist/BaseTableRow.svelte.d.ts +25 -0
- package/dist/ButtonFile.svelte +51 -0
- package/dist/ButtonFile.svelte.d.ts +25 -0
- package/dist/CardRelation.svelte +29 -0
- package/dist/CardRelation.svelte.d.ts +22 -0
- package/dist/CompanySelector.svelte +74 -0
- package/dist/CompanySelector.svelte.d.ts +23 -0
- package/dist/CounterWorkflow.svelte +15 -0
- package/dist/CounterWorkflow.svelte.d.ts +17 -0
- package/dist/DataListItem.svelte +22 -0
- package/dist/DataListItem.svelte.d.ts +22 -0
- package/dist/DatePicker.svelte +431 -0
- package/dist/DatePicker.svelte.d.ts +22 -0
- package/dist/DrawerContext.svelte +48 -0
- package/dist/DrawerContext.svelte.d.ts +23 -0
- package/dist/DrawerContextItem.svelte +93 -0
- package/dist/DrawerContextItem.svelte.d.ts +23 -0
- package/dist/DrawerContextWorkspace.svelte +40 -0
- package/dist/DrawerContextWorkspace.svelte.d.ts +20 -0
- package/dist/DropdownSelect.svelte +78 -0
- package/dist/DropdownSelect.svelte.d.ts +26 -0
- package/dist/EmptyStateIcon.svelte +46 -0
- package/dist/EmptyStateIcon.svelte.d.ts +22 -0
- package/dist/EmptyStateIllustration.svelte +58 -0
- package/dist/EmptyStateIllustration.svelte.d.ts +21 -0
- package/dist/FeedEvents.svelte +26 -0
- package/dist/FeedEvents.svelte.d.ts +17 -0
- package/dist/FeedIconEvent.svelte +10 -0
- package/dist/FeedIconEvent.svelte.d.ts +19 -0
- package/dist/FeedIconStatus.svelte +26 -0
- package/dist/FeedIconStatus.svelte.d.ts +17 -0
- package/dist/FeedItem.svelte +87 -0
- package/dist/FeedItem.svelte.d.ts +30 -0
- package/dist/FeedItemDetail.svelte +56 -0
- package/dist/FeedItemDetail.svelte.d.ts +23 -0
- package/dist/FeedViewer.svelte +19 -0
- package/dist/FeedViewer.svelte.d.ts +21 -0
- package/dist/FormLayoutModal.svelte +8 -0
- package/dist/FormLayoutModal.svelte.d.ts +29 -0
- package/dist/GlobalSearch.svelte +47 -0
- package/dist/GlobalSearch.svelte.d.ts +18 -0
- package/dist/InputCheckbox.svelte +20 -0
- package/dist/InputCheckbox.svelte.d.ts +18 -0
- package/dist/InputError.svelte +14 -0
- package/dist/InputError.svelte.d.ts +16 -0
- package/dist/InputLabel.svelte +5 -0
- package/dist/InputLabel.svelte.d.ts +17 -0
- package/dist/InputRadio.svelte +27 -0
- package/dist/InputRadio.svelte.d.ts +19 -0
- package/dist/InputSearch.svelte +69 -0
- package/dist/InputSearch.svelte.d.ts +32 -0
- package/dist/InputSelect.svelte +75 -0
- package/dist/InputSelect.svelte.d.ts +30 -0
- package/dist/InputText.svelte +63 -0
- package/dist/InputText.svelte.d.ts +26 -0
- package/dist/InputTextarea.svelte +42 -0
- package/dist/InputTextarea.svelte.d.ts +24 -0
- package/dist/InputToggle.svelte +33 -0
- package/dist/InputToggle.svelte.d.ts +18 -0
- package/dist/MenuItem.svelte +141 -0
- package/dist/MenuItem.svelte.d.ts +29 -0
- package/dist/ProfileAvatar.svelte +39 -0
- package/dist/ProfileAvatar.svelte.d.ts +21 -0
- package/dist/ProfileSelector.svelte +20 -0
- package/dist/ProfileSelector.svelte.d.ts +20 -0
- package/dist/SectionLayout.svelte +10 -0
- package/dist/SectionLayout.svelte.d.ts +18 -0
- package/dist/SeparatorHorizontal.svelte +14 -0
- package/dist/SeparatorHorizontal.svelte.d.ts +23 -0
- package/dist/ShortcutWrapper.svelte +6 -0
- package/dist/ShortcutWrapper.svelte.d.ts +27 -0
- package/dist/StatusLabel.svelte +20 -0
- package/dist/StatusLabel.svelte.d.ts +18 -0
- package/dist/Tabs.svelte +41 -0
- package/dist/Tabs.svelte.d.ts +20 -0
- package/dist/TagBeta.svelte +23 -0
- package/dist/TagBeta.svelte.d.ts +23 -0
- package/dist/TagSearch.svelte +46 -0
- package/dist/TagSearch.svelte.d.ts +22 -0
- package/dist/TagStatus.svelte +46 -0
- package/dist/TagStatus.svelte.d.ts +19 -0
- package/dist/TitleMain.svelte +6 -0
- package/dist/TitleMain.svelte.d.ts +18 -0
- package/dist/TitleSection.svelte +6 -0
- package/dist/TitleSection.svelte.d.ts +18 -0
- package/dist/UuidCopy.svelte +55 -0
- package/dist/UuidCopy.svelte.d.ts +26 -0
- package/dist/clickOutside.d.ts +4 -0
- package/dist/clickOutside.js +18 -0
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +1 -0
- package/dist/helpers.d.ts +6 -0
- package/dist/helpers.js +35 -0
- package/dist/index.d.ts +51 -0
- package/dist/index.js +101 -0
- package/dist/popui.css +1 -0
- package/dist/svg/BgPattern.svelte +20 -0
- package/dist/svg/BgPattern.svelte.d.ts +23 -0
- package/dist/svg/IconContact.svelte +114 -0
- package/dist/svg/IconContact.svelte.d.ts +16 -0
- package/dist/svg/IconEmpty.svelte +138 -0
- package/dist/svg/IconEmpty.svelte.d.ts +23 -0
- package/dist/svg/IconFile.svelte +91 -0
- package/dist/svg/IconFile.svelte.d.ts +16 -0
- package/dist/svg/IconInvoice.svelte +97 -0
- package/dist/svg/IconInvoice.svelte.d.ts +16 -0
- package/dist/svg/IconNoResults.svelte +83 -0
- package/dist/svg/IconNoResults.svelte.d.ts +16 -0
- package/dist/svg/IconPdf.svelte +93 -0
- package/dist/svg/IconPdf.svelte.d.ts +16 -0
- package/dist/svg/IconProduct.svelte +105 -0
- package/dist/svg/IconProduct.svelte.d.ts +16 -0
- package/dist/tw.theme.d.ts +135 -0
- package/dist/tw.theme.js +152 -0
- package/dist/types.d.ts +128 -0
- package/dist/types.js +1 -0
- package/dist/wcdispatch.d.ts +1 -0
- package/dist/wcdispatch.js +9 -0
- package/package.json +102 -0
package/README.md
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
# Invopop UI Kit
|
|
2
|
+
|
|
3
|
+
Set of reusable components to be used inside Console UI and other Invopop Microfrontends.
|
|
4
|
+
|
|
5
|
+
Everything inside `src/lib` is part of the library, everything else will be omitted on the NPM package.
|
|
6
|
+
|
|
7
|
+
## Runing Storybook
|
|
8
|
+
|
|
9
|
+
Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development storybook server:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm run storybook
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
> For using a different `accent` color for some components you can set the `--workspace-accent-color:` CSS variable placed in `.storybook/variables.css` file.
|
|
16
|
+
|
|
17
|
+
## Compiling Web Components
|
|
18
|
+
|
|
19
|
+
The following command will compile a file called `dist/invopop-web-components.js` that can be imported on any external project.
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm run build-web-components
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
A test HTML file using this script can be found at `src/wbc-preview/index.html`
|
|
26
|
+
|
|
27
|
+
## Building the Svelte Library
|
|
28
|
+
|
|
29
|
+
To build the Svelte library:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npm run package
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
To create a production version of the showcase app:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
npm run build
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
You can preview the production build with `npm run preview`.
|
|
42
|
+
|
|
43
|
+
> To deploy the app, you may need to install an [adapter](https://kit.svelte.dev/docs/adapters) for your target environment.
|
|
44
|
+
|
|
45
|
+
## Publishing the Svelte Library
|
|
46
|
+
|
|
47
|
+
To publish the library to [npm](https://www.npmjs.com):
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
npm publish
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Building the Web Components Library
|
|
54
|
+
|
|
55
|
+
To build the Web Components library:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
npm run build-web-components
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
This will generate a `/dist/index.js` file that you can include on any HTML to test. There is a ready-to-use HTML file with an example of any of the components located in `/src/wbc-preview/index.html`
|
|
62
|
+
|
|
63
|
+
## Publishing the Web Components Library
|
|
64
|
+
|
|
65
|
+
To publish the Web Components library to [npm](https://www.npmjs.com):
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
npm publish-wbc
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Using the Web Components Library in your module
|
|
72
|
+
|
|
73
|
+
Include the CDN script in your HTML file
|
|
74
|
+
|
|
75
|
+
```html
|
|
76
|
+
<script src="https://cdn.jsdelivr.net/npm/@invopop/web-components@0.0.1/index.js" defer></script>
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Use any of the components available
|
|
80
|
+
|
|
81
|
+
```html
|
|
82
|
+
<ui-button>Default Button</ui-button>
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
You can pass props and listen to events
|
|
86
|
+
|
|
87
|
+
```html
|
|
88
|
+
<ui-button onClick="alert('button click')" type="primary">Primary Button</ui-button>
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Available Web Components
|
|
92
|
+
|
|
93
|
+
> NOTE: Due to web component limitations booleans need to be passed as strings ie: "true", other structures like objects or arrays need to be passed as JSON.stringify()
|
|
94
|
+
|
|
95
|
+
| Component | Events Emitted | Props Accepted |
|
|
96
|
+
| ------------------ | -------------- | ---------------------------------------------------------------------------------- |
|
|
97
|
+
| `ui-button` | `@click` | `type`: 'default', 'primary', 'secondary', 'danger', 'dark'` (default: 'default') |
|
|
98
|
+
| | | `disabled`: boolean (default: false) |
|
|
99
|
+
| | | `small`: boolean (default: false) |
|
|
100
|
+
| | | `icon`: Cog6Tooth (Heroicons library name) (default: undefined) |
|
|
101
|
+
| | | `iconPosition`: 'right', 'left' (default: left) |
|
|
102
|
+
| | | |
|
|
103
|
+
| `ui-button-file` | `@click` | `type`: 'default', 'primary', 'secondary', 'danger', 'dark'` (default: 'default') |
|
|
104
|
+
| | | `disabled`: boolean (default: false) |
|
|
105
|
+
| | | `name`: string (default: '') |
|
|
106
|
+
| | | `fullwidth`: boolean (default: false) |
|
|
107
|
+
| | | |
|
|
108
|
+
| `ui-checkbox` | `@change` | `checked`: boolean (default: false) |
|
|
109
|
+
| | | |
|
|
110
|
+
| `ui-input-search` | `@input` | `placeholder`: string (default: '') |
|
|
111
|
+
| | | `shortcut`: string (default: '') |
|
|
112
|
+
| | | |
|
|
113
|
+
| `ui-input-text` | `@input` | `id`: string (default: '') |
|
|
114
|
+
| | | `label`: string (default: '') |
|
|
115
|
+
| | | `placeholder`: string (default: '') |
|
|
116
|
+
| | | `errorText`: string (default: '') |
|
|
117
|
+
| | | `disabled`: boolean (default: 'false') |
|
|
118
|
+
| | | |
|
|
119
|
+
| `ui-list-item` | `@input` | `value`: string (default: '') |
|
|
120
|
+
| | | `label`: string (default: '') |
|
|
121
|
+
| | | |
|
|
122
|
+
| `ui-radio` | `@change` | `checked`: boolean (default: false) |
|
|
123
|
+
| | | |
|
|
124
|
+
| `ui-section` | | `title`: string (default: '') |
|
|
125
|
+
| | | |
|
|
126
|
+
| `ui-select` | `@change` | `id`: string (default: '') |
|
|
127
|
+
| | | `name`: string (default: '') |
|
|
128
|
+
| | | `label`: string (default: '') |
|
|
129
|
+
| | | `placeholder`: string (default: '') |
|
|
130
|
+
| | | `value`: string (default: '') |
|
|
131
|
+
| | | `icon`: Cog6Tooth (Heroicons library name) (default: undefined) |
|
|
132
|
+
| | | `disabled`: boolean (default: 'false') |
|
|
133
|
+
| | | `disablePlaceholder`: boolean (default: 'false') |
|
|
134
|
+
| | | `options`: string (default: '[]') |
|
|
135
|
+
| | | |
|
|
136
|
+
| `ui-tag-search` | `@clear` | `label`: string (default: '') |
|
|
137
|
+
| | | `icon`: Cog6Tooth (Heroicons library name) (default: undefined) |
|
|
138
|
+
| | | |
|
|
139
|
+
| `ui-tag-status` | | `label`: string (default: '') |
|
|
140
|
+
| | | `status`: 'default', 'success', 'warning', 'danger', 'orange' (default: 'default') |
|
|
141
|
+
| | | |
|
|
142
|
+
| `ui-title-main` | | `title`: string (default: '') |
|
|
143
|
+
| | | |
|
|
144
|
+
| `ui-title-section` | | `title`: string (default: '') |
|
|
145
|
+
| | | |
|
|
146
|
+
| `ui-toggle` | `@change` | `checked`: boolean (default: false) |
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
<script>import clsx from "clsx";
|
|
2
|
+
import { Icon } from "@steeze-ui/svelte-icon";
|
|
3
|
+
import { createEventDispatcher } from "svelte";
|
|
4
|
+
import { dispatchWcEvent } from "./wcdispatch.js";
|
|
5
|
+
import { resolveIcon } from "./helpers.js";
|
|
6
|
+
import ShortcutWrapper from "./ShortcutWrapper.svelte";
|
|
7
|
+
const dispatch = createEventDispatcher();
|
|
8
|
+
export let icon = void 0;
|
|
9
|
+
export let iconTheme = "default";
|
|
10
|
+
export let iconPosition = "left";
|
|
11
|
+
export let type = "button";
|
|
12
|
+
export let variant = "default";
|
|
13
|
+
export let disabled = false;
|
|
14
|
+
export let small = false;
|
|
15
|
+
export let big = false;
|
|
16
|
+
export let dangerIcon = false;
|
|
17
|
+
export let shortcut = false;
|
|
18
|
+
export let fullwidth = false;
|
|
19
|
+
let resolvedIcon;
|
|
20
|
+
$: {
|
|
21
|
+
resolveIcon(icon).then((icon2) => {
|
|
22
|
+
resolvedIcon = icon2;
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
$:
|
|
26
|
+
buttonStyles = clsx(
|
|
27
|
+
{ "w-full": fullwidth },
|
|
28
|
+
{ "opacity-30 pointer-events-none": disabled },
|
|
29
|
+
{ "flex-row-reverse space-x-reverse": iconPosition === "right" },
|
|
30
|
+
{ "bg-white": variant === "default" },
|
|
31
|
+
{ "bg-workspace-accent": variant === "primary" },
|
|
32
|
+
{ "bg-neutral-100 hover:bg-neutral-200 focus:bg-neutral-300": variant === "secondary" },
|
|
33
|
+
{ "bg-danger-500": variant === "danger" },
|
|
34
|
+
{ "text-sm rounded": small },
|
|
35
|
+
{ "text-base rounded-md": !small },
|
|
36
|
+
{ "p-1": small && !$$slots.default },
|
|
37
|
+
{ "p-1.5": !small && !big && !$$slots.default },
|
|
38
|
+
{ "p-2": big && !$$slots.default },
|
|
39
|
+
{ "px-3": big && $$slots.default && !icon },
|
|
40
|
+
{ "px-2": !big && $$slots.default && !icon },
|
|
41
|
+
{ "pl-2 pr-2.5": big && $$slots.default && icon && iconPosition === "left" },
|
|
42
|
+
{ "pl-1.5 pr-2": big && $$slots.default && icon && iconPosition === "right" },
|
|
43
|
+
{ "pl-1.5 pr-2": !small && !big && $$slots.default && icon && iconPosition === "left" },
|
|
44
|
+
{ "pl-2 pr-1.5": !small && !big && $$slots.default && icon && iconPosition === "right" },
|
|
45
|
+
{ "py-1.5": big && $$slots.default },
|
|
46
|
+
{ "py-1": !big && $$slots.default },
|
|
47
|
+
{ "text-white": ["primary", "danger", "dark"].includes(variant) },
|
|
48
|
+
{ "text-neutral-800": ["default", "secondary"].includes(variant) },
|
|
49
|
+
{ "border border-white-10 hover:border-white-20 focus:border-white-40": variant === "dark" },
|
|
50
|
+
{
|
|
51
|
+
"border border-neutral-200 hover:bg-neutral-100 focus:border-neutral-300 focus:bg-neutral-200": variant === "default"
|
|
52
|
+
},
|
|
53
|
+
{ "gap-1": icon && $$slots.default }
|
|
54
|
+
);
|
|
55
|
+
$:
|
|
56
|
+
iconStyles = clsx(
|
|
57
|
+
{
|
|
58
|
+
"text-neutral-500": ["default", "secondary"].includes(variant) && $$slots.default && !dangerIcon
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"text-neutral-800": ["default", "secondary"].includes(variant) && !$$slots.default && !dangerIcon
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"text-white-70": !["default", "secondary"].includes(variant) && $$slots.default && !dangerIcon
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"text-white": !["default", "secondary"].includes(variant) && !$$slots.default && !dangerIcon
|
|
68
|
+
},
|
|
69
|
+
{ "text-danger-500": dangerIcon }
|
|
70
|
+
);
|
|
71
|
+
$:
|
|
72
|
+
overlayClasses = clsx({
|
|
73
|
+
"rounded-md": !small,
|
|
74
|
+
rounded: small,
|
|
75
|
+
"group-hover:bg-black/[.16] group-active:bg-black/[.32]": ["primary", "danger"].includes(
|
|
76
|
+
variant
|
|
77
|
+
)
|
|
78
|
+
});
|
|
79
|
+
function handleClick(event) {
|
|
80
|
+
if (event instanceof CustomEvent)
|
|
81
|
+
return;
|
|
82
|
+
dispatch("click");
|
|
83
|
+
dispatchWcEvent(event.target, "click");
|
|
84
|
+
}
|
|
85
|
+
</script>
|
|
86
|
+
|
|
87
|
+
<button
|
|
88
|
+
{type}
|
|
89
|
+
{disabled}
|
|
90
|
+
class="{buttonStyles} flex items-center justify-center font-medium font-sans relative group tracking-tight"
|
|
91
|
+
{...$$restProps}
|
|
92
|
+
on:click|stopPropagation={handleClick}
|
|
93
|
+
>
|
|
94
|
+
<span class="{overlayClasses} absolute inset-0" />
|
|
95
|
+
{#if resolvedIcon}
|
|
96
|
+
{#if shortcut}
|
|
97
|
+
<ShortcutWrapper>
|
|
98
|
+
<Icon src={resolvedIcon} theme={iconTheme} class="{iconStyles} h-4 w-4 z-10" />
|
|
99
|
+
</ShortcutWrapper>
|
|
100
|
+
{:else}
|
|
101
|
+
<Icon src={resolvedIcon} theme={iconTheme} class="{iconStyles} h-4 w-4 z-10" />
|
|
102
|
+
{/if}
|
|
103
|
+
{/if}
|
|
104
|
+
{#if $$slots.default}
|
|
105
|
+
<span class="z-10"><slot /></span>
|
|
106
|
+
{/if}
|
|
107
|
+
</button>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
import type { ButtonVariant, IconPosition, IconTheme } from './types.ts';
|
|
3
|
+
import { type IconSource } from '@steeze-ui/svelte-icon';
|
|
4
|
+
declare const __propDef: {
|
|
5
|
+
props: {
|
|
6
|
+
[x: string]: any;
|
|
7
|
+
icon?: IconSource | string | undefined;
|
|
8
|
+
iconTheme?: IconTheme | undefined;
|
|
9
|
+
iconPosition?: IconPosition | undefined;
|
|
10
|
+
type?: 'button' | 'submit' | 'reset' | null | undefined;
|
|
11
|
+
variant?: ButtonVariant | undefined;
|
|
12
|
+
disabled?: boolean | undefined;
|
|
13
|
+
small?: boolean | undefined;
|
|
14
|
+
big?: boolean | undefined;
|
|
15
|
+
dangerIcon?: boolean | undefined;
|
|
16
|
+
shortcut?: boolean | undefined;
|
|
17
|
+
fullwidth?: boolean | undefined;
|
|
18
|
+
};
|
|
19
|
+
events: {
|
|
20
|
+
click: CustomEvent<any>;
|
|
21
|
+
} & {
|
|
22
|
+
[evt: string]: CustomEvent<any>;
|
|
23
|
+
};
|
|
24
|
+
slots: {
|
|
25
|
+
default: {};
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
export type BaseButtonProps = typeof __propDef.props;
|
|
29
|
+
export type BaseButtonEvents = typeof __propDef.events;
|
|
30
|
+
export type BaseButtonSlots = typeof __propDef.slots;
|
|
31
|
+
export default class BaseButton extends SvelteComponent<BaseButtonProps, BaseButtonEvents, BaseButtonSlots> {
|
|
32
|
+
}
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
<script>import TagBeta from "./TagBeta.svelte";
|
|
2
|
+
export let imageUrl = "";
|
|
3
|
+
export let imageAlt = "";
|
|
4
|
+
export let title = "";
|
|
5
|
+
export let description = "";
|
|
6
|
+
export let type = "default";
|
|
7
|
+
export let enabled = false;
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<button
|
|
11
|
+
class="rounded-lg bg-white hover:bg-neutral-100 focus:bg-neutral-200 disabled:bg-neutral-50 disabled:pointer-events-none border border-neutral-100 p-3 flex flex-col min-w-[298px] min-h-[126px] text-left"
|
|
12
|
+
disabled={type === 'soon'}
|
|
13
|
+
on:click
|
|
14
|
+
>
|
|
15
|
+
<div class="flex flex-col items-start justify-center space-y-2 w-full">
|
|
16
|
+
<div class="flex items-center justify-between w-full">
|
|
17
|
+
<div class="rounded-md bg-white border border-neutral-100 p-1.5">
|
|
18
|
+
<img class="h-5 w-5 flex-shrink-0" src={imageUrl} alt={imageAlt} />
|
|
19
|
+
</div>
|
|
20
|
+
<div class="flex items-center space-x-2">
|
|
21
|
+
{#if enabled}
|
|
22
|
+
<div
|
|
23
|
+
class="flex items-center space-x-1 rounded bg-neutral-50 border border-neutral-100 py-0.5 pl-1.5 pr-[5px] text-sm text-neutral-500 font-medium"
|
|
24
|
+
>
|
|
25
|
+
<div class="bg-positive-500 h-2 w-2 rounded-full" />
|
|
26
|
+
<span>Enabled</span>
|
|
27
|
+
</div>
|
|
28
|
+
{/if}
|
|
29
|
+
{#if type === 'beta'}
|
|
30
|
+
<TagBeta />
|
|
31
|
+
{:else if type === 'soon'}
|
|
32
|
+
<div
|
|
33
|
+
class="flex items-center space-x-1 rounded bg-neutral-50 border border-neutral-200 py-0.5 pl-1.5 pr-[5px] text-sm text-neutral-400 font-medium"
|
|
34
|
+
>
|
|
35
|
+
<span>Soon</span>
|
|
36
|
+
</div>
|
|
37
|
+
{/if}
|
|
38
|
+
</div>
|
|
39
|
+
</div>
|
|
40
|
+
<h3 class="truncate text-base font-medium text-neutral-800 tracking-tight">{title}</h3>
|
|
41
|
+
</div>
|
|
42
|
+
<p class="flex mt-0.5 text-base text-neutral-500 tracking-normal flex-1">
|
|
43
|
+
{description}
|
|
44
|
+
</p>
|
|
45
|
+
{#if $$slots.footer}
|
|
46
|
+
<div class="mt-5">
|
|
47
|
+
<slot name="footer" />
|
|
48
|
+
</div>
|
|
49
|
+
{/if}
|
|
50
|
+
</button>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
imageUrl?: string | undefined;
|
|
5
|
+
imageAlt?: string | undefined;
|
|
6
|
+
title?: string | undefined;
|
|
7
|
+
description?: string | undefined;
|
|
8
|
+
type?: "default" | "soon" | "beta" | undefined;
|
|
9
|
+
enabled?: boolean | undefined;
|
|
10
|
+
};
|
|
11
|
+
events: {
|
|
12
|
+
click: MouseEvent;
|
|
13
|
+
} & {
|
|
14
|
+
[evt: string]: CustomEvent<any>;
|
|
15
|
+
};
|
|
16
|
+
slots: {
|
|
17
|
+
footer: {};
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export type BaseCardProps = typeof __propDef.props;
|
|
21
|
+
export type BaseCardEvents = typeof __propDef.events;
|
|
22
|
+
export type BaseCardSlots = typeof __propDef.slots;
|
|
23
|
+
export default class BaseCard extends SvelteComponent<BaseCardProps, BaseCardEvents, BaseCardSlots> {
|
|
24
|
+
}
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<script>import clsx from "clsx";
|
|
2
|
+
export let content;
|
|
3
|
+
export let variant = "default";
|
|
4
|
+
$:
|
|
5
|
+
styles = clsx(
|
|
6
|
+
{ "bg-neutral-100": variant === "light" },
|
|
7
|
+
{ "bg-neutral-200": variant === "default" },
|
|
8
|
+
{ "bg-neutral-300": variant === "dark" }
|
|
9
|
+
);
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<div
|
|
13
|
+
class="{styles} inline-flex items-center justify-center rounded p-[3px] text-neutral-500 text-sm font-medium h-4 min-w-[16px] tracking-wide tabular-nums slashed-zero lining-nums"
|
|
14
|
+
>
|
|
15
|
+
{content}
|
|
16
|
+
</div>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
content: number;
|
|
5
|
+
variant?: "default" | "dark" | "light" | undefined;
|
|
6
|
+
};
|
|
7
|
+
events: {
|
|
8
|
+
[evt: string]: CustomEvent<any>;
|
|
9
|
+
};
|
|
10
|
+
slots: {};
|
|
11
|
+
};
|
|
12
|
+
export type BaseCounterProps = typeof __propDef.props;
|
|
13
|
+
export type BaseCounterEvents = typeof __propDef.events;
|
|
14
|
+
export type BaseCounterSlots = typeof __propDef.slots;
|
|
15
|
+
export default class BaseCounter extends SvelteComponent<BaseCounterProps, BaseCounterEvents, BaseCounterSlots> {
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
<script>import { offset, flip, shift } from "svelte-floating-ui/dom";
|
|
2
|
+
import { createFloatingActions } from "svelte-floating-ui";
|
|
3
|
+
import { clickOutside } from "./clickOutside.js";
|
|
4
|
+
export let isOpen = false;
|
|
5
|
+
export let fullWidth = false;
|
|
6
|
+
export let placement = "bottom-end";
|
|
7
|
+
const [floatingRef, floatingContent] = createFloatingActions({
|
|
8
|
+
strategy: "absolute",
|
|
9
|
+
placement,
|
|
10
|
+
middleware: [offset(6), flip(), shift()]
|
|
11
|
+
});
|
|
12
|
+
let closedFromClickOutside = false;
|
|
13
|
+
export const toggle = () => {
|
|
14
|
+
isOpen = !isOpen;
|
|
15
|
+
};
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<div class="inline-flex" class:w-full={fullWidth}>
|
|
19
|
+
<button
|
|
20
|
+
class="text-left"
|
|
21
|
+
use:floatingRef
|
|
22
|
+
on:click|stopPropagation={async () => {
|
|
23
|
+
if (closedFromClickOutside) return
|
|
24
|
+
isOpen = !isOpen
|
|
25
|
+
}}
|
|
26
|
+
class:w-full={fullWidth}
|
|
27
|
+
>
|
|
28
|
+
<slot name="trigger" />
|
|
29
|
+
</button>
|
|
30
|
+
{#if isOpen}
|
|
31
|
+
<div
|
|
32
|
+
class="max-h-40 absolute z-40"
|
|
33
|
+
use:floatingContent
|
|
34
|
+
use:clickOutside
|
|
35
|
+
on:click_outside={() => {
|
|
36
|
+
closedFromClickOutside = true
|
|
37
|
+
setTimeout(() => {
|
|
38
|
+
closedFromClickOutside = false
|
|
39
|
+
}, 100)
|
|
40
|
+
isOpen = false
|
|
41
|
+
}}
|
|
42
|
+
>
|
|
43
|
+
<slot />
|
|
44
|
+
</div>
|
|
45
|
+
{/if}
|
|
46
|
+
</div>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
import { type Placement } from 'svelte-floating-ui/dom';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
isOpen?: boolean | undefined;
|
|
6
|
+
fullWidth?: boolean | undefined;
|
|
7
|
+
placement?: Placement | undefined;
|
|
8
|
+
toggle?: (() => void) | undefined;
|
|
9
|
+
};
|
|
10
|
+
events: {
|
|
11
|
+
[evt: string]: CustomEvent<any>;
|
|
12
|
+
};
|
|
13
|
+
slots: {
|
|
14
|
+
trigger: {};
|
|
15
|
+
default: {};
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export type BaseDropdownProps = typeof __propDef.props;
|
|
19
|
+
export type BaseDropdownEvents = typeof __propDef.events;
|
|
20
|
+
export type BaseDropdownSlots = typeof __propDef.slots;
|
|
21
|
+
export default class BaseDropdown extends SvelteComponent<BaseDropdownProps, BaseDropdownEvents, BaseDropdownSlots> {
|
|
22
|
+
get toggle(): () => void;
|
|
23
|
+
}
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<script>import { World } from "@invopop/ui-icons";
|
|
2
|
+
import { Icon } from "@steeze-ui/svelte-icon";
|
|
3
|
+
export let country = "";
|
|
4
|
+
export let width = 12;
|
|
5
|
+
$:
|
|
6
|
+
iso = country.toLowerCase();
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
{#if country === 'global'}
|
|
10
|
+
<Icon src={World} style={`width: ${width}px;`} />
|
|
11
|
+
{:else}
|
|
12
|
+
<!-- https://github.com/HatScripts/circle-flags -->
|
|
13
|
+
<img src={`https://hatscripts.github.io/circle-flags/flags/${iso}.svg`} alt={country} {width} />
|
|
14
|
+
{/if}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
country?: string | undefined;
|
|
5
|
+
width?: number | undefined;
|
|
6
|
+
};
|
|
7
|
+
events: {
|
|
8
|
+
[evt: string]: CustomEvent<any>;
|
|
9
|
+
};
|
|
10
|
+
slots: {};
|
|
11
|
+
};
|
|
12
|
+
export type BaseFlagProps = typeof __propDef.props;
|
|
13
|
+
export type BaseFlagEvents = typeof __propDef.events;
|
|
14
|
+
export type BaseFlagSlots = typeof __propDef.slots;
|
|
15
|
+
export default class BaseFlag extends SvelteComponent<BaseFlagProps, BaseFlagEvents, BaseFlagSlots> {
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
<script>import { intersect } from "svelte-intersection-observer-action";
|
|
2
|
+
import BaseTableHeader from "./BaseTableHeader.svelte";
|
|
3
|
+
import { createEventDispatcher } from "svelte";
|
|
4
|
+
import BaseCounter from "./BaseCounter.svelte";
|
|
5
|
+
import BaseTableRow from "./BaseTableRow.svelte";
|
|
6
|
+
import BaseTableCell from "./BaseTableCell.svelte";
|
|
7
|
+
const dispatch = createEventDispatcher();
|
|
8
|
+
const callback = (entry) => {
|
|
9
|
+
if (entry.intersectionRatio && entry.isIntersecting) {
|
|
10
|
+
dispatch("tableEndReached");
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
const intersectOptions = { callback };
|
|
14
|
+
let metaKeyPressed = false;
|
|
15
|
+
export let sortBy = "";
|
|
16
|
+
export let sortDirection = "";
|
|
17
|
+
export let fields = [];
|
|
18
|
+
export let data = [];
|
|
19
|
+
export let getActions = void 0;
|
|
20
|
+
export let groupLabel = void 0;
|
|
21
|
+
export let disableRowClick = false;
|
|
22
|
+
export let hideCounter = false;
|
|
23
|
+
export let freeWrap = false;
|
|
24
|
+
$:
|
|
25
|
+
groupedData = groupData(data);
|
|
26
|
+
$:
|
|
27
|
+
addExtraCell = getActions instanceof Function;
|
|
28
|
+
function groupData(rows) {
|
|
29
|
+
if (rows.length === 0)
|
|
30
|
+
return [];
|
|
31
|
+
const groups = [];
|
|
32
|
+
rows.forEach((row) => {
|
|
33
|
+
const rowLabel = groupLabel instanceof Function ? groupLabel(row) : "";
|
|
34
|
+
const groupExist = groups.find((g) => g.label === rowLabel);
|
|
35
|
+
if (groupExist) {
|
|
36
|
+
groupExist.rows.push(row);
|
|
37
|
+
} else {
|
|
38
|
+
groups.push({ label: rowLabel, rows: [row] });
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
return groups;
|
|
42
|
+
}
|
|
43
|
+
</script>
|
|
44
|
+
|
|
45
|
+
<svelte:window
|
|
46
|
+
on:keydown={(event) => {
|
|
47
|
+
metaKeyPressed = event.metaKey
|
|
48
|
+
}}
|
|
49
|
+
on:keyup={() => {
|
|
50
|
+
metaKeyPressed = false
|
|
51
|
+
}}
|
|
52
|
+
/>
|
|
53
|
+
|
|
54
|
+
<div class="w-full rounded-md md:border border-neutral-100 font-sans">
|
|
55
|
+
<table class="hidden md:table w-full rounded-md">
|
|
56
|
+
<thead>
|
|
57
|
+
<tr class="border-b border-neutral-100 relative">
|
|
58
|
+
{#each fields as field, i (i)}
|
|
59
|
+
<BaseTableHeader
|
|
60
|
+
isFirst={i === 0}
|
|
61
|
+
isLast={!addExtraCell && i === fields.length - 1}
|
|
62
|
+
{sortBy}
|
|
63
|
+
{sortDirection}
|
|
64
|
+
{field}
|
|
65
|
+
on:orderBy
|
|
66
|
+
/>
|
|
67
|
+
{/each}
|
|
68
|
+
{#if addExtraCell}
|
|
69
|
+
<!-- if table has actions cell we need to add an extra header -->
|
|
70
|
+
<th scope="col" class="bg-white sticky top-0 z-10 rounded-tr-md" />
|
|
71
|
+
{/if}
|
|
72
|
+
</tr>
|
|
73
|
+
</thead>
|
|
74
|
+
<tbody>
|
|
75
|
+
{#each groupedData as group}
|
|
76
|
+
{#if group.label}
|
|
77
|
+
<tr>
|
|
78
|
+
<th
|
|
79
|
+
scope="colgroup"
|
|
80
|
+
colspan={fields.length + 1}
|
|
81
|
+
class="bg-neutral-50 px-3 py-1.5 text-left text-sm font-medium text-neutral-500 sticky top-11 tracking-normal border-t border-b border-neutral-100 h-8"
|
|
82
|
+
>
|
|
83
|
+
<span>{group.label}</span>
|
|
84
|
+
{#if !hideCounter}
|
|
85
|
+
<BaseCounter content={group.rows.length} />
|
|
86
|
+
{/if}
|
|
87
|
+
</th>
|
|
88
|
+
</tr>
|
|
89
|
+
{/if}
|
|
90
|
+
{#each group.rows as row}
|
|
91
|
+
<BaseTableRow
|
|
92
|
+
{row}
|
|
93
|
+
{fields}
|
|
94
|
+
{getActions}
|
|
95
|
+
{disableRowClick}
|
|
96
|
+
{freeWrap}
|
|
97
|
+
on:click={() => {
|
|
98
|
+
if (disableRowClick) return
|
|
99
|
+
|
|
100
|
+
if (metaKeyPressed) {
|
|
101
|
+
dispatch('rowNewTabClick', row)
|
|
102
|
+
} else {
|
|
103
|
+
dispatch('rowClick', row)
|
|
104
|
+
}
|
|
105
|
+
}}
|
|
106
|
+
on:contextmenu={() => {
|
|
107
|
+
dispatch('rowRightClick', row)
|
|
108
|
+
}}
|
|
109
|
+
on:action
|
|
110
|
+
on:copied
|
|
111
|
+
/>
|
|
112
|
+
{/each}
|
|
113
|
+
{/each}
|
|
114
|
+
</tbody>
|
|
115
|
+
</table>
|
|
116
|
+
<div class="md:hidden space-y-3">
|
|
117
|
+
{#each groupedData as group}
|
|
118
|
+
{#each group.rows as row}
|
|
119
|
+
<button
|
|
120
|
+
class:cursor-default={disableRowClick}
|
|
121
|
+
class="w-full text-left border border-neutral-200 rounded"
|
|
122
|
+
on:click={() => {
|
|
123
|
+
if (disableRowClick) return
|
|
124
|
+
|
|
125
|
+
if (metaKeyPressed) {
|
|
126
|
+
dispatch('rowNewTabClick', row)
|
|
127
|
+
} else {
|
|
128
|
+
dispatch('rowClick', row)
|
|
129
|
+
}
|
|
130
|
+
}}
|
|
131
|
+
>
|
|
132
|
+
{#each fields as field, i (i)}
|
|
133
|
+
<BaseTableCell
|
|
134
|
+
tag="div"
|
|
135
|
+
currentIndex={i}
|
|
136
|
+
{field}
|
|
137
|
+
badge={field.helperBadge ? field.helperBadge(row) : null}
|
|
138
|
+
status={field.helperStatus ? field.helperStatus(row) : null}
|
|
139
|
+
data={field.formatter ? field.formatter(row) : row[field.slug] || ''}
|
|
140
|
+
on:copied
|
|
141
|
+
/>
|
|
142
|
+
{/each}
|
|
143
|
+
</button>
|
|
144
|
+
{/each}
|
|
145
|
+
{/each}
|
|
146
|
+
</div>
|
|
147
|
+
<div use:intersect={intersectOptions} />
|
|
148
|
+
</div>
|