@v1nt1248/3nclient-lib 0.0.24 → 0.0.26

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.
Files changed (40) hide show
  1. package/README.md +4 -6
  2. package/dist/components/index.d.ts +3 -1
  3. package/dist/components/ui3n-button.vue.d.ts +11 -52
  4. package/dist/components/ui3n-checkbox.vue.d.ts +68 -0
  5. package/dist/components/ui3n-dialog.vue.d.ts +11 -24
  6. package/dist/components/ui3n-drop-files.vue.d.ts +11 -22
  7. package/dist/components/ui3n-emoji.vue.d.ts +22 -28
  8. package/dist/components/ui3n-icon.vue.d.ts +11 -72
  9. package/dist/components/ui3n-input.vue.d.ts +11 -60
  10. package/dist/components/ui3n-list.vue.d.ts +36 -11
  11. package/dist/components/ui3n-menu.vue.d.ts +29 -45
  12. package/dist/components/ui3n-notification.vue.d.ts +10 -70
  13. package/dist/components/ui3n-table-sort-icon.vue.d.ts +9 -22
  14. package/dist/components/ui3n-table.vue.d.ts +11 -18
  15. package/dist/components/ui3n-text.vue.d.ts +11 -48
  16. package/dist/components/ui3n-virtual-scroll.vue.d.ts +21 -11
  17. package/dist/index.d.ts +37 -2
  18. package/dist/stories/Ui3nButton.stories.d.ts +32 -47
  19. package/dist/stories/Ui3nCheckbox.stories.d.ts +226 -0
  20. package/dist/stories/Ui3nDropFiles.stories.d.ts +15 -47
  21. package/dist/stories/Ui3nEmoji.stories.d.ts +8 -8
  22. package/dist/stories/Ui3nList.stories.d.ts +36 -11
  23. package/dist/style.css +1 -1
  24. package/dist/tools/index.d.ts +2 -0
  25. package/dist/ui-3n-lib.js +6899 -7744
  26. package/package.json +11 -12
  27. package/src/components/index.ts +6 -0
  28. package/src/components/ui3n-button.vue +2 -15
  29. package/src/components/ui3n-checkbox.vue +191 -0
  30. package/dist/libs/index.d.ts +0 -4
  31. package/dist/libs/ipc-service-caller.d.ts +0 -12
  32. package/dist/libs/ipc-service.d.ts +0 -60
  33. package/dist/libs/serialization-for-ipc/copy-json.d.ts +0 -8
  34. package/dist/libs/serialization-for-ipc/json-n-binary.d.ts +0 -5
  35. package/dist/libs/serialization-for-ipc/protobuf-type.d.ts +0 -10
  36. package/dist/libs/serialization-for-ipc/types.d.ts +0 -3
  37. /package/dist/{libs → tools}/sqlite-on-3nstorage/deferred.d.ts +0 -0
  38. /package/dist/{libs → tools}/sqlite-on-3nstorage/index.d.ts +0 -0
  39. /package/dist/{libs → tools}/sqlite-on-3nstorage/synced.d.ts +0 -0
  40. /package/dist/{libs → tools}/sqlite-on-3nstorage/types.d.ts +0 -0
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@v1nt1248/3nclient-lib",
3
3
  "license": "AGPL-3.0-or-later",
4
4
  "author": "v1nt1248",
5
- "version": "0.0.24",
5
+ "version": "0.0.26",
6
6
  "description": "Library for 3NWeb clients",
7
7
  "private": false,
8
8
  "type": "module",
@@ -39,7 +39,6 @@
39
39
  "dayjs": "^1.11.9",
40
40
  "lodash": "^4.17.21",
41
41
  "mitt": "^3.0.1",
42
- "protobufjs": "^7.2.5",
43
42
  "sanitize-html": "^2.11.0",
44
43
  "tslib": "^2.6.2"
45
44
  },
@@ -48,16 +47,16 @@
48
47
  "vue": "^3.3.4"
49
48
  },
50
49
  "devDependencies": {
51
- "@storybook/addon-actions": "^7.4.4",
52
- "@storybook/addon-docs": "^7.4.4",
53
- "@storybook/addon-essentials": "^7.4.4",
54
- "@storybook/addon-interactions": "^7.4.4",
55
- "@storybook/addon-links": "^7.4.4",
56
- "@storybook/blocks": "^7.4.4",
57
- "@storybook/builder-vite": "^7.4.4",
50
+ "@storybook/addon-actions": "^7.5.1",
51
+ "@storybook/addon-docs": "^7.5.1",
52
+ "@storybook/addon-essentials": "^7.5.1",
53
+ "@storybook/addon-interactions": "^7.5.1",
54
+ "@storybook/addon-links": "^7.5.1",
55
+ "@storybook/blocks": "^7.5.1",
56
+ "@storybook/builder-vite": "^7.5.1",
58
57
  "@storybook/testing-library": "^0.2.1",
59
- "@storybook/vue3": "^7.4.4",
60
- "@storybook/vue3-vite": "^7.4.4",
58
+ "@storybook/vue3": "^7.5.1",
59
+ "@storybook/vue3-vite": "^7.5.1",
61
60
  "@types/lodash": "^4.14.197",
62
61
  "@types/node": "^20.5.6",
63
62
  "@types/sanitize-html": "^2.9.0",
@@ -87,7 +86,7 @@
87
86
  "stylelint-rscss": "^0.4.0",
88
87
  "stylelint-scss": "^5.1.0",
89
88
  "typescript": "^5.2.2",
90
- "vite": "^4.4.5",
89
+ "vite": "^4.5.0",
91
90
  "vite-plugin-css-injected-by-js": "^3.3.0",
92
91
  "vite-plugin-dts": "^3.5.3",
93
92
  "vue": "^3.3.4",
@@ -10,6 +10,8 @@ import Ui3nInput from './ui3n-input.vue'
10
10
  import type { Ui3nInputProps, Ui3nInputEmits } from './ui3n-input.vue'
11
11
  import Ui3nText from './ui3n-text.vue'
12
12
  import type { Ui3nTextProps, Ui3nTextEmits } from './ui3n-text.vue'
13
+ import Ui3mCheckbox from './ui3n-checkbox.vue'
14
+ import type { Ui3nCheckboxProps, Ui3nCheckboxEmits, Ui3nCheckboxSlots } from './ui3n-checkbox.vue'
13
15
  import Ui3nNotification from './ui3n-notification.vue'
14
16
  import Ui3nTableSortIcon from './ui3n-table-sort-icon.vue'
15
17
  import type { Ui3nTableSortIconProps } from './ui3n-table-sort-icon.vue'
@@ -43,6 +45,10 @@ export {
43
45
  Ui3nText,
44
46
  Ui3nTextProps,
45
47
  Ui3nTextEmits,
48
+ Ui3mCheckbox,
49
+ Ui3nCheckboxProps,
50
+ Ui3nCheckboxEmits,
51
+ Ui3nCheckboxSlots,
46
52
  Ui3nNotification,
47
53
  Ui3nTableSortIcon,
48
54
  Ui3nTableSortIconProps,
@@ -110,8 +110,6 @@
110
110
  line-height: var(--ui3n-button-text-height);
111
111
  font-weight: 600;
112
112
  color: var(--ui3n-button-text-color);
113
- background-position: center;
114
- transition: background 0.5s ease-in-out;
115
113
 
116
114
  &--round {
117
115
  --ui3n-button-padding-vert: 6px;
@@ -125,13 +123,7 @@
125
123
  }
126
124
 
127
125
  &:not([disabled]) {
128
- cursor: pointer;
129
-
130
126
  &:hover {
131
- background:
132
- var(--ui3n-button-background)
133
- radial-gradient(circle, transparent 1%, var(--ui3n-button-background) 1%)
134
- center/15000%;
135
127
  box-shadow: 0 0 4px var(--shadow-key-ambient-opacity, rgba(0, 0, 0, 0.12));
136
128
 
137
129
  .ui3n-button {
@@ -141,13 +133,6 @@
141
133
  }
142
134
  }
143
135
  }
144
-
145
- &:active {
146
- opacity: 1;
147
- background-color: var(--black-30, #b3b3b3);
148
- background-size: 100%;
149
- transition: background 0s;
150
- }
151
136
  }
152
137
 
153
138
  &__icon {
@@ -168,5 +153,7 @@
168
153
  &[disabled] {
169
154
  opacity: 0.7;
170
155
  }
156
+
157
+ @include ripple(var(--ui3n-button-background));
171
158
  }
172
159
  </style>
@@ -0,0 +1,191 @@
1
+ <script lang="ts" setup>
2
+ import { computed, onMounted, watch, onBeforeMount, ref, useSlots } from 'vue'
3
+ import Ui3nIcon from './ui3n-icon.vue'
4
+
5
+ type Ui3nCheckboxValue = boolean | string | number;
6
+
7
+ export interface Ui3nCheckboxProps {
8
+ modelValue: Ui3nCheckboxValue;
9
+ checkedValue?: Ui3nCheckboxValue;
10
+ uncheckedValue?: Ui3nCheckboxValue;
11
+ size?: number|string;
12
+ color?: string;
13
+ indeterminate?: boolean;
14
+ disabled?: boolean;
15
+ }
16
+
17
+ export interface Ui3nCheckboxEmits {
18
+ (ev: 'change', value: Ui3nCheckboxValue): void;
19
+ (ev: 'update:modelValue', value: Ui3nCheckboxValue): void;
20
+ }
21
+
22
+ export interface Ui3nCheckboxSlots {
23
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
24
+ default: () => any;
25
+ }
26
+
27
+ const iconMap = {
28
+ checked: 'check-box-checked',
29
+ unchecked: 'check-box',
30
+ indeterminate: 'check-box-inderterminate',
31
+ }
32
+
33
+ const props = withDefaults(
34
+ defineProps<Ui3nCheckboxProps>(),
35
+ {
36
+ modelValue: false,
37
+ checkedValue: true,
38
+ uncheckedValue: false,
39
+ size: '16',
40
+ color: '#0090ec',
41
+ indeterminate: false,
42
+ disabled: false,
43
+ },
44
+ )
45
+ const emits = defineEmits<Ui3nCheckboxEmits>()
46
+ defineSlots<Ui3nCheckboxSlots>()
47
+
48
+ const slots = useSlots()
49
+
50
+ const checkboxEl = ref<HTMLDivElement|null>(null)
51
+ const val = ref<Ui3nCheckboxValue>(props.uncheckedValue || false)
52
+ const uncertain = ref(false)
53
+
54
+ onBeforeMount(() => {
55
+ const checkedValueType = typeof props.checkedValue
56
+ const uncheckedValueType = typeof props.uncheckedValue
57
+ const valueType = typeof props.modelValue
58
+ if (
59
+ checkedValueType !== uncheckedValueType
60
+ || checkedValueType !== valueType
61
+ || uncheckedValueType !== valueType
62
+ ) {
63
+ throw Error('[Ui3nCheckbox] types of "value", "checkedValue" and "unchecktdValue" are different')
64
+ }
65
+ })
66
+
67
+ onMounted(() => {
68
+ if (checkboxEl.value) {
69
+ checkboxEl.value.style.setProperty('--ui3n-checkbox-size', `${props.size}px`)
70
+ }
71
+ })
72
+
73
+ watch(
74
+ () => props.modelValue,
75
+ newValue => val.value = newValue,
76
+ { immediate: true },
77
+ )
78
+
79
+ watch(
80
+ () => props.indeterminate,
81
+ newValue => uncertain.value = newValue,
82
+ { immediate: true},
83
+ )
84
+
85
+ watch(
86
+ () => props.size,
87
+ newValue => {
88
+ if (checkboxEl.value) {
89
+ checkboxEl.value.style.setProperty('--ui3n-checkbox-size', `${newValue}px`)
90
+ }
91
+ },
92
+ )
93
+
94
+ const checkBoxValue = computed(() => {
95
+ if (uncertain.value) {
96
+ return 'indeterminate'
97
+ }
98
+
99
+ return val.value === props.checkedValue
100
+ ? 'checked'
101
+ : 'unchecked'
102
+ } )
103
+
104
+ const change = () => {
105
+ val.value = checkBoxValue.value !== 'unchecked'
106
+ ? props.uncheckedValue
107
+ : props.checkedValue
108
+
109
+ if (uncertain.value) {
110
+ uncertain.value = false
111
+ }
112
+
113
+ emits('change', val.value)
114
+ emits('update:modelValue', val.value)
115
+ }
116
+ </script>
117
+
118
+ <template>
119
+ <div
120
+ ref="checkboxEl"
121
+ :class="[
122
+ 'ui3n-checkbox',
123
+ {
124
+ 'ui3n-checkbox--disabled': props.disabled,
125
+ 'ui3n-checkbox--with-label': slots.default,
126
+ },
127
+ ]"
128
+ >
129
+ <div
130
+ class="ui3n-checkbox__wrapper"
131
+ @click="change"
132
+ >
133
+ <ui3n-icon
134
+ class="ui3n-checkbox__icon"
135
+ :icon="iconMap[checkBoxValue]"
136
+ :width="props.size"
137
+ :height="props.size"
138
+ :color="props.color"
139
+ />
140
+ </div>
141
+
142
+ <div
143
+ class="ui3n-checkbox__label"
144
+ @click="change"
145
+ >
146
+ <slot />
147
+ </div>
148
+ </div>
149
+ </template>
150
+
151
+ <style lang="scss" scoped>
152
+ @import "../assets/styles/mixins";
153
+
154
+ .ui3n-checkbox {
155
+ --ui3n-checkbox-size: 16px;
156
+ --ui3n-checkbox-text-size: 12px;
157
+ --ui3n-checkbox-text-color: var(--black-90, #212121);
158
+ --ui3n-checkbox-text-weight: 500;
159
+
160
+ position: relative;
161
+ display: flex;
162
+ justify-content: flex-start;
163
+ align-items: center;
164
+
165
+ &__wrapper {
166
+ position: relative;
167
+ display: flex;
168
+ width: calc(var(--ui3n-checkbox-size) * 1.5);
169
+ height: calc(var(--ui3n-checkbox-size) * 1.5);
170
+ justify-content: center;
171
+ align-items: center;
172
+ border-radius: 50%;
173
+ cursor: pointer;
174
+
175
+ @include ripple(transparent);
176
+ }
177
+
178
+ &__label {
179
+ font-size: var(--ui3n-checkbox-text-size);
180
+ font-weight: var(--ui3n-checkbox-text-weight);
181
+ color: var(--ui3n-checkbox-text-color);
182
+ user-select: none;
183
+ cursor: pointer;
184
+ }
185
+
186
+ &--disabled {
187
+ pointer-events: none;
188
+ opacity: 0.5;
189
+ }
190
+ }
191
+ </style>
@@ -1,4 +0,0 @@
1
- export { SQLiteOn3NStorage } from './sqlite-on-3nstorage';
2
- export type { BindParams, Database, QueryExecResult } from './sqlite-on-3nstorage';
3
- export { makeObservableMethodCaller, makeReqRepMethodCaller, makeServiceCaller, } from './ipc-service-caller';
4
- export { SingleConnectionIPCWrap, MultiConnectionIPCWrap, IPCWrap, } from './ipc-service';
@@ -1,12 +0,0 @@
1
- type RPCConnection = web3n.rpc.client.RPCConnection;
2
- type PassedDatum = web3n.rpc.PassedDatum;
3
- export interface TransformOpts {
4
- unpackReply?: ((reply: PassedDatum | undefined) => any) | 'noop';
5
- packRequest?: ((args: any[]) => PassedDatum | undefined) | 'noop';
6
- }
7
- export declare function makeReqRepMethodCaller<F extends Function>(connection: RPCConnection, method: string, transforms?: TransformOpts): F;
8
- export declare function makeObservableMethodCaller<F extends Function>(connection: RPCConnection, method: string, transforms?: TransformOpts): F;
9
- export declare function makeServiceCaller<T>(connection: RPCConnection, reqRepMethods?: (keyof T)[], obsMethods?: (keyof T)[], transforms?: {
10
- [method in keyof T]: TransformOpts;
11
- }): Partial<T>;
12
- export {};
@@ -1,60 +0,0 @@
1
- type IncomingConnection = web3n.rpc.service.IncomingConnection;
2
- type PassedDatum = web3n.rpc.PassedDatum;
3
- type Observer<T> = web3n.Observer<T>;
4
- export type HandleObservingCall = (obs: Observer<any>, ...requestArgs: any[]) => (() => void);
5
- export type HandleReqReplyCall = (...requestArgs: any[]) => Promise<any>;
6
- export interface TransformOpts {
7
- unpackRequest?: ((req: PassedDatum | undefined) => any[]) | 'noop';
8
- packReply?: ((reply: any) => PassedDatum | undefined) | 'noop';
9
- }
10
- declare class ConnectionState {
11
- private readonly disconnect;
12
- private readonly calls;
13
- private isRunning;
14
- constructor(disconnect: () => void);
15
- acceptsMsgs(): boolean;
16
- stop(): void;
17
- hasCall(callNum: number): boolean;
18
- cancelCall(callNum: number): void;
19
- completeCall(callNum: number): void;
20
- registerReqReplyCall(callNum: number): void;
21
- registerObservableCall(callNum: number, cancel: () => void): void;
22
- }
23
- export declare abstract class IPCWrap {
24
- readonly srvName: string;
25
- protected readonly connections: Map<web3n.rpc.service.IncomingConnection, ConnectionState>;
26
- private readonly methods;
27
- constructor(srvName: string);
28
- addReqReplyMethod(method: string, srv: object | undefined, func: HandleReqReplyCall, transforms?: TransformOpts): void;
29
- exposeReqReplyMethods<T extends object>(srv: T, methods: (keyof T)[], transforms?: {
30
- [method in keyof T]: TransformOpts;
31
- }): void;
32
- addObservableMethod(method: string, srv: object | undefined, func: HandleObservingCall, transforms?: TransformOpts): void;
33
- exposeObservableMethods<T extends object>(srv: T, methods: (keyof T)[], transforms?: {
34
- [method in keyof T]: TransformOpts;
35
- }): void;
36
- private onMsg;
37
- private callReqReplyHandler;
38
- private callObsHandler;
39
- startIPC(): () => void;
40
- stopIPC(): void;
41
- protected onConnection(connection: IncomingConnection): Promise<void>;
42
- protected onConnectionCompletion(connection: IncomingConnection, connectionState: ConnectionState): Promise<void>;
43
- protected onConnectionError(connection: IncomingConnection, connectionState: ConnectionState, err: any): Promise<void>;
44
- protected abstract onListeningCompletion(): Promise<void>;
45
- protected abstract onListeningError(err: any): Promise<void>;
46
- }
47
- export declare class SingleConnectionIPCWrap extends IPCWrap {
48
- constructor(srvName: string);
49
- protected onListeningCompletion(): Promise<void>;
50
- protected onListeningError(err: any): Promise<void>;
51
- protected onConnectionCompletion(connection: IncomingConnection, connectionState: ConnectionState): Promise<void>;
52
- protected onConnectionError(connection: IncomingConnection, connectionState: ConnectionState, err: any): Promise<void>;
53
- }
54
- export declare class MultiConnectionIPCWrap extends IPCWrap {
55
- constructor(srvName: string);
56
- protected onListeningCompletion(): Promise<void>;
57
- protected onListeningError(err: any): Promise<void>;
58
- protected onConnectionError(connection: IncomingConnection, connectionState: ConnectionState, err: any): Promise<void>;
59
- }
60
- export {};
@@ -1,8 +0,0 @@
1
- /**
2
- * This function creates a copy of json entity with a caveat that Buffer and
3
- * byte arrays are shared between original and a copy.
4
- * @param orig is an object, which copy is created. Buffer and byte arrays
5
- * passed through like primitives.
6
- * @param excludeTopFields is an optional list of fields to exclude from copy.
7
- */
8
- export declare function copyJSON<T>(orig: T, excludeTopFields?: string[]): T;
@@ -1,5 +0,0 @@
1
- export declare function serializeArgs(args: any[]): {
2
- bytes: Uint8Array;
3
- passedByReference?: any[];
4
- };
5
- export declare function deserializeArgs(bytes: Uint8Array, passedByReference: any[] | undefined): any[];
@@ -1,10 +0,0 @@
1
- /// <reference types="node" />
2
- export declare class ProtoType<T extends object> {
3
- private readonly type;
4
- private constructor();
5
- static for<T extends object>(type: any): ProtoType<T>;
6
- pack(msg: T): Buffer;
7
- unpack(bytes: Buffer | void): T;
8
- packToBase64(msg: T): string;
9
- unpackFromBase64(str: string): T;
10
- }
@@ -1,3 +0,0 @@
1
- /** Namespace json_ipc. */
2
- export declare namespace json_ipc {
3
- }