startup-ui 0.11.3 → 1.0.0

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 (123) hide show
  1. package/AGENTS.md +18 -0
  2. package/CHANGELOG.md +39 -0
  3. package/CLAUDE.md +1 -0
  4. package/LICENSE +21 -0
  5. package/README.md +54 -0
  6. package/dist/defaults.css +83 -0
  7. package/dist/index.css +1 -1
  8. package/dist/startup-ui.cjs.js +28 -587
  9. package/dist/startup-ui.cjs.js.map +1 -1
  10. package/dist/startup-ui.es.js +4555 -7451
  11. package/dist/startup-ui.es.js.map +1 -1
  12. package/dist/types/components/SActionIcon.d.ts +2 -1
  13. package/dist/types/components/SActionIcon.d.ts.map +1 -1
  14. package/dist/types/components/SCanvas.d.ts +0 -1
  15. package/dist/types/components/SCanvas.d.ts.map +1 -1
  16. package/dist/types/components/SCheckbox.d.ts.map +1 -1
  17. package/dist/types/components/SCheckboxGroup.d.ts +4 -0
  18. package/dist/types/components/SCheckboxGroup.d.ts.map +1 -1
  19. package/dist/types/components/SColumnSettings.d.ts +4 -4
  20. package/dist/types/components/SColumnSettings.d.ts.map +1 -1
  21. package/dist/types/components/SConfirm/SConfirm.d.ts +2 -0
  22. package/dist/types/components/SConfirm/SConfirm.d.ts.map +1 -1
  23. package/dist/types/components/SCopyText.d.ts.map +1 -1
  24. package/dist/types/components/SDatePicker.d.ts +3 -4
  25. package/dist/types/components/SDatePicker.d.ts.map +1 -1
  26. package/dist/types/components/SDialog.d.ts.map +1 -1
  27. package/dist/types/components/SFilterGroup.d.ts +3 -3
  28. package/dist/types/components/SFilterGroup.d.ts.map +1 -1
  29. package/dist/types/components/SFooter.d.ts.map +1 -1
  30. package/dist/types/components/SForm.d.ts.map +1 -1
  31. package/dist/types/components/SFormRow.d.ts.map +1 -1
  32. package/dist/types/components/SHtmlEditor.d.ts +20 -0
  33. package/dist/types/components/SHtmlEditor.d.ts.map +1 -1
  34. package/dist/types/components/SImagePreview.d.ts.map +1 -1
  35. package/dist/types/components/SInput.d.ts +9 -2
  36. package/dist/types/components/SInput.d.ts.map +1 -1
  37. package/dist/types/components/SMenu.d.ts +39 -0
  38. package/dist/types/components/SMenu.d.ts.map +1 -0
  39. package/dist/types/components/SNote.d.ts.map +1 -1
  40. package/dist/types/components/SPagination.d.ts.map +1 -1
  41. package/dist/types/components/SProgressbar.d.ts.map +1 -1
  42. package/dist/types/components/SRadio.d.ts.map +1 -1
  43. package/dist/types/components/SRadioGroup.d.ts +4 -0
  44. package/dist/types/components/SRadioGroup.d.ts.map +1 -1
  45. package/dist/types/components/SSelect.d.ts +6 -0
  46. package/dist/types/components/SSelect.d.ts.map +1 -1
  47. package/dist/types/components/SStatus.d.ts.map +1 -1
  48. package/dist/types/components/STable.d.ts +4 -4
  49. package/dist/types/components/STable.d.ts.map +1 -1
  50. package/dist/types/components/SToggle.d.ts.map +1 -1
  51. package/dist/types/components/STooltip.d.ts +0 -1
  52. package/dist/types/components/STooltip.d.ts.map +1 -1
  53. package/dist/types/components/STree.d.ts +11 -5
  54. package/dist/types/components/STree.d.ts.map +1 -1
  55. package/dist/types/components/SUpload.d.ts +5 -4
  56. package/dist/types/components/SUpload.d.ts.map +1 -1
  57. package/dist/types/components/SVerticalMenu.d.ts.map +1 -1
  58. package/dist/types/components/htmlEditor/contentStyle.d.ts +9 -0
  59. package/dist/types/components/htmlEditor/contentStyle.d.ts.map +1 -0
  60. package/dist/types/components/icons.d.ts +24 -0
  61. package/dist/types/components/icons.d.ts.map +1 -0
  62. package/dist/types/config.d.ts +49 -0
  63. package/dist/types/config.d.ts.map +1 -0
  64. package/dist/types/global-components.d.ts +3 -6
  65. package/dist/types/global-components.d.ts.map +1 -1
  66. package/dist/types/index.d.ts +12 -2
  67. package/dist/types/index.d.ts.map +1 -1
  68. package/dist/types/locale/index.d.ts +49 -0
  69. package/dist/types/locale/index.d.ts.map +1 -0
  70. package/dist/types/locale/messages/en-US.d.ts +4 -0
  71. package/dist/types/locale/messages/en-US.d.ts.map +1 -0
  72. package/dist/types/locale/messages/en.d.ts +4 -0
  73. package/dist/types/locale/messages/en.d.ts.map +1 -0
  74. package/dist/types/locale/messages/ru.d.ts +4 -0
  75. package/dist/types/locale/messages/ru.d.ts.map +1 -0
  76. package/dist/types/locale/types.d.ts +74 -0
  77. package/dist/types/locale/types.d.ts.map +1 -0
  78. package/dist/types/plugin.d.ts +2 -1
  79. package/dist/types/plugin.d.ts.map +1 -1
  80. package/dist/types/utils/deepMerge.d.ts +9 -0
  81. package/dist/types/utils/deepMerge.d.ts.map +1 -0
  82. package/dist/types/utils/options.d.ts +25 -0
  83. package/dist/types/utils/options.d.ts.map +1 -0
  84. package/llms/components/data/sfilter.md +194 -0
  85. package/llms/components/data/spagination.md +114 -0
  86. package/llms/components/data/stable.md +638 -0
  87. package/llms/components/data/stree.md +213 -0
  88. package/llms/components/forms/scheckbox.md +139 -0
  89. package/llms/components/forms/sdatepicker.md +161 -0
  90. package/llms/components/forms/sform.md +240 -0
  91. package/llms/components/forms/shtmleditor.md +143 -0
  92. package/llms/components/forms/sinput.md +165 -0
  93. package/llms/components/forms/sradio.md +164 -0
  94. package/llms/components/forms/sselect.md +149 -0
  95. package/llms/components/forms/sswitch.md +69 -0
  96. package/llms/components/forms/supload.md +189 -0
  97. package/llms/components/interfaces/sactionbar.md +40 -0
  98. package/llms/components/interfaces/sactionicon.md +126 -0
  99. package/llms/components/interfaces/salert.md +87 -0
  100. package/llms/components/interfaces/sbutton.md +167 -0
  101. package/llms/components/interfaces/scolumnsettings.md +204 -0
  102. package/llms/components/interfaces/sconfirm.md +57 -0
  103. package/llms/components/interfaces/scopytext.md +67 -0
  104. package/llms/components/interfaces/sdashboard.md +130 -0
  105. package/llms/components/interfaces/sdialog.md +158 -0
  106. package/llms/components/interfaces/simagepreview.md +98 -0
  107. package/llms/components/interfaces/snote.md +64 -0
  108. package/llms/components/interfaces/sprogressbar.md +48 -0
  109. package/llms/components/interfaces/sstat.md +79 -0
  110. package/llms/components/interfaces/sstatus.md +76 -0
  111. package/llms/components/interfaces/stag.md +70 -0
  112. package/llms/components/interfaces/stimeline.md +47 -0
  113. package/llms/components/interfaces/stoggle.md +120 -0
  114. package/llms/components/interfaces/stooltip.md +88 -0
  115. package/llms/components/template/scanvas.md +61 -0
  116. package/llms/components/template/smenu.md +88 -0
  117. package/llms/components/template/sverticalmenu.md +113 -0
  118. package/llms/llms.txt +49 -0
  119. package/package.json +56 -21
  120. package/dist/types/components/SDropdownMenu.d.ts +0 -39
  121. package/dist/types/components/SDropdownMenu.d.ts.map +0 -1
  122. package/dist/types/components/SHorizontalMenu.d.ts +0 -33
  123. package/dist/types/components/SHorizontalMenu.d.ts.map +0 -1
@@ -0,0 +1,126 @@
1
+ # SActionIcon
2
+
3
+ Иконка действия (чаще всего используется в таблицах).
4
+
5
+ <SToggle title="В чем отличие от аналогов?">
6
+ <p>В отличие от популярных библиотек компонентов для Vue3:</p>
7
+ <ol>
8
+ <li>Привязка к FontAwesome, который бесплатен и оптимально решает задачи иконок для стартапов.</li>
9
+ <li>Упрощает запрос подтверждения перед опасными действиями (напр. удаление) с помощью одного атрибута.</li>
10
+ </ol>
11
+ </SToggle>
12
+
13
+ ## Стандартный пример
14
+
15
+ Используются стандартые иконки FontAwesome. Типовой пример с click-событием:
16
+
17
+ ```vue
18
+ <template>
19
+ <SActionIcon icon="pen-to-square" title="Редактировать" @click="greet('Hello!')" />
20
+ <SActionIcon :icon="['far', 'calendar']" title="Календарь" @click="greet('Hello!')" />
21
+ <SActionIcon icon="xmark" title="Закрыть" @click="greet('Hello!')" />
22
+ <SActionIcon icon="arrow-up-right-from-square" title="Открыть" @click="greet('Hello!')" />
23
+ <SActionIcon icon="circle-question" title="Помощь" @click="greet('Hello!')" />
24
+ <SActionIcon icon="copy" title="Копировать" @click="greet('Hello!')" />
25
+ <SActionIcon icon="bars" title="Меню" @click="greet('Hello!')" />
26
+ <SActionIcon icon="cloud-arrow-down" title="Скачать" @click="greet('Hello!')" />
27
+ <SActionIcon icon="folder-open" title="Открыть папку" @click="greet('Hello!')" />
28
+ <SActionIcon icon="user" title="Профиль" @click="greet('Hello!')" />
29
+ </template>
30
+
31
+ <script setup>
32
+ function greet(msg) {
33
+ alert(msg)
34
+ }
35
+ </script>
36
+ ```
37
+
38
+ ## Ссылка в иконке
39
+
40
+ Если указать href-атрибут, то по умолчанию иконка станет анкором:
41
+
42
+ ```vue
43
+ <template>
44
+ <SActionIcon icon="pen-to-square" title="Перейти на сайт" href="https://startup-ui.ru" />
45
+ <SActionIcon :icon="['far', 'calendar']" title="Перейти на сайт" href="https://startup-ui.ru" />
46
+ <SActionIcon icon="xmark" title="Перейти на сайт" href="https://startup-ui.ru" />
47
+ <SActionIcon icon="arrow-up-right-from-square" title="Перейти на сайт" href="https://startup-ui.ru" />
48
+ <SActionIcon icon="circle-question" title="Перейти на сайт" href="https://startup-ui.ru" />
49
+ <SActionIcon icon="copy" title="Перейти на сайт" href="https://startup-ui.ru" />
50
+ <SActionIcon icon="bars" title="Перейти на сайт" href="https://startup-ui.ru" />
51
+ <SActionIcon icon="cloud-arrow-down" title="Перейти на сайт" href="https://startup-ui.ru" />
52
+ <SActionIcon icon="folder-open" title="Перейти на сайт" href="https://startup-ui.ru" />
53
+ <SActionIcon icon="user" title="Перейти на сайт" href="https://startup-ui.ru" />
54
+ </template>
55
+
56
+ <script setup>
57
+ import { SActionIcon } from 'startup-ui'
58
+ </script>
59
+ ```
60
+
61
+ Но при необходимости также через атрибут is можно также передать Link-компонент InertiaJs:
62
+
63
+ ```vue
64
+ <template>
65
+ <SActionIcon icon="pen-to-square" title="Редактировать" :is="Link" href="/users/" />
66
+ </template>
67
+
68
+ <script setup>
69
+ import { Link } from '@inertiajs/vue3';
70
+ </script>
71
+ ```
72
+
73
+ ## Подтверждение действия
74
+
75
+ Для небезопасных действий выделяем иконку цветом (атрибут <strong>danger</strong>) и запрашиваем подтверждение перед выполнением (атрибут <strong>confirm</strong>):
76
+
77
+ ```vue
78
+ <template>
79
+ <SActionIcon title="Удалить" @click="deleteUser" icon="trash" danger
80
+ confirm="Вы действительно хотите удалить пользователя?" />
81
+ </template>
82
+
83
+ <script setup>
84
+ function deleteUser() {
85
+ alert('Пользователь удален (эмуляция)')
86
+ }
87
+ </script>
88
+ ```
89
+
90
+ Подписи и цвет кнопок диалога настраиваются через `confirm-options` (пробрасываются в `SConfirm`):
91
+
92
+ ```vue
93
+ <SActionIcon
94
+ icon="trash"
95
+ confirm="Удалить запись?"
96
+ :confirm-options="{ acceptLabel: 'Удалить', variant: 'danger' }"
97
+ @click="remove"
98
+ />
99
+ ```
100
+
101
+ ## Интерфейс компонента
102
+
103
+ ### Свойства (Props)
104
+
105
+ | Название | Тип | По умолчанию | Описание |
106
+ |----------|-----|--------------|----------|
107
+ | icon | string \| string[] | required | Имя иконки FontAwesome (например, `'trash'` или `['far', 'calendar']`) |
108
+ | danger | boolean | false | Выделяет иконку красным цветом |
109
+ | confirm | string | undefined | Текст диалога подтверждения перед выполнением `@click` |
110
+ | confirmTitle | string | 'Необходимо подтверждение' | Заголовок диалога подтверждения |
111
+ | confirmOptions | object | undefined | Опции, пробрасываемые в `SConfirm.open` (`acceptLabel`, `cancelLabel`, `variant`, …) |
112
+ | is | string \| Component | undefined | HTML-элемент или Vue-компонент для рендеринга (например, InertiaJS `Link`) |
113
+ | href | string | undefined | URL для перехода (делает иконку ссылкой) |
114
+ | title | string | undefined | Текст подсказки при наведении |
115
+
116
+ ### События (Events)
117
+
118
+ | Название | Параметры | Описание |
119
+ |----------|-----------|----------|
120
+ | click | none | Вызывается при клике на иконку. Срабатывает ПОСЛЕ подтверждения, если передан параметр `confirm`. |
121
+
122
+ <style lang="scss" scoped>
123
+ a {
124
+ color: var(--s-primary);
125
+ }
126
+ </style>
@@ -0,0 +1,87 @@
1
+ # SAlert
2
+
3
+ Оповещение о произошедшем событии.
4
+
5
+ <SToggleGroup>
6
+ <SToggle title="В чем отличие от аналогов?">
7
+ <p>В отличие от популярных библиотек компонентов для Vue3:</p>
8
+ <ol>
9
+ <li>Упрощено до одного метода, не требует добавлять элемент в шаблон.</li>
10
+ </ol>
11
+ </SToggle>
12
+ <SToggle title="Что будет ценно улучшить">
13
+ <ol>
14
+ <li>Добавить возможность собирать серию оповещений друг под другом.</li>
15
+ </ol>
16
+ </SToggle>
17
+ </SToggleGroup>
18
+
19
+ ## Базовый пример
20
+
21
+ Информационное оповещение:
22
+
23
+ ```vue
24
+ <template>
25
+ <SButton @click="SAlert.info('Информация')">Информация</SButton>
26
+ </template>
27
+ <script setup>
28
+ import { SAlert } from 'startup-ui'
29
+ </script>
30
+ ```
31
+
32
+ Оповещение об успешном действии:
33
+
34
+ ```vue
35
+ <template>
36
+ <SButton color="green" @click="SAlert.success('Успех')">Успех</SButton>
37
+ </template>
38
+ <script setup>
39
+ import { SAlert } from 'startup-ui'
40
+ </script>
41
+ ```
42
+
43
+ Оповещение об ошибке:
44
+
45
+ ```vue
46
+ <template>
47
+ <SButton color="red" @click="SAlert.error('Ошибка')">Ошибка</SButton>
48
+ </template>
49
+ <script setup>
50
+ import { SAlert } from 'startup-ui'
51
+ </script>
52
+ ```
53
+
54
+ ## Увеличенное время до закрытия
55
+
56
+ По умолчанию оповещения закрываются через 5 секунд. Другое время закрытия можно задать параметром closeAfter:
57
+
58
+ ```vue
59
+ <template>
60
+ <SButton @click="closeWithDelay">Информация</SButton>
61
+ </template>
62
+ <script setup>
63
+ import { SAlert } from 'startup-ui'
64
+
65
+ function closeWithDelay() {
66
+ SAlert.info('Закроется через 5 секунд', {
67
+ closeAfter: 5000,
68
+ })
69
+ }
70
+ </script>
71
+ ```
72
+
73
+ ## Интерфейс компонента
74
+
75
+ ### Методы
76
+
77
+ - `SAlert.info(text: string, options?: AlertOptions)` — информационное оповещение
78
+ - `SAlert.success(text: string, options?: AlertOptions)` — оповещение об успехе
79
+ - `SAlert.error(text: string, options?: AlertOptions)` — оповещение об ошибке
80
+ - `SAlert.open(text: string, options?: AlertOptions)` — базовый метод (тип задаётся в `options`)
81
+
82
+ ### AlertOptions
83
+
84
+ | Название | Тип | По умолчанию | Описание |
85
+ |----------|-----|--------------|----------|
86
+ | type | `'success'` \| `'info'` \| `'error'` | `'info'` | Визуальный стиль оповещения. |
87
+ | closeAfter | number | `3000` | Время в миллисекундах до автозакрытия. |
@@ -0,0 +1,167 @@
1
+ # SButton
2
+
3
+ Кнопка.
4
+
5
+ <SToggle title="В чем отличие от аналогов?">
6
+ <p>В отличие от популярных библиотек компонентов для Vue3:</p>
7
+ <ol>
8
+ <li>В зависимости от контекста сам подбирает семантический элемент: анкор для ссылок или button для отправки формы.</li>
9
+ <li>Позволяет передать Link-элемент InertiaJS в качестве атрибута as.</li>
10
+ </ol>
11
+ </SToggle>
12
+
13
+ ## Стандартный пример
14
+
15
+ Используйте `color`, `outlined`, `transparent`, `disabled`, `small`, `loading` и `fullwidth` чтобы задать стили кнопок.
16
+
17
+ ### Основной цвет
18
+
19
+ ```vue
20
+ <template>
21
+ <SButton>Основное действие</SButton>
22
+ <SButton outlined>Дополнительное действие</SButton>
23
+ <SButton transparent>Прозрачная кнопка</SButton>
24
+ <SButton disabled>Недоступная кнопка</SButton>
25
+ <SButton small>Маленькая кнопка</SButton>
26
+ </template>
27
+
28
+ <script setup>
29
+ import { SButton } from 'startup-ui'
30
+ </script>
31
+ ```
32
+
33
+ ### Красная кнопка
34
+
35
+ ```vue
36
+ <template>
37
+ <SButton color="red">Основное действие</SButton>
38
+ <SButton outlined color="red">Дополнительное действие</SButton>
39
+ <SButton transparent color="red">Прозрачная кнопка</SButton>
40
+ <SButton disabled color="red">Недоступная кнопка</SButton>
41
+ <SButton small color="red">Маленькая кнопка</SButton>
42
+ </template>
43
+
44
+ <script setup>
45
+ import { SButton } from 'startup-ui'
46
+ </script>
47
+ ```
48
+
49
+ ### Зеленая кнопка
50
+
51
+ ```vue
52
+ <template>
53
+ <SButton color="green">Основное действие</SButton>
54
+ <SButton outlined color="green">Дополнительное действие</SButton>
55
+ <SButton transparent color="green">Прозрачная кнопка</SButton>
56
+ <SButton disabled color="green">Недоступная кнопка</SButton>
57
+ <SButton small color="green">Маленькая кнопка</SButton>
58
+ </template>
59
+
60
+ <script setup>
61
+ import { SButton } from 'startup-ui'
62
+ </script>
63
+ ```
64
+
65
+ ### Жёлтая кнопка
66
+
67
+ ```vue
68
+ <template>
69
+ <SButton color="yellow">Основное действие</SButton>
70
+ <SButton outlined color="yellow">Дополнительное действие</SButton>
71
+ <SButton transparent color="yellow">Прозрачная кнопка</SButton>
72
+ <SButton disabled color="yellow">Недоступная кнопка</SButton>
73
+ <SButton small color="yellow">Маленькая кнопка</SButton>
74
+ </template>
75
+
76
+ <script setup>
77
+ import { SButton } from 'startup-ui'
78
+ </script>
79
+ ```
80
+
81
+ ### Кнопка на всю ширину формы
82
+
83
+ ```vue
84
+ <template>
85
+ <SButton fullwidth>Основное действие</SButton>
86
+ <SButton fullwidth color="red">Основное действие</SButton>
87
+ <SButton fullwidth color="green">Основное действие</SButton>
88
+ <SButton fullwidth color="yellow">Основное действие</SButton>
89
+ </template>
90
+
91
+ <script setup>
92
+ import { SButton } from 'startup-ui'
93
+ </script>
94
+ ```
95
+
96
+ ## Действия по кнопке
97
+
98
+ ### Отправка формы
99
+
100
+ Если кнопка внутри формы, то отправляет форму:
101
+
102
+ ```vue
103
+ <template>
104
+ <SForm method="post" action="/users/create">
105
+ ...
106
+ <SButton>Создать пользователя</SButton>
107
+ </SForm>
108
+ </template>
109
+ ```
110
+
111
+ ### Кастомное действие
112
+
113
+ ```vue
114
+ <template>
115
+ <SButton @click="createUser">Создать пользователя</SButton>
116
+ </template>
117
+ <script setup>
118
+ import { SAlert } from 'startup-ui'
119
+ function createUser() {
120
+ SAlert.success('Пользователь создан')
121
+ }
122
+ </script>
123
+ ```
124
+
125
+ ### Переход по ссылке
126
+
127
+ Если добавляем href, то кнопка по умолчанию становится семантически правильным анкором:
128
+
129
+ ```vue
130
+ <template>
131
+ <SButton href="https://startup-ui.ru">Документация</SButton>
132
+ </template>
133
+
134
+ <script setup>
135
+ import { SButton } from 'startup-ui'
136
+ </script>
137
+ ```
138
+
139
+ ### Переход по внутренней ссылке InertiaJs
140
+
141
+ Если нужно сделать кнопку внутренней InertjaJS-ссылкой, то используем атрибут "is":
142
+
143
+ ```vue
144
+ <SButton :is="Link" href="/projects/create">Создать проект</SButton>
145
+ ```
146
+
147
+ ## Интерфейс компонента
148
+
149
+ ### Свойства (Props)
150
+
151
+ | Название | Тип | По умолчанию | Описание |
152
+ |----------|-----|--------------|----------|
153
+ | outlined | boolean | false | Стиль кнопки с контуром (без заливки) |
154
+ | transparent | boolean | false | Прозрачная кнопка без границ |
155
+ | fullwidth | boolean | false | Кнопка на всю ширину контейнера |
156
+ | small | boolean | false | Маленький размер кнопки |
157
+ | disabled | boolean | false | Отключает кнопку (некликабельна, прозрачность 0.3) |
158
+ | loading | boolean | false | Состояние загрузки (некликабельна, курсор ожидания) |
159
+ | color | string | — | Цвет кнопки: `"red"`, `"green"`, `"yellow"` или кастомный |
160
+ | is | string \| Component | — | HTML-элемент или Vue-компонент для рендеринга (например, InertiaJS `Link`) |
161
+ | href | string | — | URL для перехода (делает кнопку ссылкой) |
162
+
163
+ ### Слоты (Slots)
164
+
165
+ | Название | Описание |
166
+ |----------|----------|
167
+ | default | Содержимое кнопки (текст, иконка и т.д.) |
@@ -0,0 +1,204 @@
1
+ # SColumnSettings
2
+
3
+ Включение/выключение колонок в таблице.
4
+
5
+ ## Базовый пример
6
+
7
+ ```vue
8
+ <template>
9
+ <div style="display: flex; justify-content: flex-end; margin-bottom: 20px;">
10
+ <SColumnSettings v-model="tableColumns" :options="availableColumns" />
11
+ </div>
12
+
13
+ <STable :data="users">
14
+ <template #header>
15
+ <td>Пользователь</td>
16
+ <template v-for="tableColumn in tableColumns" :key="tableColumn">
17
+ <td class="center">{{ availableColumns[tableColumn] }}</td>
18
+ </template>
19
+ <td></td>
20
+ </template>
21
+ <template #row="{ row }">
22
+ <td>{{ row.username }}</td>
23
+ <template v-for="tableColumn in tableColumns" :key="tableColumn">
24
+ <td class="center">{{ row[tableColumn] }}</td>
25
+ </template>
26
+ <td class="right">
27
+ <SActionIcon title="Удалить" :confirm="`Вы действительно хотите удалить пользователя «${row.username}»?`"
28
+ @click="deleteUser(row.username)" icon="trash" danger />
29
+ </td>
30
+ </template>
31
+ </STable>
32
+ </template>
33
+ <script setup>
34
+ import { ref, computed } from 'vue'
35
+
36
+ const users = ref([
37
+ { username: 'Ivanov', role: 'customer', plan: 'Базовый', balance: 3000 },
38
+ { username: 'Petrov', role: 'admin', plan: 'Расширенный', balance: 4500 }
39
+ ])
40
+
41
+ function deleteUser(username) {
42
+ users.value = users.value.filter(user => user.username !== username)
43
+ }
44
+
45
+ const availableColumns = {
46
+ plan: 'Тариф',
47
+ balance: 'Баланс',
48
+ role: 'Роль'
49
+ }
50
+ const tableColumns = ref(Object.keys(availableColumns))
51
+ </script>
52
+ ```
53
+
54
+ ## Сброс колонок до значений по умолчанию
55
+
56
+ Если нужно сбрасывать колонки до набора по умолчанию, это можно сделать так:
57
+
58
+ ```vue
59
+ <template>
60
+ <div style="display: flex; justify-content: flex-end; margin-bottom: 20px;">
61
+ <SColumnSettings v-model="tableColumns" :options="availableColumns" :column-presets="columnPresets" />
62
+ </div>
63
+
64
+ <STable :data="users">
65
+ <template #header>
66
+ <td>Пользователь</td>
67
+ <template v-for="tableColumn in tableColumns" :key="tableColumn">
68
+ <td class="center">{{ availableColumns[tableColumn] }}</td>
69
+ </template>
70
+ <td></td>
71
+ </template>
72
+ <template #row="{ row }">
73
+ <td>{{ row.username }}</td>
74
+ <template v-for="tableColumn in tableColumns" :key="tableColumn">
75
+ <td class="center">{{ row[tableColumn] }}</td>
76
+ </template>
77
+ <td class="right">
78
+ <SActionIcon title="Удалить" :confirm="`Вы действительно хотите удалить пользователя «${row.username}»?`"
79
+ @click="deleteUser(row.username)" icon="trash" danger />
80
+ </td>
81
+ </template>
82
+ </STable>
83
+ </template>
84
+ <script setup>
85
+ import { ref } from 'vue'
86
+
87
+ const users = ref([
88
+ { username: 'Ivanov', role: 'customer', plan: 'Базовый', balance: 3000, created_at: '2025-11-04' },
89
+ { username: 'Petrov', role: 'admin', plan: 'Расширенный', balance: 4500, created_at: '2025-11-05' }
90
+ ])
91
+
92
+ function deleteUser(username) {
93
+ users.value = users.value.filter(user => user.username !== username)
94
+ }
95
+
96
+ const availableColumns = {
97
+ plan: 'Тариф',
98
+ balance: 'Баланс',
99
+ role: 'Роль',
100
+ created_at: 'Дата регистрации'
101
+ }
102
+ const tableColumns = ref(Object.keys(availableColumns))
103
+
104
+ const columnPresets = [{
105
+ title: 'Стандартные колонки',
106
+ columns: ['plan', 'balance', 'role', 'created_at']
107
+ }]
108
+ </script>
109
+ ```
110
+
111
+ Когда набор полей всего один, по умолчанию в футере выпадающего списка выводится строка «Сбросить изменения», когда несколько — выводится название каждого набора. Это повдение можно изменить с помощью слота <strong>setpreset</strong>:
112
+
113
+ ```vue
114
+ <template>
115
+ <SColumnSettings v-model="tableColumns" :options="availableColumns" :column-presets="columnPresets">
116
+ <template #setpreset="{ preset }">
117
+ <FontAwesomeIcon icon="rotate-left" /> Сбросить на {{ preset.title }}
118
+ </template>
119
+ </SColumnSettings>
120
+ </template>
121
+ ```
122
+
123
+ ## Постоянные колонки
124
+
125
+ Если нужно запретить удаление определенных колонок, передайте массив с ними в атрибут <strong>permanent-columns</strong>:
126
+
127
+ ```vue
128
+ <template>
129
+ <div style="display: flex; justify-content: flex-end; margin-bottom: 20px;">
130
+ <SColumnSettings v-model="tableColumns" :permanent-columns="permanentColumns" :column-presets="columnPresets" :options="availableColumns" />
131
+ </div>
132
+
133
+ <STable :data="users">
134
+ <template #header>
135
+ <td>Пользователь</td>
136
+ <template v-for="tableColumn in tableColumns" :key="tableColumn">
137
+ <td class="center">{{ availableColumns[tableColumn] }}</td>
138
+ </template>
139
+ <td></td>
140
+ </template>
141
+ <template #row="{ row }">
142
+ <td>{{ row.username }}</td>
143
+ <template v-for="tableColumn in tableColumns" :key="tableColumn">
144
+ <td class="center">{{ row[tableColumn] }}</td>
145
+ </template>
146
+ <td class="right">
147
+ <SActionIcon title="Удалить" :confirm="`Вы действительно хотите удалить пользователя «${row.username}»?`"
148
+ @click="deleteUser(row.username)" icon="trash" danger />
149
+ </td>
150
+ </template>
151
+ </STable>
152
+ </template>
153
+ <script setup>
154
+ import { ref } from 'vue'
155
+
156
+ const users = ref([
157
+ { username: 'Ivanov', role: 'customer', plan: 'Базовый', balance: 3000, created_at: '2025-11-04' },
158
+ { username: 'Petrov', role: 'admin', plan: 'Расширенный', balance: 4500, created_at: '2025-11-05' }
159
+ ])
160
+
161
+ function deleteUser(username) {
162
+ users.value = users.value.filter(user => user.username !== username)
163
+ }
164
+
165
+ const availableColumns = {
166
+ plan: 'Тариф',
167
+ balance: 'Баланс',
168
+ role: 'Роль',
169
+ created_at: 'Дата регистрации'
170
+ }
171
+ const tableColumns = ref(Object.keys(availableColumns))
172
+
173
+ const columnPresets = [{
174
+ title: 'Стандартные колонки',
175
+ columns: ['plan', 'balance', 'role', 'created_at']
176
+ }]
177
+
178
+ const permanentColumns = ['role']
179
+ </script>
180
+ ```
181
+
182
+ ## Интерфейс компонента
183
+
184
+ ### Свойства (Props)
185
+
186
+ | Название | Тип | По умолчанию | Описание |
187
+ |----------|-----|--------------|----------|
188
+ | modelValue / v-model | `string[]` | `[]` | Массив ключей активных колонок. |
189
+ | options | `Record<string, string>` | `{}` | Объект (словарь), сопоставляющий ключи колонок с их отображаемыми заголовками, например `{ id: 'Идентификатор' }`. |
190
+ | columnPresets | `SColumnSettingsPreset[]` | `[]` | Массив объектов `{ title: string, columns: string[] }`. Используется для быстрого сброса колонок на заданные пресеты. |
191
+ | permanentColumns | `string[]` | `[]` | Массив ключей колонок, которые пользователь не может выключить. |
192
+
193
+ ### Слоты (Slots)
194
+
195
+ | Название | Описание |
196
+ |----------|----------|
197
+ | label | Основное содержимое кнопки, открывающей выпадающий список. По умолчанию отображает иконку и текст "Настроить колонки". |
198
+ | setpreset | Слот для переопределения шаблона кнопки пресета в подвале выпадающего списка. Передает параментр `{ preset }`. |
199
+
200
+ <style lang="scss">
201
+ .s-custom-dropdown-container.open li + li {
202
+ margin-top: 0;
203
+ }
204
+ </style>
@@ -0,0 +1,57 @@
1
+ # SConfirm
2
+
3
+ Диалоговое окно подтверждения действия.
4
+
5
+ <SToggle title="В чем отличие от аналогов?">
6
+ <p>В отличие от популярных библиотек компонентов для Vue3:</p>
7
+ <ol>
8
+ <li>Упрощено до одного метода, не требует добавлять элемент в шаблон.</li>
9
+ </ol>
10
+ </SToggle>
11
+
12
+ ## Базовый пример
13
+
14
+ ```vue
15
+ <template>
16
+ <SButton @click="deleteUser">Удалить пользователя</SButton>
17
+ </template>
18
+
19
+ <script setup>
20
+ import { SConfirm, SAlert } from 'startup-ui'
21
+
22
+ function deleteUser() {
23
+ SConfirm.open('Вы действительно хотите удалить пользователя?', {
24
+ title: 'Подтверждение удаления',
25
+ onAccept: () => SAlert.success('Пользователь удален')
26
+ })
27
+ }
28
+ </script>
29
+ ```
30
+
31
+ ## Интерфейс компонента
32
+
33
+ `SConfirm.open(message: string, options?: ConfirmOptions)`
34
+
35
+ ### Аргументы
36
+
37
+ | Название | Тип | Описание |
38
+ |----------|-----|----------|
39
+ | message | string | Обязательный. Основной текст/HTML диалога подтверждения. |
40
+ | options | object | Необязательный объект конфигурации (см. ConfirmOptions ниже). |
41
+
42
+ ### ConfirmOptions
43
+
44
+ | Название | Тип | По умолчанию | Описание |
45
+ |----------|-----|--------------|----------|
46
+ | title | string | `'Необходимо подтверждение'` | Заголовок диалогового окна. |
47
+ | acceptLabel | string | `'Да'` | Текст кнопки подтверждения. |
48
+ | cancelLabel | string | `'Нет'` | Текст кнопки отмены. |
49
+ | variant | `'primary' \| 'danger'` | `'danger'` | Цвет кнопки подтверждения: `danger` (красная) для разрушающих действий, `primary` — для неразрушающих (move и т.п.). |
50
+ | onAccept | function | `() => {}` | Коллбэк при нажатии кнопки подтверждения. |
51
+ | onCancel | function | `() => {}` | Коллбэк при нажатии кнопки отмены или фонового оверлея. |
52
+
53
+ <style lang="scss">
54
+ .s-confirm {
55
+ color: var(--s-text);
56
+ }
57
+ </style>