@studio-west/component-sw 0.13.18 → 0.13.19

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 (2) hide show
  1. package/README.md +434 -786
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -45,10 +45,10 @@ Interactive playground of the latest version with live examples, demonstration o
45
45
 
46
46
  - [SwFormItem](#swformitem)
47
47
 
48
- - [SwIcon](#swicon)
49
-
50
48
  - [SwGide](#swgide)
51
49
 
50
+ - [SwIcon](#swicon)
51
+
52
52
  - [SwInput](#swinput)
53
53
 
54
54
  - [SwMenu](#swmenu)
@@ -57,10 +57,10 @@ Interactive playground of the latest version with live examples, demonstration o
57
57
 
58
58
  - [SwPagination](#swpagination)
59
59
 
60
- - [SwSelect](#swselect)
61
-
62
60
  - [SwSection](#swsection)
63
61
 
62
+ - [SwSelect](#swselect)
63
+
64
64
  - [SwSkeleton](#swskeleton)
65
65
 
66
66
  - [SwSkeletonItem](#swskeletonitem)
@@ -87,29 +87,6 @@ npm install @studio-west/component-sw
87
87
 
88
88
  Registry: [npmjs](https://www.npmjs.com/package/@studio-west/component-sw).
89
89
 
90
- ### Публикация / Publish
91
-
92
- ```bash
93
- npm version patch # или minor / major
94
- npm publish # либо: npm run release:patch
95
- git push && git push --tags
96
- ```
97
-
98
- CI: git-тег `v*.*.*` → workflow **Publish to npm** (secret **`NPM_TOKEN`**).
99
-
100
- ### Разработка / Development
101
-
102
- Нужен **Node 24** через [nvm](https://github.com/nvm-sh/nvm) (см. `.nvmrc`). Системный Node 21 с Vite 8 не совместим.
103
-
104
- ```bash
105
- nvm use # или: nvm install
106
- npm run dev # scripts/with-node.sh сам переключает Node
107
- npm run build
108
- ```
109
-
110
- Не вызывайте `npx vite` напрямую на системном Node — используйте `npm run …`. /
111
- Requires **Node 24** via [nvm](https://github.com/nvm-sh/nvm) (see `.nvmrc`). System Node 21 is incompatible with Vite 8. Use `npm run …` (via `scripts/with-node.sh`), not bare `npx vite`.
112
-
113
90
  ### Глобальное подключение / global add to main.js
114
91
  ```js
115
92
  import { Library } from '@studio-west/component-sw';
@@ -127,6 +104,7 @@ const {
127
104
  } = components;
128
105
 
129
106
  ```
107
+
130
108
  Установка в ручную светлой и темной темы - добавление к тегу `html` классов `dark` или `light` / Installation in a manual light and dark theme - adding to the tag `html` classes` dark` or `light`
131
109
 
132
110
  ### Пример использования / Example Usage
@@ -151,7 +129,7 @@ const darkMode = () => {
151
129
 
152
130
  ## SwAlert
153
131
 
154
- Функция `Alert()` — система всплывающих сообщений. Несколько алертов стекаются; позиция и порядок задаются параметрами `placement` / `align`.
132
+ Функция `Alert()` — система всплывающих сообщений. Несколько сообщений групируются; позиция и порядок задаются параметрами `placement` / `align`.
155
133
 
156
134
  The `Alert()` function shows toast messages. Multiple alerts stack; position and order are controlled by `placement` / `align`.
157
135
 
@@ -164,7 +142,7 @@ The `Alert()` function shows toast messages. Multiple alerts stack; position and
164
142
  | `type` | `String` | `info` | `'primary'`, `'success'`, `'info'`, `'warning'`, `'danger'` (алиас `'error'` → `danger`). |
165
143
  | `message` | `String` | `Default message` | Текст сообщения. |
166
144
  | `duration` | `Number` | `6000` | Время отображения в миллисекундах. |
167
- | `placement` | `String` | `top` | Вертикаль: `'top'` — старые сверху, новые ниже; `'bottom'` — свежие сверху стека у низа экрана. |
145
+ | `placement` | `String` | `top` | Вертикаль: `'top'` — старые сверху в верху экрана; `'bottom'` — новые сверху у низа экрана. |
168
146
  | `align` | `String` | `center` | Горизонталь: `'left'`, `'center'`, `'right'`. |
169
147
  | `before` | `String` | `` | Иконка в начале: имя из SVG-спрайта или URL. См. [SwIcon](#swicon). |
170
148
  | `after` | `String` | `` | Иконка в конце (закрыть): имя из спрайта или URL. См. [SwIcon](#swicon). |
@@ -182,34 +160,83 @@ Default - Текст описания или модуль / модули
182
160
 
183
161
  ### Пример использования / Example Usage
184
162
 
185
- ```js
186
- // .js addons
187
- import { Alert, components } from "@studio-west/component-sw"
188
- import { h } from 'vue'
189
- Alert({
190
- message: 'Message',
191
- type: 'danger',
192
- duration: 10000,
193
- placement: 'bottom',
194
- align: 'right',
195
- before: 'https://cdn.jsdelivr.net/npm/@tabler/icons@3.19.0/icons/outline/bell.svg',
196
- footer: h(components.SwButton, { onClick: () => console.log('Клик по кнопке в футере') }, () => 'OK')
197
- })
163
+ ```html
164
+ <script setup>
165
+ import { Alert } from '@studio-west/component-sw'
198
166
 
199
- // Composition API / <script setup>:
200
- import { inject, h } from "vue"
201
- import { components } from "@studio-west/component-sw"
202
- const Alert = inject('Alert')
203
- Alert({
204
- message: 'Alarm!',
205
- type: 'warning',
206
- placement: 'top',
207
- align: 'center',
208
- suffix: h(components.SwIcon, { iconClass: 'https://cdn.jsdelivr.net/npm/@tabler/icons@3.19.0/icons/outline/info-circle.svg' })
209
- })
167
+ const TABLER = 'https://cdn.jsdelivr.net/npm/@tabler/icons@3.19.0/icons/outline'
168
+ const icons = {
169
+ star: `${TABLER}/star.svg`,
170
+ close: `${TABLER}/x.svg`
171
+ }
172
+
173
+ let alertSeq = 0
174
+
175
+ function showAlert(type, placement = 'top', align = 'center') {
176
+ alertSeq += 1
177
+ Alert({
178
+ message: `#${alertSeq} ${type} (${placement}/${align})`,
179
+ type,
180
+ placement,
181
+ align,
182
+ duration: 8000,
183
+ before: icons.star,
184
+ after: icons.close
185
+ })
186
+ }
187
+ </script>
188
+
189
+ <sw-button type="info" label="info" @click="showAlert('info')" />
190
+ <sw-button type="success" label="success" @click="showAlert('success')" />
191
+ <sw-button type="warning" label="warning" @click="showAlert('warning')" />
192
+ <sw-button type="danger" label="error" @click="showAlert('error')" />
193
+
194
+ <!-- позиция: повторный клик — стек -->
195
+ <sw-button
196
+ v-for="pos in [
197
+ { placement: 'top', align: 'left' },
198
+ { placement: 'top', align: 'center' },
199
+ { placement: 'bottom', align: 'right' }
200
+ ]"
201
+ :key="`${pos.placement}-${pos.align}`"
202
+ type="primary"
203
+ :label="`${pos.placement}/${pos.align}`"
204
+ @click="showAlert('info', pos.placement, pos.align)"
205
+ />
206
+ ```
207
+ ---
208
+
209
+ ## SwBadge
210
+
211
+ Индикатор поверх слота: число, текст или точка (`isDot`).
212
+
213
+ ### Свойства / Properties
214
+
215
+ | Имя | Тип | По умолчанию | Описание |
216
+ |-------------|-------------------|--------------|-----------------------------------|
217
+ | `value` | `Number`/`String` | `` | Значение на бейдже. |
218
+ | `max` | `Number` | `99` | При числе > max → `{max}+`. |
219
+ | `type` | `String` | `danger` | Цвет метки. |
220
+ | `isDot` | `Boolean` | `false` | Точка вместо текста. |
221
+ | `showZero` | `Boolean` | `false` | Показывать `0`. |
222
+ | `hidden` | `Boolean` | `false` | Скрыть метку. |
223
+ | `class` | `String` | `` | CSS-класс обёртки. |
224
+
225
+ ### Пример
210
226
 
211
- // Options API:
212
- this.$Alert({ message: 'Welcome!', type: 'success', prefix: 'Дополнительная информация' })
227
+ ```html
228
+ <sw-badge :value="3">
229
+ <sw-button type="primary" label="Сообщения" />
230
+ </sw-badge>
231
+ <sw-badge :value="120" :max="99" type="warning">
232
+ <sw-button label="Уведомления" />
233
+ </sw-badge>
234
+ <sw-badge is-dot type="danger">
235
+ <sw-button type="info" label="Точка" />
236
+ </sw-badge>
237
+ <sw-badge value="new" type="success">
238
+ <sw-button label="Текст" />
239
+ </sw-badge>
213
240
  ```
214
241
  ---
215
242
 
@@ -230,10 +257,10 @@ this.$Alert({ message: 'Welcome!', type: 'success', prefix: 'Дополните
230
257
  | `href` | `String` | `` | URL, на который будет перенаправлен пользователь при клике (если `link=true`). |
231
258
  | `disabled` | `Boolean` | `false` | Блокирует кнопку, делая её неактивной. |
232
259
  | `label` | `String` | `` | Текст кнопки (альтернатива содержимому слота). |
233
- | `before` | `String` | `` | Иконка перед текстом: имя из SVG-спрайта или URL (`https://…`). См. [SwIcon](#swicon). |
260
+ | `before` | `String` | `` | Иконка перед текстом: имя из SVG-спрайта или URL. См. [SwIcon](#swicon). |
234
261
  | `after` | `String` | `` | Иконка после текста: имя из спрайта или URL. См. [SwIcon](#swicon). |
235
- | `prefix` | `String` | `` | **Deprecated** (удалить в major) — используйте `before`. |
236
- | `postfix` | `String` | `` | **Deprecated** (удалить в major) — используйте `after`. |
262
+ | `prefix` | `String` | `` | **Deprecated** (удалю в major) — используйте `before`. |
263
+ | `postfix` | `String` | `` | **Deprecated** (удалю в major) — используйте `after`. |
237
264
 
238
265
  ### Слоты / Slots
239
266
 
@@ -241,42 +268,32 @@ Default - содержимое кнопки (текст, иконки или д
241
268
 
242
269
  ### Пример использования / Example Usage
243
270
 
244
- #### Базовый пример:
245
-
246
271
  ```html
247
- <sw-button
248
- class="custom-class"
249
- size="large"
250
- type="primary"
251
- round
252
- text
253
- link
254
- href="https://example.com"
255
- >
256
- Нажми меня / Click Me
257
- </sw-button>
258
- ```
259
-
260
- #### С иконками и label:
272
+ <script setup>
273
+ const TABLER = 'https://cdn.jsdelivr.net/npm/@tabler/icons@3.19.0/icons/outline'
274
+ const icons = {
275
+ floppy: `${TABLER}/device-floppy.svg`,
276
+ arrow: `${TABLER}/arrow-right.svg`,
277
+ star: `${TABLER}/star.svg`,
278
+ chevron: `${TABLER}/chevron-down.svg`,
279
+ search: `${TABLER}/search.svg`
280
+ }
281
+ </script>
261
282
 
262
- ```html
283
+ <sw-button type="primary" label="Primary" />
284
+ <sw-button type="success" label="Success" />
285
+ <sw-button size="small" type="primary" label="Small" />
286
+ <sw-button type="primary" round label="Round" />
287
+ <sw-button type="primary" text label="Text" />
288
+ <sw-button type="primary" link label="Link" />
289
+ <sw-button type="primary" disabled label="Disabled" />
263
290
  <sw-button
264
- label="Сохранить"
265
- before="https://cdn.jsdelivr.net/npm/@tabler/icons@3.19.0/icons/outline/device-floppy.svg"
266
- after="https://cdn.jsdelivr.net/npm/@tabler/icons@3.19.0/icons/outline/arrow-right.svg"
267
291
  type="success"
292
+ label="Сохранить"
293
+ :before="icons.floppy"
294
+ :after="icons.arrow"
268
295
  />
269
- ```
270
-
271
- #### Отключенная кнопка:
272
-
273
- ```html
274
- <sw-button
275
- disabled="true"
276
- type="primary"
277
- >
278
- Недоступно
279
- </sw-button>
296
+ <sw-button type="warning" :before="icons.search">Слот</sw-button>
280
297
  ```
281
298
  ---
282
299
 
@@ -306,16 +323,15 @@ model - индекс активной кнопки.
306
323
  ### Пример использования / Example Usage
307
324
 
308
325
  ```html
309
- <script>let active = 0 </script>
310
- <sw-button-group
311
- class="custom-class"
312
- radio
313
- v-model="active"
314
- vertical
315
- >
316
- <sw-button type="primary" size="small">Нажми меня 1 / Click Me 1</sw-button>
317
- <sw-button type="primary" >Нажми меня 2 / Click Me 2</sw-button>
318
- <sw-button type="danger">Нажми меня 3 / Click Me 3</sw-button>
326
+ <script setup>
327
+ import { ref } from 'vue'
328
+ const buttonGroupActive = ref(0)
329
+ </script>
330
+
331
+ <sw-button-group radio v-model="buttonGroupActive">
332
+ <sw-button type="primary" size="small">Один</sw-button>
333
+ <sw-button type="primary">Два</sw-button>
334
+ <sw-button type="danger">Три</sw-button>
319
335
  </sw-button-group>
320
336
  ```
321
337
  ---
@@ -337,7 +353,6 @@ Default - Контент для скрытия
337
353
  ### Особенности реализации
338
354
 
339
355
  - Плавная анимация открытия/закрытия с использованием CSS transitions
340
- - Автоматический расчет высоты контента через ResizeObserver
341
356
  - Адаптивное изменение размеров при динамическом контенте
342
357
 
343
358
  ### Пример использования / Example Usage
@@ -345,14 +360,14 @@ Default - Контент для скрытия
345
360
  ```html
346
361
  <script setup>
347
362
  import { ref } from 'vue'
348
-
349
- const open = ref(true)
363
+ const collapseOpen = ref(true)
350
364
  </script>
351
365
 
352
- <sw-button label="Показать / скрыть" type="primary" @click="open = !open" />
353
-
354
- <sw-collapse :visual="open">
355
- <p>Скрываемый контент / Collapsible content</p>
366
+ <sw-button size="small" @click="collapseOpen = !collapseOpen">
367
+ {{ collapseOpen ? 'Свернуть' : 'Развернуть' }}
368
+ </sw-button>
369
+ <sw-collapse :visual="collapseOpen">
370
+ <p>Скрываемый контент коллапса.</p>
356
371
  </sw-collapse>
357
372
  ```
358
373
  ---
@@ -371,7 +386,7 @@ const open = ref(true)
371
386
 
372
387
  ### События / Events
373
388
 
374
- input - событие выбора с данными {dateStart: "11.11.2011", dateEnd: "14-12-2011" ( при range), count: 1 }
389
+ input — событие выбора: `{ dateStart: "11.11.2011", dateEnd: "14.12.2011" /* при range */, count: 1 }` (формат `DD.MM.YYYY`)
375
390
 
376
391
  ### Слоты / Slots
377
392
 
@@ -437,11 +452,9 @@ const datePickerLimitation = ref([
437
452
 
438
453
  ## SwDropdown
439
454
 
440
- Компонент `SwDropdown` — всплывающее меню с настройкой места открытия и типа триггера. У попапа есть **уголок**, который указывает на триггер; сторона и смещение считаются по фактической позиции (с учётом flip у края экрана). `z-index` попапа = z-index ближайшего предка + 3 (`Teleport` в `body`). Клавиатура: **Escape** закрывает, **↑/↓** по пунктам, **Enter** / **Space** выбирает.
455
+ Компонент `SwDropdown` — всплывающее меню с настройкой места открытия и типа триггера. У попапа есть **уголок**, который указывает на триггер; сторона и смещение считаются по фактической позиции (с учётом flip у края экрана). `z-index` попапа динамический = z-index ближайшего предка + 3. Клавиатура: **Escape** закрывает, **↑/↓** по пунктам, **Enter** / **Space** выбирает.
441
456
 
442
- **Tooltip:** отдельный `SwTooltip` не нужен. Тот же компонент с `trigger="hover"` и текстом/разметкой в `#dropdown` работает как подсказка (без `SwDropdownItem`, если это не меню).
443
-
444
- The `SwDropdown` popup shows a caret pointing at the trigger; side/offset follow the real placement after edge flip. Keyboard: Escape, Arrow keys, Enter/Space. Use `trigger="hover"` as a tooltip — no separate Tooltip component.
457
+ Компонент с `trigger="hover"` и текстом/разметкой в `#dropdown` работает как подсказка **Tooltip** (без `SwDropdownItem`, если это не меню).
445
458
 
446
459
  ### Свойства / Properties
447
460
 
@@ -469,10 +482,22 @@ model - состояние меню, булевое значение откры
469
482
  Меню:
470
483
 
471
484
  ```html
472
- <sw-dropdown class="custom-class" placement="bottom" :max-width="250">
473
- <sw-button label="Меню" type="primary" />
485
+ <script setup>
486
+ import { ref } from 'vue'
487
+ const open = ref(false)
488
+ const TABLER = 'https://cdn.jsdelivr.net/npm/@tabler/icons@3.19.0/icons/outline'
489
+ const star = `${TABLER}/star.svg`
490
+ const chevron = `${TABLER}/chevron-down.svg`
491
+ </script>
492
+
493
+ <sw-dropdown v-model="open" trigger="click" placement="bottom-left">
494
+ <sw-button size="small">
495
+ Меню <sw-icon :icon-class="chevron" />
496
+ </sw-button>
474
497
  <template #dropdown>
475
- <sw-dropdown-item>содержание / context</sw-dropdown-item>
498
+ <sw-dropdown-item :before="star">Пункт со звездой</sw-dropdown-item>
499
+ <sw-dropdown-item>Обычный пункт</sw-dropdown-item>
500
+ <sw-dropdown-item type="danger">Опасный</sw-dropdown-item>
476
501
  </template>
477
502
  </sw-dropdown>
478
503
  ```
@@ -509,13 +534,16 @@ Default - текст названия или модуль
509
534
 
510
535
  ### Пример использования / Example Usage
511
536
 
537
+ См. [SwDropdown](#swdropdown). Кратко с иконкой:
538
+
512
539
  ```html
513
- <sw-dropdown class="custom-class" :max-width="250">
514
- <sw-button label="Меню" type="primary" />
515
- <template #dropdown>
516
- <sw-dropdown-item before="https://cdn.jsdelivr.net/npm/@tabler/icons@3.19.0/icons/outline/files.svg">содержание / context</sw-dropdown-item>
517
- </template>
518
- </sw-dropdown>
540
+ <script setup>
541
+ const star = 'https://cdn.jsdelivr.net/npm/@tabler/icons@3.19.0/icons/outline/star.svg'
542
+ </script>
543
+
544
+ <sw-dropdown-item :before="star">Пункт со звездой</sw-dropdown-item>
545
+ <sw-dropdown-item>Обычный пункт</sw-dropdown-item>
546
+ <sw-dropdown-item type="danger">Пункт внимание</sw-dropdown-item>
519
547
  ```
520
548
  ---
521
549
 
@@ -650,8 +678,6 @@ const documentFiles = ref([])
650
678
 
651
679
  Компонент `SwFormItem` — **подписи к полям формы** (не обёртка контрола): строка с подписью слева и текстом справа (подсказка / ошибка). Выравнивание через `justify`, цвет текста через `type`.
652
680
 
653
- `SwFormItem` is a **form caption row** (not a field wrapper): label on the left, hint/error on the right. Use `justify` for alignment and `type` for text color.
654
-
655
681
  ### Свойства / Properties
656
682
 
657
683
  | Имя | Тип | По умолчанию | Значения/Описание |
@@ -659,7 +685,7 @@ const documentFiles = ref([])
659
685
  | `label` | `String` | `` | Подпись слева. |
660
686
  | `type` | `String` | `` | Цвет текста: `'primary'`, `'success'`, `'info'`, `'warning'`, `'danger'` (`'error'` → `danger`). Без фонов кнопок. |
661
687
  | `justify` | `String` | `` | Выравнивание: `''` → `space-between`; `'start'`, `'end'`, `'around'`, `'center'`. |
662
- | `class` | `String` | `` | Дополнительный CSS-класс. |
688
+ | `class` | `String` | `` | Пользовательски CSS-класс корня модуля. |
663
689
 
664
690
  ### Слоты / Slots
665
691
 
@@ -672,46 +698,28 @@ Default — текст справа (подсказка / ошибка)
672
698
  ### Пример использования / Example Usage
673
699
 
674
700
  ```html
675
- <sw-form-item label="Пароль" type="danger">слишком короткий</sw-form-item>
676
- <sw-input v-model="pass" name="pass" label="Пароль" />
677
-
678
- <sw-form-item justify="start" type="info">Подсказка под полем</sw-form-item>
679
- ```
680
- ---
681
-
682
- ## SwIcon
683
-
684
- Компонент `SwIcon` отображает SVG-иконку из встроенного спрайта или по-внешнему URL.
685
-
686
- Если `iconClass` начинается с `http://`, `https://`, иконка загружается как внешний SVG через CSS `mask` (класс `sw-external-icon`). Иначе используется символ из спрайта: `#prefix-iconClass`.
687
-
688
- Компонент используется внутри SwButton, SwInput, SwAlert, SwDropdownItem, SwSection, SwMessage, SwGide (`before` / `after`) — во всех этих props можно передавать как имя из спрайта, так и полный URL. Старые имена (`prefix`/`postfix`, `iconBefore`, `iconAfter`, `iconClose`) пока работают, будут удалены в major.
689
-
690
- ### Свойства / Properties
691
-
692
- | Имя | Тип | По умолчанию | Значения/Описание |
693
- |-------------|----------|--------------|-------------------------------------------------|
694
- | `iconClass` | `String` | `required` | Имя иконки в спрайте или URL (`https://…`). |
695
- | `prefix` | `String` | `icon` | Префикс символа в спрайте: `#prefix-iconClass`. |
696
- | `className` | `String` | `` | Дополнительный CSS-класс для элемента `<svg>`. |
697
-
698
- ### Пример использования / Example Usage
699
-
700
- ```html
701
- <!-- из спрайта -->
702
- <sw-icon icon-class="star" />
701
+ <script setup>
702
+ import { ref } from 'vue'
703
+ const formPlain = ref('')
704
+ const formOk = ref('ok')
705
+ const formBad = ref('')
706
+ </script>
703
707
 
704
- <!-- внешний URL (Tabler Icons) -->
705
- <sw-icon icon-class="https://cdn.jsdelivr.net/npm/@tabler/icons@3.19.0/icons/outline/star.svg" />
708
+ <sw-form-item label="Имя">
709
+ <sw-input v-model="formPlain" name="form-plain" label="Имя" />необязательно
710
+ </sw-form-item>
711
+ <sw-form-item label="Email" type="success">
712
+ <sw-input v-model="formOk" name="form-ok" label="Email" />ок
713
+ </sw-form-item>
714
+ <sw-form-item label="Пароль" justify="center" type="danger">
715
+ <sw-input v-model="formBad" name="form-bad" label="Пароль" />слишком короткий
716
+ </sw-form-item>
706
717
  ```
707
-
708
718
  ---
709
719
 
710
720
  ## SwGide
711
721
 
712
- Компонент `SwGide` создаёт затемнение вокруг блока по селектору и показывает [SwDropdown](#swdropdown) с шагами из `steps`. `z-index` гида динамический: выше контента страницы (в т.ч. тултипов слайдера), ниже алертов (`9999`).
713
-
714
- `SwGide` dims the page around a selector and shows a [SwDropdown](#swdropdown) for `steps`. Overlay `z-index` is dynamic: above page content, below alerts (`9999`).
722
+ Компонент `SwGide` создаёт затемнение вокруг блока по селектору и показывает [SwDropdown](#swdropdown) с шагами из `steps`. `z-index` гида динамический: выше контента страницы (в т.ч. тултипов слайдера), ниже алертов.
715
723
 
716
724
  ### Свойства / Properties
717
725
 
@@ -739,27 +747,63 @@ model - массив обьектов шагов обучения
739
747
  ```html
740
748
  <script setup>
741
749
  import { ref } from 'vue'
750
+ const gideOn = ref(false)
751
+ const gideStep = ref(0)
752
+ const close = 'https://cdn.jsdelivr.net/npm/@tabler/icons@3.19.0/icons/outline/x.svg'
753
+ const gideSteps = [
754
+ { header: 'Dropdown', text: 'Клик открывает список пунктов.', tag: '#gide-demo', placement: 'bottom' },
755
+ { header: 'Календарь', text: 'Ниже на странице — SwDatePicker.', tag: '#sw-datepicker', placement: 'bottom' }
756
+ ]
757
+ </script>
742
758
 
743
- const settings = ref({ gide: true })
744
- const step = ref(0)
745
- const steps = ref([
746
- {header: 'заголовок',
747
- text: 'текст сообщения',
748
- tag: 'nav',
749
- placement: 'bottom',
750
- img: 'assets/teme_sw/images/sw.png'
751
- }
752
- ])
759
+ <sw-button type="primary" size="small" @click="gideStep = 0; gideOn = true">Запустить гид</sw-button>
760
+ <sw-gide
761
+ v-if="gideOn"
762
+ v-model="gideStep"
763
+ :steps="gideSteps"
764
+ :after="close"
765
+ @close="gideOn = false"
766
+ />
767
+ ```
768
+ ---
769
+
770
+ ## SwIcon
771
+
772
+ Компонент `SwIcon` отображает SVG-иконку из встроенного спрайта или по-внешнему URL.
773
+
774
+ Если `iconClass` начинается с `http://`, `https://`, иконка загружается как внешний SVG через CSS `mask` (класс `sw-external-icon`). Иначе используется символ из спрайта: `#prefix-iconClass`.
775
+
776
+ Компонент используется внутри библиотеки, и во многих компонентов в props можно передавать как имя из спрайта, так и полный URL.
777
+
778
+ ### Свойства / Properties
779
+
780
+ | Имя | Тип | По умолчанию | Значения/Описание |
781
+ |-------------|----------|--------------|-------------------------------------------------|
782
+ | `iconClass` | `String` | `required` | Имя иконки в спрайте или URL (`https://…`). |
783
+ | `prefix` | `String` | `icon` | Префикс символа в спрайте: `#prefix-iconClass`. |
784
+ | `className` | `String` | `` | Пользовательский CSS-класс для элемента `<svg>`. |
785
+
786
+ ### Пример использования / Example Usage
787
+
788
+ ```html
789
+ <script setup>
790
+ const TABLER = 'https://cdn.jsdelivr.net/npm/@tabler/icons@3.19.0/icons/outline'
791
+ const icons = {
792
+ star: `${TABLER}/star.svg`,
793
+ search: `${TABLER}/search.svg`,
794
+ phone: `${TABLER}/phone.svg`,
795
+ chevron: `${TABLER}/chevron-down.svg`
796
+ }
753
797
  </script>
754
- <sw-gide v-if="settings.gide" :steps="steps" v-model="step" @close="settings.gide=false" after="https://cdn.jsdelivr.net/npm/@tabler/icons@3.19.0/icons/outline/x.svg">
755
- <template #header>
756
- Блок {{ steps[step].header }}
757
- <sw-button type="primary" link @click="settings.gide=false"><sw-icon icon-class="https://cdn.jsdelivr.net/npm/@tabler/icons@3.19.0/icons/outline/x.svg" /></sw-button>
758
- </template>
759
- <template #arrow><sw-icon icon-class="https://cdn.jsdelivr.net/npm/@tabler/icons@3.19.0/icons/outline/chevron-left.svg" /></template>
760
- </sw-gide>
798
+
799
+ <sw-icon :icon-class="icons.star" />
800
+ <sw-icon :icon-class="icons.search" />
801
+ <sw-icon :icon-class="icons.phone" />
802
+ <sw-icon :icon-class="icons.chevron" />
761
803
  ```
804
+
762
805
  ---
806
+
763
807
  ## SwInput
764
808
 
765
809
  Компонент `SwInput` представляет собой поле ввода с возможностью настройки внешнего вида и поведения.
@@ -809,23 +853,15 @@ clear - очистка через `clearable`
809
853
  ```html
810
854
  <script setup>
811
855
  import { ref } from 'vue'
812
-
813
- const model = ref('')
856
+ const inputSmall = ref('')
857
+ const inputPassword = ref('')
858
+ const inputTextarea = ref('')
859
+ const phone = 'https://cdn.jsdelivr.net/npm/@tabler/icons@3.19.0/icons/outline/phone.svg'
814
860
  </script>
815
861
 
816
- <sw-input
817
- v-model="model"
818
- name="input"
819
- class="custom-class"
820
- size="large"
821
- type="phone"
822
- before="https://cdn.jsdelivr.net/npm/@tabler/icons@3.19.0/icons/outline/phone.svg"
823
- placeholder="Your phone"
824
- label="Телефон"
825
- @prefix="console.log('before')"
826
- >
827
- <template #suffix>#</template>
828
- </sw-input>
862
+ <sw-input v-model="inputSmall" name="input-small" size="small" :before="phone" label="Small" clearable />
863
+ <sw-input v-model="inputPassword" name="input-password" type="password" label="Password" clearable />
864
+ <sw-input v-model="inputTextarea" name="input-textarea" type="textarea" label="Комментарий" :rows="4" clearable />
829
865
  ```
830
866
  ---
831
867
 
@@ -939,204 +975,18 @@ change - событие изменения значения компонента
939
975
 
940
976
  ### Пример использования / Example Usage
941
977
 
942
- #### Базовый пример с объектом:
943
-
944
- ```html
945
- <script setup>
946
- import { ref } from 'vue'
947
-
948
- const menuState = ref([false, false])
949
-
950
- const menuConfig = {
951
- 'SwButton': {
952
- label: 'Нажми меня',
953
- type: 'primary',
954
- before: 'https://cdn.jsdelivr.net/npm/@tabler/icons@3.19.0/icons/outline/star.svg'
955
- },
956
- 'SwSwitch': [
957
- {
958
- label: 'Уведомления',
959
- on: 'Вкл',
960
- off: 'Выкл'
961
- },
962
- {
963
- label: 'Звук',
964
- checkbox: true
965
- }
966
- ]
967
- }
968
-
969
- const handleClick = (data) => {
970
- console.log('Clicked:', data)
971
- }
972
-
973
- const handleChange = (data) => {
974
- console.log('Changed:', data)
975
- }
976
- </script>
977
-
978
- <style>
979
- .demo-menu {
980
- display: flex;
981
- flex-wrap: wrap;
982
- gap: 12px;
983
- align-items: center;
984
- padding: 12px;
985
- }
986
- </style>
987
-
988
- <sw-menu
989
- class="demo-menu"
990
- :menu-items="menuConfig"
991
- v-model="menuState"
992
- @click="handleClick"
993
- @change="handleChange"
994
- />
995
- ```
996
-
997
- #### Пример с массивом:
998
-
999
978
  ```html
1000
979
  <script setup>
1001
980
  import { ref } from 'vue'
1002
-
981
+ const menuModel = ref([])
1003
982
  const menuItems = [
1004
- {
1005
- 'SwButton': {
1006
- label: 'Главная',
1007
- type: 'info',
1008
- link: true,
1009
- href: '/'
1010
- }
1011
- },
1012
- {
1013
- 'SwButton': {
1014
- label: 'О нас',
1015
- type: 'info',
1016
- link: true,
1017
- href: '/about'
1018
- }
1019
- },
1020
- {
1021
- 'SwInput': {
1022
- name: 'search',
1023
- placeholder: 'Поиск...',
1024
- before: 'https://cdn.jsdelivr.net/npm/@tabler/icons@3.19.0/icons/outline/search.svg',
1025
- size: 'small'
1026
- }
1027
- }
983
+ { SwButton: { type: 'primary', size: 'small', slot: 'Пункт 1' } },
984
+ { SwButton: { size: 'small', slot: 'Пункт 2' } },
985
+ { SwSwitch: { id: 'menu-sw', name: 'menu-sw', on: 'On', off: 'Off' } }
1028
986
  ]
1029
987
  </script>
1030
988
 
1031
- <style>
1032
- .demo-menu {
1033
- display: flex;
1034
- flex-wrap: wrap;
1035
- gap: 12px;
1036
- align-items: center;
1037
- padding: 12px;
1038
- }
1039
- </style>
1040
-
1041
- <sw-menu
1042
- class="demo-menu"
1043
- :menu-items="menuItems"
1044
- />
1045
- ```
1046
-
1047
- #### Пример с вложенными компонентами:
1048
-
1049
- ```html
1050
- <script setup>
1051
- import { ref } from 'vue'
1052
-
1053
- const dropdownMenu = {
1054
- 'SwDropdown': {
1055
- trigger: 'hover',
1056
- placement: 'bottom-left',
1057
- slot: {
1058
- 'SwButton': {
1059
- label: 'Меню',
1060
- type: 'primary',
1061
- after: 'https://cdn.jsdelivr.net/npm/@tabler/icons@3.19.0/icons/outline/chevron-down.svg'
1062
- }
1063
- },
1064
- 'slot.dropdown': [
1065
- {
1066
- 'SwDropdownItem': {
1067
- before: 'https://cdn.jsdelivr.net/npm/@tabler/icons@3.19.0/icons/outline/user.svg',
1068
- slot: 'Профиль'
1069
- }
1070
- },
1071
- {
1072
- 'SwDropdownItem': {
1073
- before: 'https://cdn.jsdelivr.net/npm/@tabler/icons@3.19.0/icons/outline/settings.svg',
1074
- slot: 'Настройки'
1075
- }
1076
- }
1077
- ]
1078
- }
1079
- }
1080
- </script>
1081
-
1082
- <style>
1083
- .demo-menu {
1084
- display: flex;
1085
- flex-wrap: wrap;
1086
- gap: 12px;
1087
- align-items: center;
1088
- padding: 12px;
1089
- }
1090
- </style>
1091
-
1092
- <sw-menu class="demo-menu" :menu-items="dropdownMenu" />
1093
- ```
1094
-
1095
- #### Пример с использованием слотов:
1096
-
1097
- ```html
1098
- <script setup>
1099
- import { h } from 'vue'
1100
- import { components } from '@studio-west/component-sw'
1101
-
1102
- const complexMenu = {
1103
- 'SwSection': {
1104
- name: 'Панель управления',
1105
- after: 'https://cdn.jsdelivr.net/npm/@tabler/icons@3.19.0/icons/outline/chevron-down.svg',
1106
- slot: 'Основное содержимое секции',
1107
- 'slot.footer': {
1108
- 'SwButtonGroup': {
1109
- radio: true,
1110
- slot: [
1111
- {
1112
- 'SwButton': {
1113
- label: 'Опция 1',
1114
- type: 'primary'
1115
- }
1116
- },
1117
- {
1118
- 'SwButton': {
1119
- label: 'Опция 2'
1120
- }
1121
- }
1122
- ]
1123
- }
1124
- }
1125
- }
1126
- }
1127
- </script>
1128
-
1129
- <style>
1130
- .demo-menu {
1131
- display: flex;
1132
- flex-wrap: wrap;
1133
- gap: 12px;
1134
- align-items: center;
1135
- padding: 12px;
1136
- }
1137
- </style>
1138
-
1139
- <sw-menu class="demo-menu" :menu-items="complexMenu" />
989
+ <sw-menu v-model="menuModel" :menu-items="menuItems" @click="console.log" />
1140
990
  ```
1141
991
  ---
1142
992
 
@@ -1170,29 +1020,74 @@ model - состояние компонента булевое значение,
1170
1020
  ### Пример использования / Example Usage
1171
1021
 
1172
1022
  ```html
1173
- <script>let model = false</script>
1174
-
1175
- <sw-button label="Показать сообщение" type="primary" @click="model = true" />
1023
+ <script setup>
1024
+ import { ref } from 'vue'
1025
+ const messageOpen = ref(false)
1026
+ const close = 'https://cdn.jsdelivr.net/npm/@tabler/icons@3.19.0/icons/outline/x.svg'
1027
+ </script>
1176
1028
 
1177
- <sw-message
1178
- v-model="model"
1179
- name="Message"
1180
- class="custom-class"
1181
- after="https://cdn.jsdelivr.net/npm/@tabler/icons@3.19.0/icons/outline/x.svg"
1182
- >
1183
- <p>Описание / Description</p>
1029
+ <sw-button type="primary" label="Открыть сообщение" @click="messageOpen = true" />
1030
+ <sw-message v-model="messageOpen" name="Сообщение" :after="close">
1031
+ Текст диалога. Клик снаружи закрывает окно.
1032
+ <template #footer>
1033
+ <sw-button type="primary" size="small" @click="messageOpen = false">OK</sw-button>
1034
+ </template>
1184
1035
  </sw-message>
1185
1036
  ```
1186
1037
  ---
1187
1038
 
1188
- ## SwSection
1039
+ ## SwPagination
1189
1040
 
1190
- Компонент `SwSection` это тег section с шаблоном из слотов, по умолчанию в слот #header добавлено заголовок и иконка.
1041
+ Постраничная навигация. `v-model` — текущая страница (с 1).
1191
1042
 
1192
1043
  ### Свойства / Properties
1193
1044
 
1194
- | Имя | Тип | По умолчанию | Значения/Описание |
1195
- |-------------|-----------|--------------|---------------------------------------------------------------------|
1045
+ | Имя | Тип | По умолчанию | Описание |
1046
+ |---------------|-----------|--------------|----------------------------------|
1047
+ | `total` | `Number` | `0` | Всего элементов. |
1048
+ | `pageSize` | `Number` | `10` | Элементов на странице (`v-model:page-size`). |
1049
+ | `pageSizes` | `Number[]` | `[10, 20, 50, 100]` | Варианты в селекте размера. |
1050
+ | `showSize` | `Boolean` | `true` | Показать выбор «N / стр.». |
1051
+ | `pagerCount` | `Number` | `7` | Число кнопок страниц (нечётное). |
1052
+ | `size` | `String` | `` | `small` / `large`. |
1053
+ | `showTotal` | `Boolean` | `false` | Текст «Всего N». |
1054
+ | `disabled` | `Boolean` | `false` | Блок неактивен. |
1055
+ | `class` | `String` | `` | CSS-класс. |
1056
+
1057
+ ### Модель / Events
1058
+
1059
+ - `v-model` / `modelValue` — номер страницы
1060
+ - `v-model:page-size` — размер страницы
1061
+ - `change` — новая страница
1062
+ - `size-change` — новый размер страницы
1063
+
1064
+ ### Пример
1065
+
1066
+ ```html
1067
+ <script setup>
1068
+ import { ref } from 'vue'
1069
+ const page = ref(1)
1070
+ const pageSize = ref(10)
1071
+ </script>
1072
+
1073
+ <sw-pagination
1074
+ v-model="page"
1075
+ v-model:page-size="pageSize"
1076
+ :total="240"
1077
+ :page-sizes="[10, 20, 50, 100]"
1078
+ show-total
1079
+ />
1080
+ ```
1081
+ ---
1082
+
1083
+ ## SwSection
1084
+
1085
+ Компонент `SwSection` это тег section с шаблоном из слотов, по умолчанию в слот #header добавлено заголовок и иконка.
1086
+
1087
+ ### Свойства / Properties
1088
+
1089
+ | Имя | Тип | По умолчанию | Значения/Описание |
1090
+ |-------------|-----------|--------------|---------------------------------------------------------------------|
1196
1091
  | `name` | `String` | `` | Добавляет заголовок в секцию. |
1197
1092
  | `class` | `String` | `sw-section` | Добавляет пользовательский CSS-класс к компоненту. |
1198
1093
  | `after` | `String` | `` | Иконка в заголовке: имя из спрайта или URL. См. [SwIcon](#swicon). |
@@ -1213,14 +1108,14 @@ header - клик по всему Header
1213
1108
  ### Пример использования / Example Usage
1214
1109
 
1215
1110
  ```html
1216
- <sw-section
1217
- name="section"
1218
- class="custom-class"
1219
- after="https://cdn.jsdelivr.net/npm/@tabler/icons@3.19.0/icons/outline/x.svg"
1220
- >
1221
- <p>Содержимое / Content</p>
1111
+ <script setup>
1112
+ const chevron = 'https://cdn.jsdelivr.net/npm/@tabler/icons@3.19.0/icons/outline/chevron-down.svg'
1113
+ </script>
1114
+
1115
+ <sw-section name="Заголовок секции" :after="chevron" @header="console.log('section header')">
1116
+ <p>Контент секции. Клик по шапке эмитит header.</p>
1222
1117
  <template #footer>
1223
- <p>Footer!</p>
1118
+ <sw-button size="small" type="primary">В футере</sw-button>
1224
1119
  </template>
1225
1120
  </sw-section>
1226
1121
  ```
@@ -1248,17 +1143,10 @@ model - текст ввода или выбора из списка
1248
1143
  ```html
1249
1144
  <script setup>
1250
1145
  import { ref } from 'vue'
1251
-
1252
- const model = ref({ text: '', coords: [0, 0] })
1253
- const token = ref('') // API-ключ DADATA
1146
+ const selectGeo = ref({ text: '', coords: [0, 0], suggestion: null })
1254
1147
  </script>
1255
1148
 
1256
- <sw-select
1257
- v-model="model"
1258
- class="custom-class"
1259
- placeholder="Введите адрес"
1260
- :token="token"
1261
- />
1149
+ <sw-select v-model="selectGeo" placeholder="Город, улица, дом" size="small" />
1262
1150
  ```
1263
1151
  ---
1264
1152
 
@@ -1283,10 +1171,21 @@ Default - Содержимое
1283
1171
  ### Пример использования / Example Usage
1284
1172
 
1285
1173
  ```html
1286
- <sw-skeleton
1287
- :visual="visual"
1288
- >
1289
- <p>Содержимое / Content</p>
1174
+ <script setup>
1175
+ import { ref } from 'vue'
1176
+ const skeletonReady = ref(false)
1177
+ </script>
1178
+
1179
+ <sw-button size="small" @click="skeletonReady = !skeletonReady">
1180
+ {{ skeletonReady ? 'Показать скелетон' : 'Показать контент' }}
1181
+ </sw-button>
1182
+ <sw-skeleton :visual="skeletonReady">
1183
+ <p>Загруженный контент.</p>
1184
+ <template #skeleton>
1185
+ <sw-skeleton-item animate width="80" />
1186
+ <sw-skeleton-item animate size="small" width="60" />
1187
+ <sw-skeleton-item animate width="40" />
1188
+ </template>
1290
1189
  </sw-skeleton>
1291
1190
  ```
1292
1191
  ---
@@ -1319,9 +1218,7 @@ Default - Содержимое
1319
1218
 
1320
1219
  ## SwSlider
1321
1220
 
1322
- Компонент `SwSlider` — слайдер с одним или несколькими ползунками: число → 1 бегунок, массив из n чисел → n бегунков. Значения в массиве **сортируются** при перетаскивании; тултип следует за тянущимся ползунком при перескоке. Без CSS-lag на `left`/`top` во время drag.
1323
-
1324
- `SwSlider` supports one value or an array of n thumbs. Array values are **sorted** while dragging; the value tooltip follows the active thumb across swaps.
1221
+ Компонент `SwSlider` — слайдер с одним или несколькими ползунками: число в v-model → 1 бегунок, массив из n чисел → n бегунков. Значения в массиве **сортируются** при перетаскивании; тултип следует за тянущимся ползунком при перескоке. Без CSS-lag на `left`/`top` во время drag.
1325
1222
 
1326
1223
  ### Свойства / Properties
1327
1224
 
@@ -1346,25 +1243,14 @@ Default - содержимое бегунка (`index`, `value` в слот-пр
1346
1243
  ### Пример использования / Example Usage
1347
1244
 
1348
1245
  ```html
1349
- <!-- один ползунок -->
1350
- <sw-slider v-model="value" :min="0" :max="100" show-value />
1351
-
1352
- <!-- несколько ползунков -->
1353
1246
  <script setup>
1354
1247
  import { ref } from 'vue'
1355
- const multi = ref([15, 35, 60, 85])
1248
+ const sliderValue = ref(40)
1249
+ const sliderMulti = ref([15, 35, 60, 85])
1356
1250
  </script>
1357
- <sw-slider
1358
- v-model="multi"
1359
- :min="0"
1360
- :max="100"
1361
- :step="1"
1362
- show-value
1363
- >
1364
- <template #default="{ value }">
1365
- <!-- опционально: иконка внутри бегунка -->
1366
- </template>
1367
- </sw-slider>
1251
+
1252
+ <sw-slider v-model="sliderValue" :min="0" :max="100" show-value />
1253
+ <sw-slider v-model="sliderMulti" :min="0" :max="100" show-value />
1368
1254
  ```
1369
1255
  ---
1370
1256
 
@@ -1395,16 +1281,14 @@ model - состояние чекбокса (checked ) булевое знач
1395
1281
  ### Пример использования / Example Usage
1396
1282
 
1397
1283
  ```html
1398
- <sw-switch
1399
- v-model="model"
1400
- name="switch"
1401
- class="custom-class"
1402
- id="switch"
1403
- on="on"
1404
- off="off"
1405
- >
1406
- <p>Описание / Description</p>
1407
- </sw-switch>
1284
+ <script setup>
1285
+ import { ref } from 'vue'
1286
+ const switchOn = ref(true)
1287
+ const switchCheck = ref(false)
1288
+ </script>
1289
+
1290
+ <sw-switch v-model="switchOn" id="sw-demo-1" name="sw-demo-1" on="Вкл" off="Выкл">С подписями</sw-switch>
1291
+ <sw-switch v-model="switchCheck" id="sw-demo-2" name="sw-demo-2" checkbox>checkbox</sw-switch>
1408
1292
  ```
1409
1293
  ---
1410
1294
 
@@ -1412,12 +1296,8 @@ model - состояние чекбокса (checked ) булевое знач
1412
1296
 
1413
1297
  Компонент `SwTable` — динамическая таблица с вложенными заголовками, объединением ячеек (`rowspan` / `colspan`), кастомизацией через слоты, подсветкой строк и столбцов при наведении, изменением ширины колонок и фиксацией крайних колонок при горизонтальном скролле.
1414
1298
 
1415
- The `SwTable` component is a dynamic table with nested headers, cell merging (`rowspan` / `colspan`), slot-based customization, row and column hover highlighting, column resizing, and sticky edge columns during horizontal scroll.
1416
-
1417
1299
  Колонки описываются дочерним компонентом `SwTableColumn`.
1418
1300
 
1419
- Columns are defined with the child `SwTableColumn` component.
1420
-
1421
1301
  ### Свойства SwTable / SwTable Properties
1422
1302
 
1423
1303
  | Имя | Тип | По умолчанию | Значения/Описание |
@@ -1444,9 +1324,7 @@ The `SwTable` component is a dynamic table with nested headers, cell merging (`r
1444
1324
  | `minWidth` | `String` \| `Number` | `48` | Минимальная ширина при ресайзе (px). |
1445
1325
  | `fixed` | `String` | — | `'left'` \| `'right'` — фиксация колонки при горизонтальном скролле. |
1446
1326
 
1447
- `SwTableColumn` без `prop` используется как групповой заголовок; внутри него задаются дочерние `SwTableColumn`.
1448
-
1449
- A `SwTableColumn` without `prop` is a group header; place child `SwTableColumn` components inside it.
1327
+ `SwTableColumn` без `prop` используется как групповой заголовок; внутри него задаются дочерние `SwTableColumn`.
1450
1328
 
1451
1329
  ### Подсветка при наведении / Hover highlight
1452
1330
 
@@ -1478,109 +1356,78 @@ The `SwTable` component is a dynamic table with nested headers, cell merging (`r
1478
1356
 
1479
1357
  ### Пример использования / Example Usage
1480
1358
 
1481
- #### Базовый пример с вложенными колонками:
1482
-
1483
- ```html
1484
- <script>
1485
- let table = [
1486
- {city:{label:'Moscow', rowspan:2},district:'Center',speed:{max:80,min:50,midl:70}},
1487
- {city:'Moscow',district:'MRCR',speed:{max:130,min:90,midl:120}},
1488
- ]
1489
- </script>
1490
-
1491
- <style>
1492
- .sw-table th, .sw-table td { border: 1px solid #d6d6d6; padding: 6px 10px; }
1493
- </style>
1494
-
1495
- <sw-table :data="table">
1496
- <sw-table-column label="Label">
1497
- <sw-table-column label="City" prop="city"/>
1498
- <sw-table-column label="District" prop="district"/>
1499
- </sw-table-column>
1500
- <sw-table-column label="Speed" prop="speed.midl"/>
1501
- </sw-table>
1502
- ```
1503
-
1504
- #### Ресайз колонок:
1359
+ #### Базовая таблица с ресайзом и слотами:
1505
1360
 
1506
1361
  ```html
1507
1362
  <script setup>
1508
- const users = [
1509
- { name: 'Иван', age: 25 },
1510
- { name: 'Мария', age: 30 },
1511
- { name: 'Петр', age: 35 }
1512
- ]
1513
-
1514
- function onColumnResize({ prop, width }) {
1515
- console.log(prop, width)
1363
+ import { ref } from 'vue'
1364
+ const users = ref([
1365
+ { name: 'Иван Петров', age: 25, status: 'active' },
1366
+ { name: 'Мария Сидорова', age: 30, status: 'inactive' },
1367
+ { name: 'Петр Иванов', age: 35, status: 'active' }
1368
+ ])
1369
+ function logRow(row) {
1370
+ console.log('row:', row)
1516
1371
  }
1517
1372
  </script>
1518
1373
 
1519
- <style>
1520
- .sw-table th, .sw-table td { border: 1px solid #d6d6d6; padding: 6px 10px; }
1521
- </style>
1522
-
1523
- <sw-table :data="users" @column-resize="onColumnResize">
1374
+ <sw-table :data="users" :resizable="true" @column-resize="console.log">
1524
1375
  <sw-table-column prop="name" label="Имя" width="180px" />
1525
1376
  <sw-table-column prop="age" label="Возраст" width="100px" />
1526
- <sw-table-column
1527
- prop="actions"
1528
- label="Действия"
1529
- width="150px"
1530
- :resizable="false"
1531
- />
1377
+ <sw-table-column prop="status" label="Статус" width="120px" />
1378
+ <sw-table-column prop="actions" label="Действия" width="150px" :resizable="false" />
1379
+
1380
+ <template #name="{ value }">
1381
+ <strong>{{ value }}</strong>
1382
+ </template>
1383
+ <template #status="{ value }">
1384
+ {{ value === 'active' ? 'Активен' : 'Неактивен' }}
1385
+ </template>
1386
+ <template #actions="{ row }">
1387
+ <sw-button type="info" size="small" text @click="logRow(row)">...</sw-button>
1388
+ </template>
1532
1389
  </sw-table>
1533
1390
  ```
1534
1391
 
1535
- #### Фиксированные крайние колонки:
1392
+ #### Вложенные заголовки:
1536
1393
 
1537
1394
  ```html
1538
1395
  <script setup>
1539
- const rows = [
1540
- { id: 1, name: 'Иван', email: 'ivan@example.com', note: 'Примечание 1' },
1541
- { id: 2, name: 'Мария', email: 'maria@example.com', note: 'Примечание 2' },
1542
- { id: 3, name: 'Петр', email: 'petr@example.com', note: 'Примечание 3' }
1543
- ]
1396
+ import { ref } from 'vue'
1397
+ const nestedData = ref([
1398
+ { city: 'Москва', district: 'Центр', speed: 70 },
1399
+ { city: 'Санкт-Петербург', district: 'Невский', speed: 60 }
1400
+ ])
1544
1401
  </script>
1545
1402
 
1546
- <style>
1547
- .sw-table th, .sw-table td { border: 1px solid #d6d6d6; padding: 6px 10px; }
1548
- </style>
1549
-
1550
- <sw-table :data="rows" max-width="520px">
1551
- <sw-table-column prop="id" label="ID" width="70px" fixed="left" />
1552
- <sw-table-column prop="name" label="Имя" width="160px" fixed="left" />
1553
- <sw-table-column prop="email" label="Email" width="200px" />
1554
- <sw-table-column prop="note" label="Примечание" width="180px" fixed="right" />
1403
+ <sw-table :data="nestedData">
1404
+ <sw-table-column label="Адрес">
1405
+ <sw-table-column prop="city" label="Город" width="140px" />
1406
+ <sw-table-column prop="district" label="Район" width="120px" />
1407
+ </sw-table-column>
1408
+ <sw-table-column prop="speed" label="Скорость" width="100px" />
1555
1409
  </sw-table>
1556
1410
  ```
1557
1411
 
1558
- #### Пример с v-for для динамических колонок:
1412
+ #### Динамические колонки (v-for):
1559
1413
 
1560
1414
  ```html
1561
1415
  <script setup>
1562
1416
  import { ref } from 'vue'
1563
-
1564
- const columns = ref([
1565
- { prop: 'name', label: 'Имя', width: '150px' },
1566
- { prop: 'age', label: 'Возраст', width: '100px' },
1567
- { prop: 'email', label: 'Email', width: '200px' }
1417
+ const productColumns = ref([
1418
+ { prop: 'name', label: 'Название', width: '200px' },
1419
+ { prop: 'price', label: 'Цена', width: '100px' },
1420
+ { prop: 'quantity', label: 'Кол-во', width: '90px' }
1568
1421
  ])
1569
-
1570
- const tableData = ref([
1571
- { name: 'Иван', age: 25, email: 'ivan@example.com' },
1572
- { name: 'Мария', age: 30, email: 'maria@example.com' },
1573
- { name: 'Петр', age: 35, email: 'petr@example.com' }
1422
+ const products = ref([
1423
+ { name: 'Товар 1', price: 1000, quantity: 5 },
1424
+ { name: 'Товар 2', price: 2500, quantity: 3 }
1574
1425
  ])
1575
1426
  </script>
1576
1427
 
1577
- <style>
1578
- .sw-table th, .sw-table td { border: 1px solid #d6d6d6; padding: 6px 10px; }
1579
- </style>
1580
-
1581
- <sw-table :data="tableData">
1582
- <sw-table-column
1583
- v-for="column in columns"
1428
+ <sw-table :data="products">
1429
+ <sw-table-column
1430
+ v-for="column in productColumns"
1584
1431
  :key="column.prop"
1585
1432
  :prop="column.prop"
1586
1433
  :label="column.label"
@@ -1589,122 +1436,51 @@ const tableData = ref([
1589
1436
  </sw-table>
1590
1437
  ```
1591
1438
 
1592
- #### Пример с кастомизацией через слоты:
1439
+ #### Фиксированные крайние колонки:
1593
1440
 
1594
1441
  ```html
1595
1442
  <script setup>
1596
1443
  import { ref } from 'vue'
1597
-
1598
- const users = ref([
1599
- { id: 1, name: 'Иван Петров', age: 25, status: 'active', email: 'ivan@example.com' },
1600
- { id: 2, name: 'Мария Сидорова', age: 30, status: 'inactive', email: 'maria@example.com' },
1601
- { id: 3, name: 'Петр Иванов', age: 35, status: 'active', email: 'petr@example.com' }
1444
+ const wideColumns = ref([
1445
+ { prop: 'dept', label: 'Отдел', width: '140px' },
1446
+ { prop: 'email', label: 'Email', width: '200px' }
1602
1447
  ])
1603
-
1604
- const deleteUser = (id) => {
1605
- console.log('Delete user:', id)
1606
- }
1607
- </script>
1608
-
1609
- <style>
1610
- .sw-table th, .sw-table td { border: 1px solid #d6d6d6; padding: 6px 10px; }
1611
- </style>
1612
-
1613
- <sw-table :data="users">
1614
- <sw-table-column prop="name" label="Имя" />
1615
- <sw-table-column prop="age" label="Возраст" />
1616
- <sw-table-column prop="status" label="Статус" />
1617
- <sw-table-column prop="actions" label="Действия" width="150px" />
1618
-
1619
- <!-- Именованный слот для конкретной колонки -->
1620
- <template #name="{ row, value }">
1621
- <strong>{{ value }}</strong>
1622
- </template>
1623
-
1624
- <template #age="{ value }">
1625
- <span style="color: blue">{{ value }} лет</span>
1626
- </template>
1627
-
1628
- <template #status="{ value }">
1629
- <span :style="{ color: value === 'active' ? 'green' : 'red' }">
1630
- {{ value === 'active' ? '✓ Активен' : '✗ Неактивен' }}
1631
- </span>
1632
- </template>
1633
-
1634
- <!-- Default слот для колонки actions -->
1635
- <template #actions="{ row }">
1636
- <button @click="deleteUser(row.id)">Удалить</button>
1637
- <a :href="`mailto:${row.email}`">Написать</a>
1638
- </template>
1639
- </sw-table>
1640
- ```
1641
-
1642
- #### Пример с универсальным слотом cell:
1643
-
1644
- ```html
1645
- <script setup>
1646
- import { ref } from 'vue'
1647
-
1648
- const products = ref([
1649
- { name: 'Товар 1', price: 1000, quantity: 5 },
1650
- { name: 'Товар 2', price: 2500, quantity: 3 },
1651
- { name: 'Товар 3', price: 750, quantity: 10 }
1448
+ const wideRows = ref([
1449
+ { id: 1, name: 'Иван Петров', dept: 'Разработка', email: 'ivan@example.com', note: 'В отпуске' },
1450
+ { id: 2, name: 'Мария Сидорова', dept: 'Дизайн', email: 'maria@example.com', note: 'Удалённо' }
1652
1451
  ])
1653
1452
  </script>
1654
1453
 
1655
- <style>
1656
- .sw-table th, .sw-table td { border: 1px solid #d6d6d6; padding: 6px 10px; }
1657
- </style>
1658
-
1659
- <sw-table :data="products">
1660
- <sw-table-column prop="name" label="Название" />
1661
- <sw-table-column prop="price" label="Цена" />
1662
- <sw-table-column prop="quantity" label="Количество" />
1663
-
1664
- <template #cell="{ column, value }">
1665
- <span v-if="column === 'price'" style="font-weight: bold">
1666
- {{ value }} ₽
1667
- </span>
1668
- <span v-else-if="column === 'quantity' && value < 5" style="color: red">
1669
- {{ value }} ⚠️ Мало
1670
- </span>
1671
- <span v-else>{{ value }}</span>
1672
- </template>
1454
+ <sw-table :data="wideRows" max-width="520px">
1455
+ <sw-table-column prop="id" label="ID" width="70px" fixed="left" />
1456
+ <sw-table-column prop="name" label="Имя" width="160px" fixed="left" />
1457
+ <sw-table-column
1458
+ v-for="column in wideColumns"
1459
+ :key="column.prop"
1460
+ :prop="column.prop"
1461
+ :label="column.label"
1462
+ :width="column.width"
1463
+ />
1464
+ <sw-table-column prop="note" label="Примечание" width="180px" fixed="right" />
1673
1465
  </sw-table>
1674
1466
  ```
1675
1467
 
1676
- #### Пример с объединением ячеек (rowspan/colspan):
1468
+ #### Объединение ячеек (rowspan / colspan):
1677
1469
 
1678
1470
  ```html
1679
1471
  <script setup>
1680
1472
  import { ref } from 'vue'
1681
-
1682
- const complexData = ref([
1683
- {
1684
- city: { label: 'Москва', rowspan: 2 },
1685
- district: 'Центр',
1686
- population: 500000
1687
- },
1688
- {
1689
- city: 'Москва', // будет скрыта из-за rowspan
1690
- district: 'Север',
1691
- population: 300000
1692
- },
1693
- {
1694
- city: { label: 'Общая статистика', colspan: 2 },
1695
- population: 800000
1696
- }
1473
+ const mergedData = ref([
1474
+ { city: { label: 'Москва', rowspan: 2 }, district: 'Центр', population: 500000 },
1475
+ { city: 'Москва', district: 'Север', population: 300000 },
1476
+ { city: { label: 'Итого', colspan: 2 }, population: 800000 }
1697
1477
  ])
1698
1478
  </script>
1699
1479
 
1700
- <style>
1701
- .sw-table th, .sw-table td { border: 1px solid #d6d6d6; padding: 6px 10px; }
1702
- </style>
1703
-
1704
- <sw-table :data="complexData">
1705
- <sw-table-column label="Город" prop="city" />
1706
- <sw-table-column label="Район" prop="district" />
1707
- <sw-table-column label="Население" prop="population" />
1480
+ <sw-table :data="mergedData">
1481
+ <sw-table-column prop="city" label="Город" width="120px" />
1482
+ <sw-table-column prop="district" label="Район" width="120px" />
1483
+ <sw-table-column prop="population" label="Население" width="120px" />
1708
1484
  </sw-table>
1709
1485
  ```
1710
1486
  ---
@@ -1732,15 +1508,18 @@ model - индекс активной вкладки (по порядку в к
1732
1508
  ### Пример использования / Example Usage
1733
1509
 
1734
1510
  ```html
1735
- <script>let activeTabId = 0</script>
1736
-
1737
- <sw-tabs v-model="activeTabId" class="custom-class">
1738
- <sw-tabs-pane label="Профиль" title="profile">
1739
- <p>Содержимое вкладки профиля / Profile tab</p>
1740
- </sw-tabs-pane>
1741
- <sw-tabs-pane label="Настройки" title="settings">
1742
- <p>Содержимое вкладки настроек / Settings tab</p>
1743
- </sw-tabs-pane>
1511
+ <script setup>
1512
+ import { ref } from 'vue'
1513
+ const tabsIndex = ref(0)
1514
+ </script>
1515
+
1516
+ <sw-tabs v-model="tabsIndex">
1517
+ <template #header>
1518
+ <sw-button size="small" text>в шапке</sw-button>
1519
+ </template>
1520
+ <sw-tabs-pane title="one" label="Первая">Контент вкладки 1</sw-tabs-pane>
1521
+ <sw-tabs-pane title="two" label="Вторая">Контент вкладки 2</sw-tabs-pane>
1522
+ <sw-tabs-pane title="three" label="Третья">Контент вкладки 3</sw-tabs-pane>
1744
1523
  </sw-tabs>
1745
1524
  ```
1746
1525
  ---
@@ -1762,17 +1541,10 @@ Default - для вкладок
1762
1541
 
1763
1542
  ### Пример использования / Example Usage
1764
1543
 
1544
+ См. [SwTabs](#swtabs).
1545
+
1765
1546
  ```html
1766
- <script>let activeTabId = 0</script>
1767
-
1768
- <sw-tabs v-model="activeTabId" class="custom-class">
1769
- <sw-tabs-pane label="Профиль" title="profile">
1770
- <p>Содержимое вкладки профиля / Profile tab</p>
1771
- </sw-tabs-pane>
1772
- <sw-tabs-pane label="Настройки" title="settings">
1773
- <p>Содержимое вкладки настроек / Settings tab</p>
1774
- </sw-tabs-pane>
1775
- </sw-tabs>
1547
+ <sw-tabs-pane title="one" label="Первая">Контент вкладки 1</sw-tabs-pane>
1776
1548
  ```
1777
1549
  ---
1778
1550
 
@@ -1796,79 +1568,32 @@ Default - для вкладок
1796
1568
  ### Пример
1797
1569
 
1798
1570
  ```html
1799
- <sw-tag type="primary" label="Новое" />
1800
- <sw-tag type="danger" closable label="Удалить" @close="onClose" />
1801
- ```
1802
- ---
1803
-
1804
- ## SwBadge
1805
-
1806
- Индикатор поверх слота: число, текст или точка (`isDot`).
1807
-
1808
- ### Свойства / Properties
1809
-
1810
- | Имя | Тип | По умолчанию | Описание |
1811
- |-------------|-------------------|--------------|-----------------------------------|
1812
- | `value` | `Number`/`String` | `` | Значение на бейдже. |
1813
- | `max` | `Number` | `99` | При числе > max → `{max}+`. |
1814
- | `type` | `String` | `danger` | Цвет метки. |
1815
- | `isDot` | `Boolean` | `false` | Точка вместо текста. |
1816
- | `showZero` | `Boolean` | `false` | Показывать `0`. |
1817
- | `hidden` | `Boolean` | `false` | Скрыть метку. |
1818
- | `class` | `String` | `` | CSS-класс обёртки. |
1819
-
1820
- ### Пример
1821
-
1822
- ```html
1823
- <sw-badge :value="3">
1824
- <sw-button label="Сообщения" />
1825
- </sw-badge>
1826
- <sw-badge is-dot type="warning">
1827
- <sw-button label="Статус" />
1828
- </sw-badge>
1829
- ```
1830
- ---
1831
-
1832
- ## SwPagination
1833
-
1834
- Постраничная навигация. `v-model` — текущая страница (с 1).
1835
-
1836
- ### Свойства / Properties
1837
-
1838
- | Имя | Тип | По умолчанию | Описание |
1839
- |---------------|-----------|--------------|----------------------------------|
1840
- | `total` | `Number` | `0` | Всего элементов. |
1841
- | `pageSize` | `Number` | `10` | Элементов на странице (`v-model:page-size`). |
1842
- | `pageSizes` | `Number[]` | `[10, 20, 50, 100]` | Варианты в селекте размера. |
1843
- | `showSize` | `Boolean` | `true` | Показать выбор «N / стр.». |
1844
- | `pagerCount` | `Number` | `7` | Число кнопок страниц (нечётное). |
1845
- | `size` | `String` | `` | `small` / `large`. |
1846
- | `showTotal` | `Boolean` | `false` | Текст «Всего N». |
1847
- | `disabled` | `Boolean` | `false` | Блок неактивен. |
1848
- | `class` | `String` | `` | CSS-класс. |
1849
-
1850
- ### Модель / Events
1851
-
1852
- - `v-model` / `modelValue` — номер страницы
1853
- - `v-model:page-size` — размер страницы
1854
- - `change` — новая страница
1855
- - `size-change` — новый размер страницы
1856
-
1857
- ### Пример
1571
+ <script setup>
1572
+ import { ref } from 'vue'
1573
+ const tags = ref(['закрыть', 'ещё'])
1574
+ const star = 'https://cdn.jsdelivr.net/npm/@tabler/icons@3.19.0/icons/outline/star.svg'
1575
+ </script>
1858
1576
 
1859
- ```html
1860
- <sw-pagination
1861
- v-model="page"
1862
- v-model:page-size="pageSize"
1863
- :total="240"
1864
- :page-sizes="[10, 20, 50]"
1865
- show-total
1577
+ <sw-tag type="primary" label="primary" />
1578
+ <sw-tag type="info" :before="star" label="icon" />
1579
+ <sw-tag
1580
+ v-for="(t, i) in tags"
1581
+ :key="i"
1582
+ type="primary"
1583
+ closable
1584
+ :label="t"
1585
+ @close="tags.splice(i, 1)"
1866
1586
  />
1867
1587
  ```
1868
1588
  ---
1869
1589
 
1870
1590
  ## Изменения / Changelog
1871
1591
 
1592
+ ### 0.13.19
1593
+
1594
+ - README: примеры из `dev/App.vue`, секции по алфавиту, правки SwDatePicker / SwDropdown
1595
+ - `exports`: `./dist/component-sw.css` (вместо несуществующего `main.css`)
1596
+
1872
1597
  ### 0.13.18
1873
1598
 
1874
1599
  - Лицензия: **ISC** (вместо MIT / Apache в файле LICENSE)
@@ -1884,83 +1609,6 @@ Default - для вкладок
1884
1609
 
1885
1610
  ---
1886
1611
 
1887
- - SwTag, SwBadge, SwPagination; Input textarea/password/clearable; Dropdown keyboard; Select without Element tokens.
1888
-
1889
- ### 0.13.11
1890
-
1891
- **Alert**
1892
-
1893
- - Параметры позиции: `placement` (`top` | `bottom`), `align` (`left` | `center` | `right`).
1894
- - Стек: `top` — старые сверху; `bottom` — свежие сверху у нижнего края.
1895
- - `type: 'error'` → класс `danger`; пустой `#footer` не рендерится.
1896
-
1897
- **SwDropdown**
1898
-
1899
- - Уголок к триггеру; сторона/смещение по фактическому placement (после flip).
1900
- - Динамический `z-index` попапа: z предка + 3.
1901
- - Удалён `SwDropdownNew`.
1902
-
1903
- **SwFormItem**
1904
-
1905
- - Подписи к полям: `label`, `type` (цвет текста), `justify`, слоты `#label` / default / `#before` / `#after`.
1906
-
1907
- **SwGide**
1908
-
1909
- - Динамический `z-index` оверлея (выше слайдеров/тултипов, ниже алертов).
1910
-
1911
- **SwSlider**
1912
-
1913
- - Без лага ползунка при drag (transition только на `transform`).
1914
- - Сортировка значений массива при перетаскивании; тултип следует за активным бегунком.
1915
-
1916
- **SwMessage**
1917
-
1918
- - Блокировка прокрутки страницы при открытии.
1919
-
1920
- ---
1921
-
1922
- - Alert: `placement` / `align` stacking; `error` → `danger`.
1923
- - SwDropdown: caret toward trigger; dynamic popup z-index; removed `SwDropdownNew`.
1924
- - SwFormItem: form captions (`label`, `type`, `justify`).
1925
- - SwGide: dynamic overlay z-index.
1926
- - SwSlider: no drag lag; array sort while dragging; tooltip follows active thumb.
1927
- - SwMessage: lock body scroll while open.
1928
-
1929
- ---
1930
-
1931
- ### 0.13.9
1932
-
1933
- **Иконки: унификация `before` / `after`**
1934
-
1935
- - Единые пропсы иконок: `before` (слева) и `after` (справа) в `SwButton`, `SwDropdownItem`, `SwMessage`, `SwSection`, `SwGide`, `Alert`.
1936
- - Старые имена сохранены и помечены **Deprecated** (удалить в major): `prefix`/`postfix` (SwButton), `iconBefore`, `iconAfter`, `iconClose`.
1937
-
1938
- **SwDatePicker**
1939
-
1940
- - В `data.holiday`: `weekend` вместо `holidays`, `preholiday` вместо `preholidays` (старые ключи — **Deprecated**, удалить в major).
1941
-
1942
- ---
1943
-
1944
- - Unified icon props: `before` / `after` across `SwButton`, `SwDropdownItem`, `SwMessage`, `SwSection`, `SwGide`, `Alert`.
1945
- - Legacy names kept and marked **Deprecated** (remove in major): `prefix`/`postfix` (SwButton), `iconBefore`, `iconAfter`, `iconClose`.
1946
- - `SwDatePicker` `data.holiday`: `weekend` / `preholiday` (legacy `holidays` / `preholidays` deprecated).
1947
-
1948
- ---
1949
-
1950
- ### 0.13.4
1951
-
1952
- **SwFile**
1953
-
1954
- - Добавлен компонент `SwFile` — загрузчик файлов с режимами `photo` (предпросмотр и обрезка) и `document` (несколько файлов, просмотр в новой вкладке).
1955
- - Поддержка drag & drop, `v-model` (`File[]`), слоты зоны загрузки, списка файлов, удаления и действий редактора обрезки.
1956
-
1957
- ---
1958
-
1959
- - Added `SwFile` — file uploader with `photo` (preview and crop) and `document` (multiple files, open in a new tab) modes.
1960
- - Supports drag & drop, `v-model` (`File[]`), slots for drop zone, file list, remove, and crop editor actions.
1961
-
1962
- ---
1963
-
1964
1612
  ## Лицензия / License
1965
1613
 
1966
1614
  Этот проект распространяется под лицензией ISC. Подробности см. в файле [LICENSE](./LICENSE). /