@bexis2/bexis2-core-ui 0.2.22 → 0.2.24

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 CHANGED
@@ -1,21 +1,31 @@
1
1
  # bexis-core-ui
2
+ ## 0.2.24
3
+ - add ids to table and code editor components
4
+
5
+ ## 0.2.23
6
+
7
+ - add CodeEditor component
8
+
2
9
  ## 0.2.22
10
+
3
11
  - Page title update on breadcrumb
4
12
 
5
13
  ## v0.2.19
14
+
6
15
  - fix multiselect bug from prev version
7
16
 
8
17
  ## v0.2.18
18
+
9
19
  - Multiselect
10
20
  - fix target bug with simple list and list of simple values
11
-
12
- - CodeEditor component
13
21
 
14
22
  ## v0.2.17
23
+
15
24
  - Multiselect
16
25
  - fix target bind bug
17
26
 
18
27
  ## v0.2.16
28
+
19
29
  - Table
20
30
  - width - fit to screen
21
31
  - Cell - drag to change the height
@@ -25,7 +35,7 @@
25
35
  ## v0.2.15
26
36
 
27
37
  - Page - centered -> min width defined
28
- - MultiSelect -> add clearable
38
+ - MultiSelect -> add clearable
29
39
 
30
40
  ## v0.2.14
31
41
 
@@ -66,13 +76,13 @@
66
76
 
67
77
  ## v0.2.1
68
78
 
69
- > refactoring based on naming conventions (https://bexis2.github.io/bexis2-core-ui/code/naming/)
79
+ > refactoring based on naming conventions (<https://bexis2.github.io/bexis2-core-ui/code/naming/>)
70
80
 
71
81
  - fix issue in index.ts file for export components
72
82
 
73
83
  ## v0.2.0
74
84
 
75
- > refactoring based on naming conventions (https://bexis2.github.io/bexis2-core-ui/code/naming/)
85
+ > refactoring based on naming conventions (<https://bexis2.github.io/bexis2-core-ui/code/naming/>)
76
86
 
77
87
  - add Help, helpStore
78
88
  - update Page
@@ -219,7 +229,7 @@
219
229
  - Disabling of filters
220
230
  - Disabling of sorting
221
231
 
222
- ### fixes:
232
+ ### fixes
223
233
 
224
234
  #### table
225
235
 
@@ -0,0 +1,99 @@
1
+ <script>import { createEventDispatcher } from "svelte";
2
+ import CodeMirror from "svelte-codemirror-editor";
3
+ import Fa from "svelte-fa/src/fa.svelte";
4
+ import { html } from "@codemirror/lang-html";
5
+ import { javascript } from "@codemirror/lang-javascript";
6
+ import { json } from "@codemirror/lang-json";
7
+ import { oneDark } from "@codemirror/theme-one-dark";
8
+ import { Modal, modalStore } from "@skeletonlabs/skeleton";
9
+ import { faMoon, faSave, faSun } from "@fortawesome/free-regular-svg-icons";
10
+ import { faArrowRotateLeft, faXmark } from "@fortawesome/free-solid-svg-icons";
11
+ export let id;
12
+ export let title = "";
13
+ export let initialValue = "";
14
+ export let value = initialValue;
15
+ export let language = "html";
16
+ export let dark = true;
17
+ export let toggle = true;
18
+ export let actions = true;
19
+ export let styles = {
20
+ "&": {
21
+ borderRadius: "0.5rem",
22
+ width: "100%"
23
+ },
24
+ ".cm-scroller": {
25
+ borderRadius: "0.5rem"
26
+ }
27
+ };
28
+ const dispatch = createEventDispatcher();
29
+ const modal = {
30
+ type: "confirm",
31
+ title: "Reset",
32
+ body: "Unsaved changes will be lost. Are you sure you want to continue?",
33
+ response: (r) => r ? value = initialValue : null
34
+ };
35
+ </script>
36
+
37
+ <div class="items-center justify-center">
38
+
39
+ <h1 class="h1 font-semibold text-primary-500 mb-3" id="{id}-title">{title}</h1>
40
+ <slot id="{id}-description" />
41
+ <div class="grid gap-1 w-full h-full mt-5">
42
+ <div class="rounded-lg shadow-lg w-full" id="{id}-editor">
43
+ <CodeMirror
44
+ bind:value
45
+ lang={language === 'html'
46
+ ? html({ selfClosingTags: true })
47
+ : language === 'js'
48
+ ? javascript()
49
+ : json()}
50
+ theme={dark ? oneDark : null}
51
+ class="flex w-full"
52
+ {styles}
53
+ />
54
+ </div>
55
+ </div>
56
+
57
+
58
+ <div class="flex justify-between gap-2 items-center mt-3" id="{id}-footer">
59
+ <div class="flex gap-2">
60
+ <button
61
+ class="btn variant-filled-warning"
62
+ id="{id}-reset"
63
+ on:click|preventDefault={() => modalStore.trigger(modal)}
64
+ ><Fa icon={faArrowRotateLeft} /></button
65
+ >{#if toggle}
66
+ <button
67
+ class="btn border"
68
+ class:bg-slate-700={dark}
69
+ class:bg-white={!dark}
70
+ id="{id}-toggle"
71
+ on:click|preventDefault={() => (dark = !dark)}
72
+ >
73
+ {#if dark}
74
+ <Fa icon={faMoon} color="white" />
75
+ {:else}
76
+ <Fa icon={faSun} color="black" />
77
+ {/if}
78
+ </button>
79
+ {/if}
80
+ </div>
81
+
82
+ {#if actions}
83
+ <div class="flex gap-2">
84
+ <button
85
+ class="btn variant-filled-warning"
86
+ id="{id}-cancel"
87
+ on:click|preventDefault={() => dispatch('cancel')}><Fa icon={faXmark} /></button
88
+ >
89
+ <button
90
+ class="btn variant-filled-primary"
91
+ id="{id}-save"
92
+ on:click|preventDefault={() => dispatch('save')}><Fa icon={faSave} /></button
93
+ >
94
+ </div>
95
+ {/if}
96
+ </div>
97
+ </div>
98
+
99
+ <Modal />
@@ -0,0 +1,31 @@
1
+ import { SvelteComponentTyped } from "svelte";
2
+ declare const __propDef: {
3
+ props: {
4
+ id: string;
5
+ title?: string | undefined;
6
+ initialValue?: string | undefined;
7
+ value?: string | undefined;
8
+ language?: string | undefined;
9
+ dark?: boolean | undefined;
10
+ toggle?: boolean | undefined;
11
+ actions?: boolean | undefined;
12
+ styles?: any;
13
+ };
14
+ events: {
15
+ cancel: CustomEvent<any>;
16
+ save: CustomEvent<any>;
17
+ } & {
18
+ [evt: string]: CustomEvent<any>;
19
+ };
20
+ slots: {
21
+ default: {
22
+ id: string;
23
+ };
24
+ };
25
+ };
26
+ export type CodeEditorProps = typeof __propDef.props;
27
+ export type CodeEditorEvents = typeof __propDef.events;
28
+ export type CodeEditorSlots = typeof __propDef.slots;
29
+ export default class CodeEditor extends SvelteComponentTyped<CodeEditorProps, CodeEditorEvents, CodeEditorSlots> {
30
+ }
31
+ export {};
@@ -21,9 +21,10 @@ let {
21
21
  height = null,
22
22
  optionsComponent,
23
23
  defaultPageSize = 10,
24
- pageSizes = [5, 10, 15, 20]
24
+ toggle = false,
25
+ pageSizes = [5, 10, 15, 20],
26
+ fitToScreen = true
25
27
  } = config;
26
- let fitToScreen = true;
27
28
  const dispatch = createEventDispatcher();
28
29
  const actionDispatcher = (obj) => dispatch("action", obj);
29
30
  const table = createTable(data, {
@@ -116,7 +117,7 @@ const tableColumns = [
116
117
  if (optionsComponent !== void 0) {
117
118
  tableColumns.push(
118
119
  table.display({
119
- id: "options",
120
+ id: "actionsColumn",
120
121
  header: "",
121
122
  cell: ({ row }, _) => {
122
123
  return createRender(optionsComponent, {
@@ -132,7 +133,7 @@ const { headerRows, pageRows, tableAttrs, tableBodyAttrs, pluginStates } = table
132
133
  const { filterValue } = pluginStates.tableFilter;
133
134
  </script>
134
135
 
135
- <div class="grid gap-2 overflow-auto" class:w-max={!fitToScreen} class:w-full={fitToScreen}>
136
+ <div class="grid gap-2 overflow-auto" class:w-fit={!fitToScreen} class:w-full={fitToScreen}>
136
137
  <div class="table-container">
137
138
  {#if $data.length > 0}
138
139
  <input
@@ -140,18 +141,27 @@ const { filterValue } = pluginStates.tableFilter;
140
141
  type="text"
141
142
  bind:value={$filterValue}
142
143
  placeholder="Search rows..."
144
+ id="{tableId}-search"
143
145
  />
144
146
  {/if}
145
- <SlideToggle
146
- name="slider-label"
147
- active="bg-primary-500"
148
- size="sm"
149
- checked={fitToScreen}
150
- on:change={() => (fitToScreen = !fitToScreen)}>Fit to screen</SlideToggle
151
- >
147
+
148
+ {#if toggle}
149
+ <SlideToggle
150
+ name="slider-label"
151
+ active="bg-primary-500"
152
+ size="sm"
153
+ checked={fitToScreen}
154
+ id="{tableId}-toggle"
155
+ on:change={() => (fitToScreen = !fitToScreen)}>Fit to screen</SlideToggle
156
+ >
157
+ {/if}
152
158
 
153
159
  <div class="overflow-auto" style="height: {height}px">
154
- <table {...$tableAttrs} class="table table-compact bg-tertiary-200 overflow-clip">
160
+ <table
161
+ {...$tableAttrs}
162
+ class="table table-compact bg-tertiary-200 overflow-clip"
163
+ id="{tableId}-table"
164
+ >
155
165
  <thead class={height != null ? `sticky top-0` : ''}>
156
166
  {#each $headerRows as headerRow (headerRow.id)}
157
167
  <Subscribe
@@ -204,10 +214,10 @@ const { filterValue } = pluginStates.tableFilter;
204
214
  <tbody class="overflow-auto" {...$tableBodyAttrs}>
205
215
  {#each $pageRows as row (row.id)}
206
216
  <Subscribe rowAttrs={row.attrs()} let:rowAttrs>
207
- <tr {...rowAttrs}>
217
+ <tr {...rowAttrs} id="{tableId}-row-{row.id}">
208
218
  {#each row.cells as cell (cell?.id)}
209
219
  <Subscribe attrs={cell.attrs()} let:attrs>
210
- <td {...attrs} class="!p-2 w-max focus:resize">
220
+ <td {...attrs} class="!p-2 w-max focus:resize" id="{tableId}-{cell.id}-{row.id}">
211
221
  <div
212
222
  class="flex items-center h-max overflow-x-auto resize-none hover:resize"
213
223
  class:max-w-md={!fitToScreen}
@@ -225,6 +235,6 @@ const { filterValue } = pluginStates.tableFilter;
225
235
  </div>
226
236
  </div>
227
237
  {#if $data.length > 0}
228
- <TablePagination pageConfig={pluginStates.page} {pageSizes} />
238
+ <TablePagination pageConfig={pluginStates.page} {pageSizes} id={tableId} />
229
239
  {/if}
230
240
  </div>
@@ -111,11 +111,12 @@ if (type === "object") {
111
111
  class="btn w-max p-2"
112
112
  type="button"
113
113
  use:popup={popupFeatured}
114
+ id="{popupId}-button"
114
115
  >
115
116
  <Fa icon={faFilter} size="12" />
116
117
  </button>
117
118
 
118
- <div data-popup={`${popupId}`} class="z-50">
119
+ <div data-popup={`${popupId}`} id="{popupId}" class="z-50">
119
120
  <div class="card p-3 grid gap-2 shadow-lg w-min bg-base-100">
120
121
  <button
121
122
  class="btn variant-filled-primary btn-sm"
@@ -7,6 +7,7 @@ import {
7
7
  } from "@fortawesome/free-solid-svg-icons";
8
8
  export let pageConfig;
9
9
  export let pageSizes;
10
+ export let id;
10
11
  const { pageIndex, pageCount, pageSize, hasNextPage, hasPreviousPage } = pageConfig;
11
12
  const goToFirstPage = () => $pageIndex = 0;
12
13
  const goToLastPage = () => $pageIndex = $pageCount - 1;
@@ -20,41 +21,45 @@ $:
20
21
  goToNextPageDisabled = !$hasNextPage;
21
22
  $:
22
23
  goToPreviousPageDisabled = !$hasPreviousPage;
23
- </script>
24
-
25
- <div class="flex justify-center gap-1">
26
- <button
27
- class="btn btn-sm variant-filled-primary"
28
- on:click|preventDefault={goToFirstPage}
29
- disabled={goToFirstPageDisabled}
30
- >
31
- <Fa icon={faAnglesLeft} /></button
32
- >
33
- <button
34
- class="btn btn-sm variant-filled-primary"
35
- on:click|preventDefault={goToPreviousPage}
36
- disabled={goToPreviousPageDisabled}><Fa icon={faAngleLeft} /></button
37
- >
38
-
39
- <select
40
- name="pageSize"
41
- id="pageSize"
42
- class="select variant-filled-primary w-min font-bold"
43
- bind:value={$pageSize}
44
- >
45
- {#each pageSizes as size}
46
- <option value={size}>{size}</option>
47
- {/each}
48
- </select>
49
-
50
- <button
51
- class="btn btn-sm variant-filled-primary"
52
- on:click|preventDefault={goToNextPage}
53
- disabled={goToNextPageDisabled}><Fa icon={faAngleRight} /></button
54
- >
55
- <button
56
- class="btn btn-sm variant-filled-primary"
57
- on:click|preventDefault={goToLastPage}
58
- disabled={goToLastPageDisabled}><Fa icon={faAnglesRight} /></button
59
- >
60
- </div>
24
+ </script>
25
+
26
+ <div class="flex justify-center gap-1">
27
+ <button
28
+ class="btn btn-sm variant-filled-primary"
29
+ on:click|preventDefault={goToFirstPage}
30
+ disabled={goToFirstPageDisabled}
31
+ id="{id}-first"
32
+ >
33
+ <Fa icon={faAnglesLeft} /></button
34
+ >
35
+ <button
36
+ class="btn btn-sm variant-filled-primary"
37
+ id="{id}-previous"
38
+ on:click|preventDefault={goToPreviousPage}
39
+ disabled={goToPreviousPageDisabled}><Fa icon={faAngleLeft} /></button
40
+ >
41
+
42
+ <select
43
+ name="pageSize"
44
+ id="{id}-pageSize"
45
+ class="select variant-filled-primary w-min font-bold"
46
+ bind:value={$pageSize}
47
+ >
48
+ {#each pageSizes as size}
49
+ <option value={size}>{size}</option>
50
+ {/each}
51
+ </select>
52
+
53
+ <button
54
+ class="btn btn-sm variant-filled-primary"
55
+ id="{id}-next"
56
+ on:click|preventDefault={goToNextPage}
57
+ disabled={goToNextPageDisabled}><Fa icon={faAngleRight} /></button
58
+ >
59
+ <button
60
+ class="btn btn-sm variant-filled-primary"
61
+ id="{id}-last"
62
+ on:click|preventDefault={goToLastPage}
63
+ disabled={goToLastPageDisabled}><Fa icon={faAnglesRight} /></button
64
+ >
65
+ </div>
@@ -3,6 +3,7 @@ declare const __propDef: {
3
3
  props: {
4
4
  pageConfig: any;
5
5
  pageSizes: any;
6
+ id: any;
6
7
  };
7
8
  events: {
8
9
  [evt: string]: CustomEvent<any>;
@@ -103,7 +103,7 @@ async function handleSubmit() {
103
103
  <b style="font-size:xx-large"><Fa icon={faFileUpload} /></b>
104
104
  <span
105
105
  ><b>Drag 'n' drop some files here, or click to select files</b>
106
- <b>max file : {model.maxSize} mb</b></span
106
+ <b>(max file size: {model.maxSize} mb)</b></span
107
107
  >
108
108
  <p>
109
109
  {#if model.accept}
@@ -11,23 +11,23 @@ function onMouseOver() {
11
11
  }
12
12
  function onMouseOut() {
13
13
  }
14
- </script>
15
-
16
- <div {id} on:mouseover={onMouseOver} on:mouseout={onMouseOut}>
17
- <label class="label">
18
- <span
19
- >{label}
20
- {#if required} <span class="text-sm text-red-600">*</span> {/if}
21
- </span>
22
- <slot />
23
- {#if feedback}
24
- <span class="text-sm text-error-600">
25
- <ul>
26
- {#each feedback as message}
27
- <li>{message}</li>
28
- {/each}
29
- </ul>
30
- </span>
31
- {/if}
32
- </label>
33
- </div>
14
+ </script>
15
+
16
+ <div id="{id}-container" on:mouseover={onMouseOver} on:mouseout={onMouseOut}>
17
+ <label class="label">
18
+ <span
19
+ >{label}
20
+ {#if required} <span class="text-sm text-red-600">*</span> {/if}
21
+ </span>
22
+ <slot />
23
+ {#if feedback}
24
+ <span class="text-sm text-error-600">
25
+ <ul>
26
+ {#each feedback as message}
27
+ <li>{message}</li>
28
+ {/each}
29
+ </ul>
30
+ </span>
31
+ {/if}
32
+ </label>
33
+ </div>
package/dist/index.d.ts CHANGED
@@ -19,6 +19,7 @@ import Table from './components/Table/Table.svelte';
19
19
  import TableFilter from './components/Table/TableFilter.svelte';
20
20
  import { columnFilter, searchFilter } from './components/Table/filter';
21
21
  import type { TableConfig, Columns, Column } from './models/Models';
22
+ import CodeEditor from './components/CodeEditor/CodeEditor.svelte';
22
23
  import Notification from './components/page/Notification.svelte';
23
24
  import TablePlaceholder from './components/page/TablePlaceholder.svelte';
24
25
  export { Checkbox, CheckboxKVPList, CheckboxList, DateInput, DropdownKVP, MultiSelect, NumberInput, TextArea, TextInput };
@@ -36,4 +37,5 @@ export { Notification };
36
37
  export { TablePlaceholder };
37
38
  export { positionType, pageContentLayoutType, decimalCharacterType, orientationType, textMarkerType, textSeperatorType } from './models/Enums';
38
39
  export { Table, TableFilter, columnFilter, searchFilter };
40
+ export { CodeEditor };
39
41
  export type { TableConfig, Columns, Column };
package/dist/index.js CHANGED
@@ -24,6 +24,8 @@ import TextArea from './components/form/TextArea.svelte';
24
24
  import Table from './components/Table/Table.svelte';
25
25
  import TableFilter from './components/Table/TableFilter.svelte';
26
26
  import { columnFilter, searchFilter } from './components/Table/filter';
27
+ // CodeEditor
28
+ import CodeEditor from './components/CodeEditor/CodeEditor.svelte';
27
29
  //notification
28
30
  import Notification from './components/page/Notification.svelte';
29
31
  //table placeholder
@@ -49,3 +51,5 @@ export { TablePlaceholder };
49
51
  export { positionType, pageContentLayoutType, decimalCharacterType, orientationType, textMarkerType, textSeperatorType } from './models/Enums';
50
52
  // Table
51
53
  export { Table, TableFilter, columnFilter, searchFilter };
54
+ // CodeEditor
55
+ export { CodeEditor };
@@ -81,6 +81,8 @@ export interface Columns {
81
81
  export interface TableConfig<T> {
82
82
  id: string;
83
83
  data: Writable<T[]>;
84
+ toggle?: boolean;
85
+ fitToScreen?: boolean;
84
86
  height?: null | number;
85
87
  columns?: Columns;
86
88
  pageSizes?: number[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bexis2/bexis2-core-ui",
3
- "version": "0.2.22",
3
+ "version": "0.2.24",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "dev": "vite dev",
@@ -19,7 +19,7 @@
19
19
  "publish": "npm publish --access public"
20
20
  },
21
21
  "devDependencies": {
22
- "@playwright/test": "^1.28.1",
22
+ "@playwright/test": "^1.36.2",
23
23
  "@skeletonlabs/skeleton": "^1.9.0",
24
24
  "@sveltejs/adapter-auto": "^2.0.0",
25
25
  "@sveltejs/adapter-static": "^2.0.2",
@@ -58,16 +58,23 @@
58
58
  "src/lib"
59
59
  ],
60
60
  "dependencies": {
61
+ "@codemirror/lang-html": "^6.4.5",
62
+ "@codemirror/lang-javascript": "^6.1.9",
63
+ "@codemirror/lang-json": "^6.0.1",
64
+ "@codemirror/theme-one-dark": "^6.1.2",
61
65
  "@floating-ui/dom": "^1.2.7",
62
66
  "@fortawesome/fontawesome-free": "^6.2.1",
63
67
  "@fortawesome/fontawesome-svg-core": "^6.2.1",
64
68
  "@fortawesome/free-regular-svg-icons": "^6.2.1",
65
69
  "@fortawesome/free-solid-svg-icons": "^6.2.1",
66
70
  "axios": "^1.2.1",
71
+ "codemirror": "^6.0.1",
67
72
  "delay": "^6.0.0",
73
+ "dotenv": "^16.3.1",
68
74
  "highlight.js": "^11.8.0",
69
75
  "highlightjs-svelte": "^1.0.6",
70
76
  "svelte": "^3.54.0",
77
+ "svelte-codemirror-editor": "^1.1.0",
71
78
  "svelte-fa": "^3.0.4",
72
79
  "svelte-file-dropzone": "^2.0.1",
73
80
  "svelte-headless-table": "^0.17.3",
@@ -0,0 +1,106 @@
1
+ <script lang="ts">
2
+ import { createEventDispatcher } from 'svelte';
3
+
4
+ import CodeMirror from 'svelte-codemirror-editor';
5
+ import Fa from 'svelte-fa/src/fa.svelte';
6
+ import { html } from '@codemirror/lang-html';
7
+ import { javascript } from '@codemirror/lang-javascript';
8
+ import { json } from '@codemirror/lang-json';
9
+ import { oneDark } from '@codemirror/theme-one-dark';
10
+ import { Modal, modalStore } from '@skeletonlabs/skeleton';
11
+ import { faMoon, faSave, faSun } from '@fortawesome/free-regular-svg-icons';
12
+ import { faArrowRotateLeft, faXmark } from '@fortawesome/free-solid-svg-icons';
13
+ import type { ThemeSpec } from 'svelte-codemirror-editor';
14
+ import type { ModalSettings } from '@skeletonlabs/skeleton';
15
+
16
+ export let id: string;
17
+ export let title = '';
18
+ export let initialValue = '';
19
+ export let value = initialValue;
20
+ export let language = 'html';
21
+ export let dark = true;
22
+ export let toggle = true;
23
+ export let actions = true;
24
+ export let styles: ThemeSpec = {
25
+ '&': {
26
+ borderRadius: '0.5rem',
27
+ width: '100%'
28
+ },
29
+ '.cm-scroller': {
30
+ borderRadius: '0.5rem'
31
+ }
32
+ };
33
+
34
+ const dispatch = createEventDispatcher();
35
+
36
+ const modal: ModalSettings = {
37
+ type: 'confirm',
38
+ title: 'Reset',
39
+ body: 'Unsaved changes will be lost. Are you sure you want to continue?',
40
+ response: (r: boolean) => (r ? (value = initialValue) : null)
41
+ };
42
+ </script>
43
+
44
+ <div class="items-center justify-center">
45
+
46
+ <h1 class="h1 font-semibold text-primary-500 mb-3" id="{id}-title">{title}</h1>
47
+ <slot id="{id}-description" />
48
+ <div class="grid gap-1 w-full h-full mt-5">
49
+ <div class="rounded-lg shadow-lg w-full" id="{id}-editor">
50
+ <CodeMirror
51
+ bind:value
52
+ lang={language === 'html'
53
+ ? html({ selfClosingTags: true })
54
+ : language === 'js'
55
+ ? javascript()
56
+ : json()}
57
+ theme={dark ? oneDark : null}
58
+ class="flex w-full"
59
+ {styles}
60
+ />
61
+ </div>
62
+ </div>
63
+
64
+
65
+ <div class="flex justify-between gap-2 items-center mt-3" id="{id}-footer">
66
+ <div class="flex gap-2">
67
+ <button
68
+ class="btn variant-filled-warning"
69
+ id="{id}-reset"
70
+ on:click|preventDefault={() => modalStore.trigger(modal)}
71
+ ><Fa icon={faArrowRotateLeft} /></button
72
+ >{#if toggle}
73
+ <button
74
+ class="btn border"
75
+ class:bg-slate-700={dark}
76
+ class:bg-white={!dark}
77
+ id="{id}-toggle"
78
+ on:click|preventDefault={() => (dark = !dark)}
79
+ >
80
+ {#if dark}
81
+ <Fa icon={faMoon} color="white" />
82
+ {:else}
83
+ <Fa icon={faSun} color="black" />
84
+ {/if}
85
+ </button>
86
+ {/if}
87
+ </div>
88
+
89
+ {#if actions}
90
+ <div class="flex gap-2">
91
+ <button
92
+ class="btn variant-filled-warning"
93
+ id="{id}-cancel"
94
+ on:click|preventDefault={() => dispatch('cancel')}><Fa icon={faXmark} /></button
95
+ >
96
+ <button
97
+ class="btn variant-filled-primary"
98
+ id="{id}-save"
99
+ on:click|preventDefault={() => dispatch('save')}><Fa icon={faSave} /></button
100
+ >
101
+ </div>
102
+ {/if}
103
+ </div>
104
+ </div>
105
+
106
+ <Modal />
@@ -27,9 +27,10 @@
27
27
  height = null,
28
28
  optionsComponent,
29
29
  defaultPageSize = 10,
30
- pageSizes = [5, 10, 15, 20]
30
+ toggle = false,
31
+ pageSizes = [5, 10, 15, 20],
32
+ fitToScreen = true
31
33
  } = config;
32
- let fitToScreen = true;
33
34
 
34
35
  type AccessorType = keyof (typeof $data)[number];
35
36
 
@@ -145,7 +146,7 @@
145
146
  if (optionsComponent !== undefined) {
146
147
  tableColumns.push(
147
148
  table.display({
148
- id: 'options',
149
+ id: 'actionsColumn',
149
150
  header: '',
150
151
  cell: ({ row }, _) => {
151
152
  return createRender(optionsComponent!, {
@@ -164,7 +165,7 @@
164
165
  const { filterValue } = pluginStates.tableFilter;
165
166
  </script>
166
167
 
167
- <div class="grid gap-2 overflow-auto" class:w-max={!fitToScreen} class:w-full={fitToScreen}>
168
+ <div class="grid gap-2 overflow-auto" class:w-fit={!fitToScreen} class:w-full={fitToScreen}>
168
169
  <div class="table-container">
169
170
  {#if $data.length > 0}
170
171
  <input
@@ -172,18 +173,27 @@
172
173
  type="text"
173
174
  bind:value={$filterValue}
174
175
  placeholder="Search rows..."
176
+ id="{tableId}-search"
175
177
  />
176
178
  {/if}
177
- <SlideToggle
178
- name="slider-label"
179
- active="bg-primary-500"
180
- size="sm"
181
- checked={fitToScreen}
182
- on:change={() => (fitToScreen = !fitToScreen)}>Fit to screen</SlideToggle
183
- >
179
+
180
+ {#if toggle}
181
+ <SlideToggle
182
+ name="slider-label"
183
+ active="bg-primary-500"
184
+ size="sm"
185
+ checked={fitToScreen}
186
+ id="{tableId}-toggle"
187
+ on:change={() => (fitToScreen = !fitToScreen)}>Fit to screen</SlideToggle
188
+ >
189
+ {/if}
184
190
 
185
191
  <div class="overflow-auto" style="height: {height}px">
186
- <table {...$tableAttrs} class="table table-compact bg-tertiary-200 overflow-clip">
192
+ <table
193
+ {...$tableAttrs}
194
+ class="table table-compact bg-tertiary-200 overflow-clip"
195
+ id="{tableId}-table"
196
+ >
187
197
  <thead class={height != null ? `sticky top-0` : ''}>
188
198
  {#each $headerRows as headerRow (headerRow.id)}
189
199
  <Subscribe
@@ -236,10 +246,10 @@
236
246
  <tbody class="overflow-auto" {...$tableBodyAttrs}>
237
247
  {#each $pageRows as row (row.id)}
238
248
  <Subscribe rowAttrs={row.attrs()} let:rowAttrs>
239
- <tr {...rowAttrs}>
249
+ <tr {...rowAttrs} id="{tableId}-row-{row.id}">
240
250
  {#each row.cells as cell (cell?.id)}
241
251
  <Subscribe attrs={cell.attrs()} let:attrs>
242
- <td {...attrs} class="!p-2 w-max focus:resize">
252
+ <td {...attrs} class="!p-2 w-max focus:resize" id="{tableId}-{cell.id}-{row.id}">
243
253
  <div
244
254
  class="flex items-center h-max overflow-x-auto resize-none hover:resize"
245
255
  class:max-w-md={!fitToScreen}
@@ -257,6 +267,6 @@
257
267
  </div>
258
268
  </div>
259
269
  {#if $data.length > 0}
260
- <TablePagination pageConfig={pluginStates.page} {pageSizes} />
270
+ <TablePagination pageConfig={pluginStates.page} {pageSizes} id={tableId} />
261
271
  {/if}
262
272
  </div>
@@ -119,11 +119,12 @@
119
119
  class="btn w-max p-2"
120
120
  type="button"
121
121
  use:popup={popupFeatured}
122
+ id="{popupId}-button"
122
123
  >
123
124
  <Fa icon={faFilter} size="12" />
124
125
  </button>
125
126
 
126
- <div data-popup={`${popupId}`} class="z-50">
127
+ <div data-popup={`${popupId}`} id="{popupId}" class="z-50">
127
128
  <div class="card p-3 grid gap-2 shadow-lg w-min bg-base-100">
128
129
  <button
129
130
  class="btn variant-filled-primary btn-sm"
@@ -1,61 +1,66 @@
1
- <script lang="ts">
2
- import Fa from 'svelte-fa/src/fa.svelte';
3
- import {
4
- faAnglesRight,
5
- faAngleRight,
6
- faAnglesLeft,
7
- faAngleLeft
8
- } from '@fortawesome/free-solid-svg-icons';
9
-
10
- export let pageConfig;
11
- export let pageSizes;
12
-
13
- const { pageIndex, pageCount, pageSize, hasNextPage, hasPreviousPage } = pageConfig;
14
-
15
- const goToFirstPage = () => ($pageIndex = 0);
16
- const goToLastPage = () => ($pageIndex = $pageCount - 1);
17
- const goToNextPage = () => ($pageIndex += 1);
18
- const goToPreviousPage = () => ($pageIndex -= 1);
19
-
20
- $: goToFirstPageDisabled = !$pageIndex;
21
- $: goToLastPageDisabled = $pageIndex == $pageCount - 1;
22
- $: goToNextPageDisabled = !$hasNextPage;
23
- $: goToPreviousPageDisabled = !$hasPreviousPage;
24
- </script>
25
-
26
- <div class="flex justify-center gap-1">
27
- <button
28
- class="btn btn-sm variant-filled-primary"
29
- on:click|preventDefault={goToFirstPage}
30
- disabled={goToFirstPageDisabled}
31
- >
32
- <Fa icon={faAnglesLeft} /></button
33
- >
34
- <button
35
- class="btn btn-sm variant-filled-primary"
36
- on:click|preventDefault={goToPreviousPage}
37
- disabled={goToPreviousPageDisabled}><Fa icon={faAngleLeft} /></button
38
- >
39
-
40
- <select
41
- name="pageSize"
42
- id="pageSize"
43
- class="select variant-filled-primary w-min font-bold"
44
- bind:value={$pageSize}
45
- >
46
- {#each pageSizes as size}
47
- <option value={size}>{size}</option>
48
- {/each}
49
- </select>
50
-
51
- <button
52
- class="btn btn-sm variant-filled-primary"
53
- on:click|preventDefault={goToNextPage}
54
- disabled={goToNextPageDisabled}><Fa icon={faAngleRight} /></button
55
- >
56
- <button
57
- class="btn btn-sm variant-filled-primary"
58
- on:click|preventDefault={goToLastPage}
59
- disabled={goToLastPageDisabled}><Fa icon={faAnglesRight} /></button
60
- >
61
- </div>
1
+ <script lang="ts">
2
+ import Fa from 'svelte-fa/src/fa.svelte';
3
+ import {
4
+ faAnglesRight,
5
+ faAngleRight,
6
+ faAnglesLeft,
7
+ faAngleLeft
8
+ } from '@fortawesome/free-solid-svg-icons';
9
+
10
+ export let pageConfig;
11
+ export let pageSizes;
12
+ export let id;
13
+
14
+ const { pageIndex, pageCount, pageSize, hasNextPage, hasPreviousPage } = pageConfig;
15
+
16
+ const goToFirstPage = () => ($pageIndex = 0);
17
+ const goToLastPage = () => ($pageIndex = $pageCount - 1);
18
+ const goToNextPage = () => ($pageIndex += 1);
19
+ const goToPreviousPage = () => ($pageIndex -= 1);
20
+
21
+ $: goToFirstPageDisabled = !$pageIndex;
22
+ $: goToLastPageDisabled = $pageIndex == $pageCount - 1;
23
+ $: goToNextPageDisabled = !$hasNextPage;
24
+ $: goToPreviousPageDisabled = !$hasPreviousPage;
25
+ </script>
26
+
27
+ <div class="flex justify-center gap-1">
28
+ <button
29
+ class="btn btn-sm variant-filled-primary"
30
+ on:click|preventDefault={goToFirstPage}
31
+ disabled={goToFirstPageDisabled}
32
+ id="{id}-first"
33
+ >
34
+ <Fa icon={faAnglesLeft} /></button
35
+ >
36
+ <button
37
+ class="btn btn-sm variant-filled-primary"
38
+ id="{id}-previous"
39
+ on:click|preventDefault={goToPreviousPage}
40
+ disabled={goToPreviousPageDisabled}><Fa icon={faAngleLeft} /></button
41
+ >
42
+
43
+ <select
44
+ name="pageSize"
45
+ id="{id}-pageSize"
46
+ class="select variant-filled-primary w-min font-bold"
47
+ bind:value={$pageSize}
48
+ >
49
+ {#each pageSizes as size}
50
+ <option value={size}>{size}</option>
51
+ {/each}
52
+ </select>
53
+
54
+ <button
55
+ class="btn btn-sm variant-filled-primary"
56
+ id="{id}-next"
57
+ on:click|preventDefault={goToNextPage}
58
+ disabled={goToNextPageDisabled}><Fa icon={faAngleRight} /></button
59
+ >
60
+ <button
61
+ class="btn btn-sm variant-filled-primary"
62
+ id="{id}-last"
63
+ on:click|preventDefault={goToLastPage}
64
+ disabled={goToLastPageDisabled}><Fa icon={faAnglesRight} /></button
65
+ >
66
+ </div>
@@ -168,7 +168,7 @@
168
168
  <b style="font-size:xx-large"><Fa icon={faFileUpload} /></b>
169
169
  <span
170
170
  ><b>Drag 'n' drop some files here, or click to select files</b>
171
- <b>max file : {model.maxSize} mb</b></span
171
+ <b>(max file size: {model.maxSize} mb)</b></span
172
172
  >
173
173
  <p>
174
174
  {#if model.accept}
@@ -1,36 +1,36 @@
1
- <script lang="ts">
2
- import { helpStore } from '$store/pageStores';
3
-
4
- export let id: string = '';
5
- export let label: string = '';
6
- export let required: boolean;
7
- export let feedback: string[];
8
- export let help: boolean = false;
9
-
10
- function onMouseOver() {
11
- if (help) {
12
- helpStore.show(id);
13
- }
14
- }
15
-
16
- function onMouseOut() {}
17
- </script>
18
-
19
- <div {id} on:mouseover={onMouseOver} on:mouseout={onMouseOut}>
20
- <label class="label">
21
- <span
22
- >{label}
23
- {#if required} <span class="text-sm text-red-600">*</span> {/if}
24
- </span>
25
- <slot />
26
- {#if feedback}
27
- <span class="text-sm text-error-600">
28
- <ul>
29
- {#each feedback as message}
30
- <li>{message}</li>
31
- {/each}
32
- </ul>
33
- </span>
34
- {/if}
35
- </label>
36
- </div>
1
+ <script lang="ts">
2
+ import { helpStore } from '$store/pageStores';
3
+
4
+ export let id: string = '';
5
+ export let label: string = '';
6
+ export let required: boolean;
7
+ export let feedback: string[];
8
+ export let help: boolean = false;
9
+
10
+ function onMouseOver() {
11
+ if (help) {
12
+ helpStore.show(id);
13
+ }
14
+ }
15
+
16
+ function onMouseOut() {}
17
+ </script>
18
+
19
+ <div id="{id}-container" on:mouseover={onMouseOver} on:mouseout={onMouseOut}>
20
+ <label class="label">
21
+ <span
22
+ >{label}
23
+ {#if required} <span class="text-sm text-red-600">*</span> {/if}
24
+ </span>
25
+ <slot />
26
+ {#if feedback}
27
+ <span class="text-sm text-error-600">
28
+ <ul>
29
+ {#each feedback as message}
30
+ <li>{message}</li>
31
+ {/each}
32
+ </ul>
33
+ </span>
34
+ {/if}
35
+ </label>
36
+ </div>
package/src/lib/index.ts CHANGED
@@ -30,6 +30,9 @@ import TableFilter from './components/Table/TableFilter.svelte';
30
30
  import { columnFilter, searchFilter } from './components/Table/filter';
31
31
  import type { TableConfig, Columns, Column } from './models/Models';
32
32
 
33
+ // CodeEditor
34
+ import CodeEditor from './components/CodeEditor/CodeEditor.svelte';
35
+
33
36
  //notification
34
37
  import Notification from './components/page/Notification.svelte';
35
38
 
@@ -96,4 +99,8 @@ export {
96
99
 
97
100
  // Table
98
101
  export { Table, TableFilter, columnFilter, searchFilter };
102
+
103
+ // CodeEditor
104
+ export { CodeEditor };
105
+
99
106
  export type { TableConfig, Columns, Column };
@@ -105,6 +105,8 @@ export interface Columns {
105
105
  export interface TableConfig<T> {
106
106
  id: string;
107
107
  data: Writable<T[]>;
108
+ toggle?: boolean;
109
+ fitToScreen?: boolean;
108
110
  height?: null | number;
109
111
  columns?: Columns;
110
112
  pageSizes?: number[];