@onereach/ui-components 4.10.1-beta.2921.0 → 4.10.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/dist/bundled/v2/components/OrCode/OrCode.js +3792 -4
- package/dist/bundled/v2/components/OrCode/index.js +2 -4
- package/dist/bundled/v2/components/OrCode/lang.js +3 -24
- package/dist/bundled/v2/components/OrCode/theme.js +1 -1
- package/dist/bundled/v2/components/OrModalV3/OrModal.js +2 -2
- package/dist/bundled/v2/components/index.d.ts +0 -1
- package/dist/bundled/v2/components/index.js +3 -8
- package/dist/bundled/v2/{index-6a13fa4e.js → index-cf2c3c27.js} +1 -1
- package/dist/bundled/v2/index.js +4 -9
- package/dist/bundled/v2/{index-eba9b646.js → lang-0fb8f78b.js} +22 -2
- package/dist/bundled/{v2/index-576b3dec.js → v3/OrCode.vue_vue_type_script_lang-46846a36.js} +235 -3
- package/dist/bundled/v3/components/OrCode/OrCode.js +5 -7
- package/dist/bundled/v3/components/OrCode/index.js +3 -5
- package/dist/bundled/v3/components/OrCode/lang.js +3 -24
- package/dist/bundled/v3/components/OrCode/theme.js +1 -1
- package/dist/bundled/v3/components/index.d.ts +0 -1
- package/dist/bundled/v3/components/index.js +4 -10
- package/dist/bundled/v3/{index-6a13fa4e.js → index-cf2c3c27.js} +1 -1
- package/dist/bundled/v3/index.js +10 -16
- package/dist/bundled/v3/{index-eba9b646.js → lang-0fb8f78b.js} +22 -2
- package/dist/esm/v2/components/index.d.ts +0 -1
- package/dist/esm/v2/components/index.js +1 -2
- package/dist/esm/v2/index.js +0 -1
- package/dist/esm/v3/components/index.d.ts +0 -1
- package/dist/esm/v3/components/index.js +1 -2
- package/dist/esm/v3/index.js +0 -1
- package/package.json +4 -3
- package/src/components/index.ts +0 -1
- package/dist/bundled/v2/components/OrCodeV3/OrCode.js +0 -333
- package/dist/bundled/v2/components/OrCodeV3/OrCode.vue.d.ts +0 -169
- package/dist/bundled/v2/components/OrCodeV3/index.d.ts +0 -2
- package/dist/bundled/v2/components/OrCodeV3/index.js +0 -49
- package/dist/bundled/v2/components/OrCodeV3/props.d.ts +0 -8
- package/dist/bundled/v2/components/OrCodeV3/props.js +0 -11
- package/dist/bundled/v2/components/OrCodeV3/styles.d.ts +0 -2
- package/dist/bundled/v2/components/OrCodeV3/styles.js +0 -10
- package/dist/bundled/v3/OrCode.vue_vue_type_script_lang-1812e6e4.js +0 -237
- package/dist/bundled/v3/OrCode.vue_vue_type_script_lang-84a512fb.js +0 -200
- package/dist/bundled/v3/components/OrCodeV3/OrCode.js +0 -142
- package/dist/bundled/v3/components/OrCodeV3/OrCode.vue.d.ts +0 -119
- package/dist/bundled/v3/components/OrCodeV3/index.d.ts +0 -2
- package/dist/bundled/v3/components/OrCodeV3/index.js +0 -60
- package/dist/bundled/v3/components/OrCodeV3/props.d.ts +0 -8
- package/dist/bundled/v3/components/OrCodeV3/props.js +0 -11
- package/dist/bundled/v3/components/OrCodeV3/styles.d.ts +0 -2
- package/dist/bundled/v3/components/OrCodeV3/styles.js +0 -10
- package/dist/bundled/v3/index-576b3dec.js +0 -3794
- package/dist/esm/v2/OrCode-ad718022.js +0 -327
- package/dist/esm/v2/components/or-code-v3/OrCode.vue.d.ts +0 -169
- package/dist/esm/v2/components/or-code-v3/index.d.ts +0 -2
- package/dist/esm/v2/components/or-code-v3/index.js +0 -35
- package/dist/esm/v2/components/or-code-v3/props.d.ts +0 -8
- package/dist/esm/v2/components/or-code-v3/styles.d.ts +0 -2
- package/dist/esm/v3/OrCode-8ccd5dc7.js +0 -301
- package/dist/esm/v3/components/or-code-v3/OrCode.vue.d.ts +0 -119
- package/dist/esm/v3/components/or-code-v3/index.d.ts +0 -2
- package/dist/esm/v3/components/or-code-v3/index.js +0 -33
- package/dist/esm/v3/components/or-code-v3/props.d.ts +0 -8
- package/dist/esm/v3/components/or-code-v3/styles.d.ts +0 -2
- package/src/components/or-code-v3/OrCode.vue +0 -338
- package/src/components/or-code-v3/index.ts +0 -2
- package/src/components/or-code-v3/props.ts +0 -8
- package/src/components/or-code-v3/styles.ts +0 -12
|
@@ -1,338 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div
|
|
3
|
-
ref="root"
|
|
4
|
-
:class="rootStyles"
|
|
5
|
-
>
|
|
6
|
-
<template v-if="label">
|
|
7
|
-
<OrLabel
|
|
8
|
-
:control-id="controlAttributes.id"
|
|
9
|
-
:variant="'input'"
|
|
10
|
-
:required="required"
|
|
11
|
-
:disabled="disabled"
|
|
12
|
-
>
|
|
13
|
-
{{ label }}
|
|
14
|
-
|
|
15
|
-
<template v-slot:addon>
|
|
16
|
-
<div :class="['layout-row', 'gap-xs']">
|
|
17
|
-
<slot name="addon" />
|
|
18
|
-
|
|
19
|
-
<OrIconButton
|
|
20
|
-
:icon="'fullscreen'"
|
|
21
|
-
@click.stop="modal.open()"
|
|
22
|
-
/>
|
|
23
|
-
</div>
|
|
24
|
-
</template>
|
|
25
|
-
</OrLabel>
|
|
26
|
-
</template>
|
|
27
|
-
|
|
28
|
-
<OrInputBox
|
|
29
|
-
:size="'m'"
|
|
30
|
-
:invalid="!!error"
|
|
31
|
-
:readonly="readonly"
|
|
32
|
-
:disabled="disabled"
|
|
33
|
-
>
|
|
34
|
-
<div
|
|
35
|
-
ref="control"
|
|
36
|
-
:class="controlStyles"
|
|
37
|
-
/>
|
|
38
|
-
</OrInputBox>
|
|
39
|
-
|
|
40
|
-
<div
|
|
41
|
-
v-show="!error"
|
|
42
|
-
:class="['contents']"
|
|
43
|
-
>
|
|
44
|
-
<template v-if="hint">
|
|
45
|
-
<OrHint :disabled="disabled">
|
|
46
|
-
{{ hint }}
|
|
47
|
-
</OrHint>
|
|
48
|
-
</template>
|
|
49
|
-
</div>
|
|
50
|
-
|
|
51
|
-
<div
|
|
52
|
-
v-show="typeof error === 'string'"
|
|
53
|
-
:class="['contents']"
|
|
54
|
-
>
|
|
55
|
-
<OrError :disabled="disabled">
|
|
56
|
-
{{ error }}
|
|
57
|
-
</OrError>
|
|
58
|
-
</div>
|
|
59
|
-
|
|
60
|
-
<OrModal ref="modal">
|
|
61
|
-
<OrInputBox
|
|
62
|
-
:size="'m'"
|
|
63
|
-
:invalid="!!error"
|
|
64
|
-
:readonly="readonly"
|
|
65
|
-
:disabled="disabled"
|
|
66
|
-
>
|
|
67
|
-
<div
|
|
68
|
-
ref="fullscreenControl"
|
|
69
|
-
:class="controlStyles"
|
|
70
|
-
/>
|
|
71
|
-
</OrInputBox>
|
|
72
|
-
</OrModal>
|
|
73
|
-
</div>
|
|
74
|
-
</template>
|
|
75
|
-
|
|
76
|
-
<script lang="ts">
|
|
77
|
-
import { indentWithTab } from '@codemirror/commands';
|
|
78
|
-
import { css } from '@codemirror/lang-css';
|
|
79
|
-
import { html } from '@codemirror/lang-html';
|
|
80
|
-
import { javascript } from '@codemirror/lang-javascript';
|
|
81
|
-
import { json } from '@codemirror/lang-json';
|
|
82
|
-
import { markdown } from '@codemirror/lang-markdown';
|
|
83
|
-
import { EditorState, Extension } from '@codemirror/state';
|
|
84
|
-
import { EditorView, keymap } from '@codemirror/view';
|
|
85
|
-
import { basicSetup } from 'codemirror';
|
|
86
|
-
import { PropType, computed, defineComponent, onMounted, onUnmounted, reactive, ref, watch } from 'vue-demi';
|
|
87
|
-
import { useControlAttributes, useIdAttribute, useValidationAttributes } from '../../hooks';
|
|
88
|
-
import { OrErrorV3 as OrError } from '../or-error-v3';
|
|
89
|
-
import { OrHintV3 as OrHint } from '../or-hint-v3';
|
|
90
|
-
import { OrIconButtonV3 as OrIconButton } from '../or-icon-button-v3';
|
|
91
|
-
import { OrInputBoxV3 as OrInputBox } from '../or-input-box-v3';
|
|
92
|
-
import { OrLabelV3 as OrLabel } from '../or-label-v3';
|
|
93
|
-
import { OrModalV3 as OrModal } from '../or-modal-v3';
|
|
94
|
-
import { CodeLanguage } from './props';
|
|
95
|
-
import { Code, CodeControl } from './styles';
|
|
96
|
-
|
|
97
|
-
export default defineComponent({
|
|
98
|
-
name: 'OrCode',
|
|
99
|
-
|
|
100
|
-
components: {
|
|
101
|
-
OrError,
|
|
102
|
-
OrHint,
|
|
103
|
-
OrIconButton,
|
|
104
|
-
OrInputBox,
|
|
105
|
-
OrLabel,
|
|
106
|
-
OrModal,
|
|
107
|
-
},
|
|
108
|
-
|
|
109
|
-
model: {
|
|
110
|
-
prop: 'modelValue',
|
|
111
|
-
event: 'update:modelValue',
|
|
112
|
-
},
|
|
113
|
-
|
|
114
|
-
props: {
|
|
115
|
-
modelValue: {
|
|
116
|
-
type: String,
|
|
117
|
-
default: undefined,
|
|
118
|
-
},
|
|
119
|
-
|
|
120
|
-
language: {
|
|
121
|
-
type: String as PropType<CodeLanguage>,
|
|
122
|
-
default: CodeLanguage.JS,
|
|
123
|
-
},
|
|
124
|
-
|
|
125
|
-
extensions: {
|
|
126
|
-
type: Array as PropType<Extension[]>,
|
|
127
|
-
default: () => [basicSetup],
|
|
128
|
-
},
|
|
129
|
-
|
|
130
|
-
label: {
|
|
131
|
-
type: String,
|
|
132
|
-
default: undefined,
|
|
133
|
-
},
|
|
134
|
-
|
|
135
|
-
hint: {
|
|
136
|
-
type: String,
|
|
137
|
-
default: undefined,
|
|
138
|
-
},
|
|
139
|
-
|
|
140
|
-
error: {
|
|
141
|
-
type: [String, Boolean],
|
|
142
|
-
default: undefined,
|
|
143
|
-
},
|
|
144
|
-
|
|
145
|
-
required: {
|
|
146
|
-
type: Boolean,
|
|
147
|
-
default: false,
|
|
148
|
-
},
|
|
149
|
-
|
|
150
|
-
readonly: {
|
|
151
|
-
type: Boolean,
|
|
152
|
-
default: false,
|
|
153
|
-
},
|
|
154
|
-
|
|
155
|
-
disabled: {
|
|
156
|
-
type: Boolean,
|
|
157
|
-
default: false,
|
|
158
|
-
},
|
|
159
|
-
},
|
|
160
|
-
|
|
161
|
-
emits: [
|
|
162
|
-
'update:modelValue',
|
|
163
|
-
|
|
164
|
-
'keydown',
|
|
165
|
-
'keyup',
|
|
166
|
-
'focus',
|
|
167
|
-
'blur',
|
|
168
|
-
],
|
|
169
|
-
|
|
170
|
-
expose: [
|
|
171
|
-
'root',
|
|
172
|
-
|
|
173
|
-
'focus',
|
|
174
|
-
'blur',
|
|
175
|
-
],
|
|
176
|
-
|
|
177
|
-
setup(props, context) {
|
|
178
|
-
// Refs
|
|
179
|
-
const root = ref<HTMLElement>();
|
|
180
|
-
const control = ref<HTMLElement>();
|
|
181
|
-
const fullscreenControl = ref<HTMLElement>();
|
|
182
|
-
|
|
183
|
-
const modal = ref<InstanceType<typeof OrModal>>();
|
|
184
|
-
|
|
185
|
-
// Styles
|
|
186
|
-
const rootStyles = computed(() => [
|
|
187
|
-
'or-code-v3',
|
|
188
|
-
...Code,
|
|
189
|
-
]);
|
|
190
|
-
|
|
191
|
-
const controlStyles = computed(() => [
|
|
192
|
-
...CodeControl,
|
|
193
|
-
]);
|
|
194
|
-
|
|
195
|
-
// State
|
|
196
|
-
const controlAttributes = reactive({
|
|
197
|
-
id: useIdAttribute(),
|
|
198
|
-
...useControlAttributes(),
|
|
199
|
-
...useValidationAttributes(),
|
|
200
|
-
});
|
|
201
|
-
|
|
202
|
-
const proxyModelValue = computed({
|
|
203
|
-
get: () => props.modelValue,
|
|
204
|
-
|
|
205
|
-
set: (value) => {
|
|
206
|
-
context.emit('update:modelValue', value);
|
|
207
|
-
},
|
|
208
|
-
});
|
|
209
|
-
|
|
210
|
-
const proxyLanguage = computed(() => {
|
|
211
|
-
switch (props.language) {
|
|
212
|
-
case CodeLanguage.HTML:
|
|
213
|
-
return html();
|
|
214
|
-
|
|
215
|
-
case CodeLanguage.CSS:
|
|
216
|
-
return css();
|
|
217
|
-
|
|
218
|
-
case CodeLanguage.JS:
|
|
219
|
-
return javascript();
|
|
220
|
-
|
|
221
|
-
case CodeLanguage.TS:
|
|
222
|
-
return javascript({ typescript: true });
|
|
223
|
-
|
|
224
|
-
case CodeLanguage.JSON:
|
|
225
|
-
return json();
|
|
226
|
-
|
|
227
|
-
case CodeLanguage.MD:
|
|
228
|
-
return markdown();
|
|
229
|
-
}
|
|
230
|
-
});
|
|
231
|
-
|
|
232
|
-
// Methods
|
|
233
|
-
function focus(): void {
|
|
234
|
-
control.value?.focus();
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
function blur(): void {
|
|
238
|
-
control.value?.blur();
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
// #region Codemirror
|
|
242
|
-
const editorView = new EditorView({
|
|
243
|
-
dispatch: (transaction) => {
|
|
244
|
-
editorView.update([
|
|
245
|
-
transaction,
|
|
246
|
-
]);
|
|
247
|
-
|
|
248
|
-
proxyModelValue.value = String(editorView.state.doc);
|
|
249
|
-
},
|
|
250
|
-
});
|
|
251
|
-
|
|
252
|
-
const extensions = computed<Extension[]>(() => [
|
|
253
|
-
...props.extensions,
|
|
254
|
-
proxyLanguage.value,
|
|
255
|
-
keymap.of([indentWithTab]),
|
|
256
|
-
EditorView.editable.of(!props.readonly && !props.disabled),
|
|
257
|
-
|
|
258
|
-
EditorView.domEventHandlers({
|
|
259
|
-
keydown: (event) => {
|
|
260
|
-
context.emit('keydown', event);
|
|
261
|
-
},
|
|
262
|
-
|
|
263
|
-
keyup: (event) => {
|
|
264
|
-
context.emit('keyup', event);
|
|
265
|
-
},
|
|
266
|
-
|
|
267
|
-
focus: (event) => {
|
|
268
|
-
context.emit('focus', event);
|
|
269
|
-
},
|
|
270
|
-
|
|
271
|
-
blur: (event) => {
|
|
272
|
-
context.emit('blur', event);
|
|
273
|
-
},
|
|
274
|
-
}),
|
|
275
|
-
|
|
276
|
-
EditorView.baseTheme({}),
|
|
277
|
-
]);
|
|
278
|
-
|
|
279
|
-
watch([
|
|
280
|
-
proxyModelValue,
|
|
281
|
-
extensions,
|
|
282
|
-
], ([
|
|
283
|
-
modelValue = '',
|
|
284
|
-
extensions,
|
|
285
|
-
]) => {
|
|
286
|
-
const { selection } = editorView.state;
|
|
287
|
-
|
|
288
|
-
editorView.setState(
|
|
289
|
-
EditorState.create({
|
|
290
|
-
doc: modelValue,
|
|
291
|
-
extensions,
|
|
292
|
-
|
|
293
|
-
selection: selection.ranges.some((range) => range.to > modelValue.length)
|
|
294
|
-
? { anchor: modelValue.length }
|
|
295
|
-
: selection,
|
|
296
|
-
}),
|
|
297
|
-
);
|
|
298
|
-
}, {
|
|
299
|
-
immediate: true,
|
|
300
|
-
});
|
|
301
|
-
// #endregion
|
|
302
|
-
|
|
303
|
-
// Effects
|
|
304
|
-
watch(() => modal.value?.state, (value) => {
|
|
305
|
-
setTimeout(() => {
|
|
306
|
-
if (value === 'open') {
|
|
307
|
-
fullscreenControl.value?.append(editorView.dom);
|
|
308
|
-
} else {
|
|
309
|
-
control.value?.append(editorView.dom);
|
|
310
|
-
}
|
|
311
|
-
});
|
|
312
|
-
});
|
|
313
|
-
|
|
314
|
-
// Lifecycle
|
|
315
|
-
onMounted(() => {
|
|
316
|
-
control.value?.append(editorView.dom);
|
|
317
|
-
});
|
|
318
|
-
|
|
319
|
-
onUnmounted(() => {
|
|
320
|
-
editorView.destroy();
|
|
321
|
-
});
|
|
322
|
-
|
|
323
|
-
return {
|
|
324
|
-
root,
|
|
325
|
-
control,
|
|
326
|
-
fullscreenControl,
|
|
327
|
-
modal,
|
|
328
|
-
rootStyles,
|
|
329
|
-
controlStyles,
|
|
330
|
-
controlAttributes,
|
|
331
|
-
proxyModelValue,
|
|
332
|
-
proxyLanguage,
|
|
333
|
-
focus,
|
|
334
|
-
blur,
|
|
335
|
-
};
|
|
336
|
-
},
|
|
337
|
-
});
|
|
338
|
-
</script>
|