@rkosafo/cai.components 0.0.33 → 0.0.35
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/dist/forms/FormClEditor/ClEdito.svelte +68 -0
- package/dist/forms/FormClEditor/ClEdito.svelte.d.ts +4 -0
- package/dist/forms/FormClEditor/index.d.ts +1 -0
- package/dist/forms/FormClEditor/index.js +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/types/index.d.ts +5 -1
- package/package.json +2 -1
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { IconifyIcon, key, Label } from '../../index.js';
|
|
3
|
+
import type { FormClEditorProps } from '../../types/index.js';
|
|
4
|
+
import Editor from 'cl-editor/src/Editor.svelte';
|
|
5
|
+
import { nanoid } from 'nanoid';
|
|
6
|
+
import { getContext, onMount } from 'svelte';
|
|
7
|
+
|
|
8
|
+
let {
|
|
9
|
+
name = '',
|
|
10
|
+
label = '',
|
|
11
|
+
required,
|
|
12
|
+
readonly,
|
|
13
|
+
contextKey = null,
|
|
14
|
+
type = 'text',
|
|
15
|
+
pattern = null,
|
|
16
|
+
placeholder,
|
|
17
|
+
value,
|
|
18
|
+
height,
|
|
19
|
+
...otherProps
|
|
20
|
+
}: FormClEditorProps = $props();
|
|
21
|
+
const { touched, errors, data, setData }: any = getContext(contextKey || key);
|
|
22
|
+
const hasError = $derived($touched[name] && $errors[name]?.length);
|
|
23
|
+
const error = $derived($errors[name]?.join(', '));
|
|
24
|
+
const isSuccess = $derived(!readonly && !hasError && $touched[name]);
|
|
25
|
+
let editorValue = $derived($data[name] || value || '');
|
|
26
|
+
let id = nanoid();
|
|
27
|
+
|
|
28
|
+
function onChange({ detail: e }: CustomEvent) {
|
|
29
|
+
setData({ ...$data, [name]: e });
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function onBlur({ detail: e }: CustomEvent) {
|
|
33
|
+
console.log({ e });
|
|
34
|
+
// setData({ ...$data, [name]: e });
|
|
35
|
+
}
|
|
36
|
+
// $effect(() => {
|
|
37
|
+
// if (value !== undefined && value !== $data[name]) {
|
|
38
|
+
// setData({ ...$data, [name]: value });
|
|
39
|
+
// }
|
|
40
|
+
// });
|
|
41
|
+
</script>
|
|
42
|
+
|
|
43
|
+
<div class="relative space-y-1">
|
|
44
|
+
<Label
|
|
45
|
+
>{label}
|
|
46
|
+
{#if required}
|
|
47
|
+
<span class="pl-1 text-red-500">*</span>
|
|
48
|
+
{/if}
|
|
49
|
+
</Label>
|
|
50
|
+
|
|
51
|
+
<Editor contentId={id} on:change={onChange} bind:html={editorValue} {height} />
|
|
52
|
+
|
|
53
|
+
{#if hasError}
|
|
54
|
+
<Label
|
|
55
|
+
class="v-error-container absolute top-9 right-2 flex items-center gap-1 text-sm {hasError &&
|
|
56
|
+
'text-red-600'}"
|
|
57
|
+
>
|
|
58
|
+
<span class="v-error-message hidden backdrop-blur-sm">
|
|
59
|
+
{error}
|
|
60
|
+
</span>
|
|
61
|
+
<IconifyIcon
|
|
62
|
+
icon="solar:danger-circle-bold-duotone"
|
|
63
|
+
class="v-error-svg ml-auto cursor-pointer text-red-500 select-none hover:text-red-600"
|
|
64
|
+
style="font-size: 18px;"
|
|
65
|
+
/>
|
|
66
|
+
</Label>
|
|
67
|
+
{/if}
|
|
68
|
+
</div>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as FormClEditor } from './ClEdito.svelte';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as FormClEditor } from './ClEdito.svelte';
|
package/dist/index.d.ts
CHANGED
|
@@ -40,6 +40,7 @@ export * from './forms/FormSelect/index.js';
|
|
|
40
40
|
export * from './forms/FormTextarea/index.js';
|
|
41
41
|
export * from './forms/FormCheckbox/index.js';
|
|
42
42
|
export * from './forms/FormRadio/index.js';
|
|
43
|
+
export * from './forms/FormClEditor/index.js';
|
|
43
44
|
export * from './builders/filters/index.js';
|
|
44
45
|
export * from './types/index.js';
|
|
45
46
|
export * from './utils/index.js';
|
package/dist/index.js
CHANGED
|
@@ -41,6 +41,7 @@ export * from './forms/FormSelect/index.js';
|
|
|
41
41
|
export * from './forms/FormTextarea/index.js';
|
|
42
42
|
export * from './forms/FormCheckbox/index.js';
|
|
43
43
|
export * from './forms/FormRadio/index.js';
|
|
44
|
+
export * from './forms/FormClEditor/index.js';
|
|
44
45
|
export * from './builders/filters/index.js';
|
|
45
46
|
export * from './types/index.js';
|
|
46
47
|
export * from './utils/index.js';
|
package/dist/types/index.d.ts
CHANGED
|
@@ -543,6 +543,9 @@ export interface FormTextareaProps extends Omit<TextareaProps, 'name'>, IFormPro
|
|
|
543
543
|
}
|
|
544
544
|
export interface FormRadioProps<T> extends Omit<RadioProps<T>, 'name'>, IFormProps {
|
|
545
545
|
}
|
|
546
|
+
export interface FormClEditorProps extends Omit<InputProps, 'name'>, IFormProps {
|
|
547
|
+
height?: string;
|
|
548
|
+
}
|
|
546
549
|
export interface FormCheckboxProps extends Omit<CheckboxProps, 'name'>, IFormProps {
|
|
547
550
|
onChange?: (val: any) => void;
|
|
548
551
|
}
|
|
@@ -808,6 +811,7 @@ export interface IButtonConfig {
|
|
|
808
811
|
label: string;
|
|
809
812
|
subLabel: string;
|
|
810
813
|
}
|
|
814
|
+
export type IActionButtonKind = keyof typeof ACTION_BUTTON_KINDS;
|
|
811
815
|
export interface ActionButtonProps {
|
|
812
816
|
icon?: string;
|
|
813
817
|
iconBgColor?: string;
|
|
@@ -820,7 +824,7 @@ export interface ActionButtonProps {
|
|
|
820
824
|
showIconHover?: boolean;
|
|
821
825
|
moreHeight?: boolean;
|
|
822
826
|
href?: string | null;
|
|
823
|
-
kind?:
|
|
827
|
+
kind?: IActionButtonKind;
|
|
824
828
|
moreShadow?: boolean;
|
|
825
829
|
onclick?: () => void;
|
|
826
830
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rkosafo/cai.components",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.35",
|
|
4
4
|
"files": [
|
|
5
5
|
"dist",
|
|
6
6
|
"!dist/**/*.test.*",
|
|
@@ -54,6 +54,7 @@
|
|
|
54
54
|
"@tiptap/extension-text-style": "^3.0.7",
|
|
55
55
|
"@tiptap/pm": "^3.0.7",
|
|
56
56
|
"@tiptap/starter-kit": "^3.0.7",
|
|
57
|
+
"cl-editor": "^2.3.0",
|
|
57
58
|
"clsx": "^2.1.1",
|
|
58
59
|
"date-fns": "^4.1.0",
|
|
59
60
|
"felte": "^1.3.0",
|