@studio-west/component-sw 0.12.25 → 0.13.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.
Files changed (28) hide show
  1. package/README.md +141 -28
  2. package/dist/{SwAlert-CU7nEnO-.js → SwAlert-CKJhS25j.js} +2 -2
  3. package/dist/SwButton-B-Z8Fhdv.js +61 -0
  4. package/dist/{SwDropdownItem-CKOTwhTf.js → SwDropdownItem-9Bq9fExK.js} +1 -1
  5. package/dist/SwFile-hpyHTblK.js +499 -0
  6. package/dist/{SwGide-Ie6XCPUn.js → SwGide-C62de-t6.js} +2 -2
  7. package/dist/{SwIcon-D6FCTrgR.js → SwIcon-CyVWEZkk.js} +1 -1
  8. package/dist/{SwInput-u7kS3lQn.js → SwInput-BED_o0wD.js} +1 -1
  9. package/dist/{SwMessage-DRjFGSK3.js → SwMessage-CA8jo3G7.js} +2 -2
  10. package/dist/{SwSkeleton-Byvq4bjt.js → SwSkeleton-BIj8PPM_.js} +1 -1
  11. package/dist/component-sw.css +1 -1
  12. package/dist/index.cjs +6 -6
  13. package/dist/index.js +21 -20
  14. package/package.json +3 -2
  15. package/types/components.d.ts +3 -0
  16. package/types/index.d.ts +19 -0
  17. package/dist/SwButton-Bvn3JLcT.js +0 -61
  18. /package/dist/{SwFormItem-DQJohClb.js → SwFormItem-rn5iuIUv.js} +0 -0
  19. /package/dist/{SwMenu-eQSh_MlP.js → SwMenu-Bh4BtVif.js} +0 -0
  20. /package/dist/{SwSection-BN1U3KaZ.js → SwSection-Bl3H3D2G.js} +0 -0
  21. /package/dist/{SwSelect-CMDZWWEI.js → SwSelect-DyArzImF.js} +0 -0
  22. /package/dist/{SwSkeletonItem-BnXZXE54.js → SwSkeletonItem-BKeBIWXT.js} +0 -0
  23. /package/dist/{SwSlider-DrIc0Xna.js → SwSlider-4S5KNn6o.js} +0 -0
  24. /package/dist/{SwSwitch-BVbje0T9.js → SwSwitch-BqAIQmG3.js} +0 -0
  25. /package/dist/{SwTable-4kHapbYy.js → SwTable-BjYEVovB.js} +0 -0
  26. /package/dist/{SwTableColumn-DCxVGb9d.js → SwTableColumn-CpNTUOVF.js} +0 -0
  27. /package/dist/{SwTabs-x2bXZwz1.js → SwTabs-jUzYPw9X.js} +0 -0
  28. /package/dist/{SwTabsPane-DpkTKQH8.js → SwTabsPane-Bhi49paR.js} +0 -0
package/README.md CHANGED
@@ -10,6 +10,13 @@ The `Component SW` library provides a set of ready-to-use UI components on Vue 3
10
10
 
11
11
  ---
12
12
 
13
+ ## SSR / Server-Side Rendering
14
+ Библиотеку можно безопасно импортировать на сервере: сборка `dist/index.js` (и `dist/index.cjs`) больше не обращается к `document`/`window`/`navigator` на верхнем уровне. Инициализация `Alert` выполняется лениво и защищена проверкой окружения.
15
+
16
+ The library is safe to import on the server: the `dist/index.js` (and `dist/index.cjs`) bundle no longer touches `document`/`window`/`navigator` at the top level. `Alert` initialization is lazy and environment-guarded.
17
+
18
+ ---
19
+
13
20
  ### Содержание / Table of Contents
14
21
 
15
22
  Интерактивный плейграунд последней версии с живыми примерами, демонстрацией компонентов в браузере: [studiowest.ru/component-sw](https://studiowest.ru/component-sw/).
@@ -18,8 +25,6 @@ Interactive playground of the latest version with live examples, demonstration o
18
25
 
19
26
  - [Установка / Install](#установка--install)
20
27
 
21
- - [SSR / Server-Side Rendering](#ssr--server-side-rendering)
22
-
23
28
  - [SwAlert](#swalert)
24
29
 
25
30
  - [SwButton](#swbutton)
@@ -34,6 +39,8 @@ Interactive playground of the latest version with live examples, demonstration o
34
39
 
35
40
  - [SwDropdownItem](#swdropdownitem)
36
41
 
42
+ - [SwFile](#swfile)
43
+
37
44
  - [SwIcon](#swicon)
38
45
 
39
46
  - [SwGide](#swgide)
@@ -109,28 +116,6 @@ const darkMode = () => {
109
116
  ```
110
117
  ---
111
118
 
112
- ## SSR / Server-Side Rendering
113
-
114
- Начиная с версии `0.12.11` библиотеку можно безопасно импортировать на сервере: сборка `dist/index.js` (и `dist/index.cjs`) больше не обращается к `document`/`window`/`navigator` на верхнем уровне. Инициализация `Alert` выполняется лениво и защищена проверкой окружения, поэтому импорт модуля в Node/SSR не падает.
115
-
116
- Since version `0.12.11` the library is safe to import on the server: the `dist/index.js` (and `dist/index.cjs`) bundle no longer touches `document`/`window`/`navigator` at the top level. `Alert` initialization is lazy and environment-guarded, so importing the module in Node/SSR does not throw.
117
-
118
- ```js
119
- // SSR: безопасный импорт собранной библиотеки / SSR-safe import of the built library
120
- import { Library } from '@studio-west/component-sw'
121
- import '@studio-west/component-sw/dist/component-sw.css'
122
-
123
- app.use(Library)
124
-
125
- // $Alert использует DOM, поэтому вызывайте его только на клиенте /
126
- // $Alert touches the DOM, so call it on the client only
127
- if (typeof document !== 'undefined') {
128
- const Alert = inject('Alert')
129
- Alert({ message: 'Готово / Done', type: 'success' })
130
- }
131
- ```
132
- ---
133
-
134
119
  ## SwAlert
135
120
 
136
121
  Функция / Компонент `SwAlert` система всплывающих сообщений. Сообщения могут быть с разным типом и временем показа. Могут иметь футер с кнопками.
@@ -150,7 +135,7 @@ if (typeof document !== 'undefined') {
150
135
 
151
136
  ### Слоты / Slots
152
137
 
153
- Default - текст описания или модуль / модули
138
+ Default - Текст описания или модуль / модули
154
139
 
155
140
  #prefix - Вставка перед текстом (если не передан `before`)
156
141
 
@@ -432,9 +417,136 @@ Default - текст названия или модуль
432
417
  ```
433
418
  ---
434
419
 
420
+ ## SwFile
421
+
422
+ Компонент `SwFile` — загрузчик файлов с двумя режимами: **photo** (фото и видео с пред-просмотром и обрезкой) и **document** (документы с просмотром в отдельном окне браузера). Поддерживает drag & drop и выбор через системный диалог.
423
+
424
+ ### Режимы / Modes
425
+
426
+ | Режим | `mode` | Описание / Description |
427
+ |--------------|--------------|----------------------------------------------------------------------------|
428
+ | Фото | `photo` | `image/*`, `video/*` — один файл, предпросмотр, обрезка области. |
429
+ | Документы | `document` | PDF, Word, Excel и др. — несколько файлов, клик открывает в новой вкладке. |
430
+
431
+ ### Свойства / Properties
432
+
433
+ | Имя | Тип | По умолчанию | Значения/Описание |
434
+ |----------------|---------------------|--------------|------------------------------------------------------------------------------------------------|
435
+ | `mode` | `String` | `photo` | `'photo'` \| `'document'`. |
436
+ | `disabled` | `Boolean` | `false` | Блокировка загрузки и удаления. |
437
+ | `accept` | `String` | `` | Переопределение `accept` у `<input type="file">`. По умолчанию зависит от `mode`. |
438
+ | `label` | `String` | `` | Заголовок зоны загрузки. |
439
+ | `class` | `String` | `` | Дополнительный CSS-класс корневого элемента. |
440
+ | `aspectRatio` | `Number` \| `null` | `null` | Соотношение сторон области обрезки в режиме `photo` (например `1`, `16/9`). |
441
+ | `editorTitle` | `String[]` | см. описание | Заголовки редактора: По умолчанию `['Preview', 'Preview and crop', 'Preview and crop video']`. |
442
+
443
+ ### Модель / Model
444
+
445
+ `v-model` — массив объектов `File[]` (итоговые файлы после обрезки или без неё).
446
+
447
+ ### События / Events
448
+
449
+ | Имя | Параметры | Описание |
450
+ |-----------|------------------------|-----------------------------------------------------|
451
+ | `change` | `files: File[]` | Срабатывает при изменении списка файлов в модели. |
452
+ | `remove` | `file: File`, `index` | Удаление файла из списка. |
453
+ | `preview` | `file: File` | В режиме `document` — перед открытием в новом окне. |
454
+
455
+ ### Слоты / Slots
456
+
457
+ | Имя | Описание / Description |
458
+ |--------------|-------------------------------------------------------------------------|
459
+ | default | Текст зоны загрузки; scope: `{ mode, label }`. |
460
+ | `data` | Имя и размер файла в списке; scope: `{ item, file, index, size }`. |
461
+ | `remove` | Вся кнопка удаления; scope: `{ item, file, index, disabled, onClick }`. |
462
+ | `close` | Вся кнопка закрытия; scope: `{ onClick }`. |
463
+ | `skip-crop` | Вся кнопка без обрезки; scope: `{ processing, onClick }`. |
464
+ | `apply` | Вся кнопка применения; scope: `{ processing, onClick }`. |
465
+
466
+ ### Особенности реализации
467
+
468
+ **Режим `photo`**
469
+
470
+ - После выбора файла открывается модальное окно с пред-просмотром.
471
+ - Для изображений обрезка выполняется через `canvas`.
472
+ - Для видео обрезка области записывается через `canvas` + `MediaRecorder` (результат — `webm`, если браузер поддерживает).
473
+ - Область обрезки можно перемещать и менять размер угловыми ручками.
474
+ - Кнопка skip-crop добавляет исходный файл без изменений.
475
+
476
+ **Режим `document`**
477
+
478
+ - Файлы отображаются списком с именем и размером.
479
+ - Можно выбрать или перетащить несколько файлов за один раз.
480
+ - Клик по элементу открывает файл в новой вкладке.
481
+
482
+ ### Пример использования / Example Usage
483
+
484
+ ```html
485
+ <script setup>
486
+ import { ref } from 'vue'
487
+
488
+ const photoFiles = ref([])
489
+ const documentFiles = ref([])
490
+ </script>
491
+
492
+ <!-- Фото / видео -->
493
+ <sw-file
494
+ v-model="photoFiles"
495
+ mode="photo"
496
+ :aspect-ratio="1"
497
+ label="Загрузить фото или видео"
498
+ :editor-title="[
499
+ 'Предпросмотр',
500
+ 'Предпросмотр и обрезка',
501
+ 'Предпросмотр и обрезка видео'
502
+ ]"
503
+ >
504
+ <template #default="{ label }">
505
+ <span class="sw-file-drop-title">{{ label }}</span>
506
+ <span class="sw-file-drop-hint">Перетащите файл или нажмите для выбора</span>
507
+ </template>
508
+ <template #data="{ file, size }">
509
+ <span class="sw-file-item-name">{{ file.name }}</span>
510
+ <span class="sw-file-item-meta">{{ size }}</span>
511
+ </template>
512
+ <template #remove="{ onClick, disabled }">
513
+ <sw-button type="danger" text :disabled="disabled" @click="onClick">Удалить</sw-button>
514
+ </template>
515
+ <template #skip-crop="{ onClick, processing }">
516
+ <sw-button text :disabled="processing" @click="onClick">Без обрезки</sw-button>
517
+ </template>
518
+ <template #apply="{ onClick, processing }">
519
+ <sw-button type="primary" :disabled="processing" @click="onClick">
520
+ {{ processing ? 'Обработка…' : 'Применить' }}
521
+ </sw-button>
522
+ </template>
523
+ </sw-file>
524
+
525
+ <!-- Документы -->
526
+ <sw-file
527
+ v-model="documentFiles"
528
+ mode="document"
529
+ label="Загрузить документы"
530
+ >
531
+ <template #default="{ label }">
532
+ <span class="sw-file-drop-title">{{ label }}</span>
533
+ <span class="sw-file-drop-hint">PDF, Word, Excel — можно выбрать несколько файлов сразу</span>
534
+ </template>
535
+ <template #data="{ file, size }">
536
+ <span class="sw-file-item-name">{{ file.name }}</span>
537
+ <span class="sw-file-item-meta">{{ size }}</span>
538
+ </template>
539
+ <template #remove="{ onClick, disabled }">
540
+ <sw-button type="danger" text :disabled="disabled" @click="onClick">Удалить</sw-button>
541
+ </template>
542
+ </sw-file>
543
+ ```
544
+
545
+ ---
546
+
435
547
  ## SwIcon
436
548
 
437
- Компонент `SwIcon` отображает SVG-иконку из встроенного спрайта или по внешнему URL.
549
+ Компонент `SwIcon` отображает SVG-иконку из встроенного спрайта или по-внешнему URL.
438
550
 
439
551
  Если `iconClass` начинается с `http://`, `https://`, иконка загружается как внешний SVG через CSS `mask` (класс `sw-external-icon`). Иначе используется символ из спрайта: `#prefix-iconClass`.
440
552
 
@@ -566,7 +678,7 @@ const model = ref('')
566
678
  size="large"
567
679
  type="phone"
568
680
  before="https://cdn.jsdelivr.net/npm/@tabler/icons@3.19.0/icons/outline/phone.svg"
569
- placeholder="+0 (___) ___-__-__"
681
+ placeholder="Your phone"
570
682
  label="Телефон"
571
683
  @prefix="console.log('before')"
572
684
  >
@@ -606,7 +718,8 @@ change - событие изменения значения компонента
606
718
  type: 'primary',
607
719
  slot: 'Текст кнопки'
608
720
  },
609
- 'SwSwitch': [
721
+ 'SwSwitch':
722
+ [
610
723
  {
611
724
  label: 'Переключатель 1',
612
725
  on: 'Вкл',
@@ -1,5 +1,5 @@
1
- import { n as e } from "./SwIcon-D6FCTrgR.js";
2
- import { t } from "./SwSelect-CMDZWWEI.js";
1
+ import { n as e } from "./SwIcon-CyVWEZkk.js";
2
+ import { t } from "./SwSelect-DyArzImF.js";
3
3
  import { Transition as n, computed as r, createBlock as i, createCommentVNode as a, createElementBlock as o, createElementVNode as s, createTextVNode as c, normalizeClass as l, onMounted as u, onUnmounted as d, openBlock as f, ref as p, renderSlot as m, toDisplayString as h, withCtx as g } from "vue";
4
4
  //#region src/components/SwAlert.vue
5
5
  var _ = /* @__PURE__ */ t({ default: () => v }), v = {
@@ -0,0 +1,61 @@
1
+ import { t as e } from "./SwSelect-DyArzImF.js";
2
+ import { computed as t, createBlock as n, createCommentVNode as r, createElementBlock as i, createTextVNode as a, defineComponent as o, normalizeClass as s, openBlock as c, renderSlot as l, resolveComponent as u, toDisplayString as d } from "vue";
3
+ //#region src/components/SwButton.vue?vue&type=script&setup=true&lang.ts
4
+ var f = /* @__PURE__ */ o({
5
+ __name: "SwButton",
6
+ props: {
7
+ class: { default: "" },
8
+ size: { default: "" },
9
+ type: { default: "" },
10
+ round: {
11
+ type: Boolean,
12
+ default: !1
13
+ },
14
+ text: {
15
+ type: Boolean,
16
+ default: !1
17
+ },
18
+ link: {
19
+ type: Boolean,
20
+ default: !1
21
+ },
22
+ href: { default: "" },
23
+ disabled: {
24
+ type: Boolean,
25
+ default: !1
26
+ },
27
+ label: { default: "" },
28
+ prefix: { default: "" },
29
+ postfix: { default: "" }
30
+ },
31
+ setup(e) {
32
+ let o = e, f = () => {
33
+ if (o.href.length > 0) {
34
+ let e = document.createElement("a");
35
+ e.setAttribute("href", o.href), e.setAttribute("target", "_blank"), o.disabled || e.click();
36
+ }
37
+ }, p = t(() => {
38
+ let e = ["sw-button"];
39
+ return o.size.length > 0 && e.push("sw-" + o.size), o.type.length > 0 && e.push("sw-" + o.type), o.round && e.push("sw-round"), o.text && e.push("sw-text"), o.link && e.push("sw-link"), o.disabled && e.push("sw-disabled"), o.class.length > 0 && e.push(o.class), e;
40
+ });
41
+ return (t, o) => {
42
+ let m = u("sw-icon");
43
+ return c(), i("button", {
44
+ class: s(p.value),
45
+ onClick: f
46
+ }, [l(t.$slots, "default", {}, () => [
47
+ e.prefix ? (c(), n(m, {
48
+ key: 0,
49
+ iconClass: e.prefix
50
+ }, null, 8, ["iconClass"])) : r("", !0),
51
+ a(d(e.label), 1),
52
+ e.postfix ? (c(), n(m, {
53
+ key: 1,
54
+ iconClass: e.postfix
55
+ }, null, 8, ["iconClass"])) : r("", !0)
56
+ ])], 2);
57
+ };
58
+ }
59
+ }), p = /* @__PURE__ */ e({ default: () => m }), m = f;
60
+ //#endregion
61
+ export { p as n, m as t };
@@ -1,4 +1,4 @@
1
- import { n as e } from "./SwIcon-D6FCTrgR.js";
1
+ import { n as e } from "./SwIcon-CyVWEZkk.js";
2
2
  import { computed as t, createBlock as n, createCommentVNode as r, createElementBlock as i, normalizeClass as a, openBlock as o, renderSlot as s } from "vue";
3
3
  //#region src/components/SwDropdownItem.vue
4
4
  var c = {