@studiocms/ui 0.3.2 → 0.4.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.
- package/dist/components/Accordion/Accordion.astro +23 -0
- package/dist/components/Accordion/Item.astro +21 -0
- package/dist/components/Accordion/accordion.css +64 -0
- package/dist/components/Accordion/accordion.d.ts +1 -0
- package/dist/components/Accordion/accordion.js +70 -0
- package/dist/components/Badge/Badge.astro +49 -0
- package/dist/components/Badge/badge.css +111 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.astro +31 -0
- package/dist/components/Breadcrumbs/breadcrumbs.css +15 -0
- package/dist/components/Button/Button.astro +75 -0
- package/dist/components/Button/button.css +292 -0
- package/{src/components → dist/components/Card}/Card.astro +1 -48
- package/dist/components/Card/card.css +38 -0
- package/dist/components/Center/Center.astro +7 -0
- package/dist/components/Center/center.css +8 -0
- package/dist/components/Checkbox/Checkbox.astro +95 -0
- package/dist/components/Checkbox/checkbox.css +119 -0
- package/dist/components/Checkbox/checkbox.d.ts +2 -0
- package/dist/components/Checkbox/checkbox.js +20 -0
- package/{src/components → dist/components/Divider}/Divider.astro +2 -25
- package/dist/components/Divider/divider.css +21 -0
- package/dist/components/Dropdown/Dropdown.astro +116 -0
- package/dist/components/Dropdown/dropdown.css +180 -0
- package/dist/components/Dropdown/dropdown.d.ts +48 -0
- package/dist/components/Dropdown/dropdown.js +201 -0
- package/dist/components/Footer/Footer.astro +58 -0
- package/dist/components/Footer/footer.css +68 -0
- package/dist/components/Group/Group.astro +7 -0
- package/dist/components/Group/group.css +19 -0
- package/{src/utils → dist/components/Icon}/Icon.astro +1 -1
- package/{src/utils/iconType.ts → dist/components/Icon/iconType.d.ts} +0 -1
- package/dist/components/Icon/iconType.js +0 -0
- package/{src/components → dist/components/Input}/Input.astro +2 -48
- package/dist/components/Input/input.css +38 -0
- package/{src → dist}/components/Modal/Modal.astro +4 -122
- package/dist/components/Modal/modal.css +100 -0
- package/dist/components/Modal/modal.d.ts +48 -0
- package/dist/components/Modal/modal.js +129 -0
- package/dist/components/Progress/Progress.astro +21 -0
- package/dist/components/Progress/helper.d.ts +13 -0
- package/dist/components/Progress/helper.js +32 -0
- package/dist/components/Progress/progress.css +29 -0
- package/dist/components/Progress/progress.d.ts +1 -0
- package/dist/components/Progress/progress.js +10 -0
- package/dist/components/RadioGroup/RadioGroup.astro +124 -0
- package/dist/components/RadioGroup/radiogroup.css +96 -0
- package/dist/components/RadioGroup/radiogroup.d.ts +1 -0
- package/dist/components/RadioGroup/radiogroup.js +48 -0
- package/{src/components → dist/components/Row}/Row.astro +1 -24
- package/dist/components/Row/row.css +18 -0
- package/dist/components/SearchSelect/SearchSelect.astro +135 -0
- package/dist/components/SearchSelect/searchselect.css +95 -0
- package/dist/components/SearchSelect/searchselect.d.ts +6 -0
- package/dist/components/SearchSelect/searchselect.js +166 -0
- package/dist/components/Select/Select.astro +147 -0
- package/dist/components/Select/select.css +110 -0
- package/dist/components/Select/select.d.ts +1 -0
- package/dist/components/Select/select.js +143 -0
- package/dist/components/Sidebar/helpers.d.ts +76 -0
- package/dist/components/Sidebar/helpers.js +160 -0
- package/{src → dist}/components/Tabs/TabItem.astro +3 -3
- package/dist/components/Tabs/Tabs.astro +150 -0
- package/dist/components/Tabs/tabs.css +121 -0
- package/dist/components/Tabs/tabs.d.ts +1 -0
- package/dist/components/Tabs/tabs.js +82 -0
- package/{src/components → dist/components/Textarea}/Textarea.astro +2 -61
- package/dist/components/Textarea/textarea.css +49 -0
- package/dist/components/ThemeToggle/ThemeToggle.astro +21 -0
- package/dist/components/ThemeToggle/themetoggle.css +17 -0
- package/dist/components/ThemeToggle/themetoggle.d.ts +1 -0
- package/dist/components/ThemeToggle/themetoggle.js +4 -0
- package/dist/components/Toast/Toaster.astro +69 -0
- package/dist/components/Toast/toast.d.ts +8 -0
- package/dist/components/Toast/toast.js +9 -0
- package/dist/components/Toast/toaster.css +168 -0
- package/dist/components/Toast/toaster.d.ts +1 -0
- package/dist/components/Toast/toaster.js +160 -0
- package/dist/components/Toggle/Toggle.astro +84 -0
- package/dist/components/Toggle/toggle.css +93 -0
- package/dist/components/Toggle/toggle.d.ts +2 -0
- package/dist/components/Toggle/toggle.js +20 -0
- package/{src/components → dist/components/User}/User.astro +3 -43
- package/dist/components/User/user.css +35 -0
- package/dist/css/colors.css +95 -0
- package/dist/css/global.css +3 -0
- package/dist/css/radii.css +6 -0
- package/dist/css/resets.css +46 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +379 -0
- package/dist/toolbar/ColorPicker.d.ts +7 -0
- package/dist/toolbar/ColorPicker.js +85 -0
- package/dist/toolbar/icon.d.ts +1 -0
- package/dist/toolbar/icon.js +4 -0
- package/dist/toolbar/index.d.ts +2 -0
- package/dist/toolbar/index.js +292 -0
- package/dist/types/index.d.ts +11 -0
- package/dist/types/index.js +0 -0
- package/dist/utils/ThemeHelper.d.ts +49 -0
- package/dist/utils/ThemeHelper.js +113 -0
- package/{src/utils/colors.ts → dist/utils/colors.d.ts} +1 -1
- package/dist/utils/colors.js +0 -0
- package/dist/utils/generateID.d.ts +2 -0
- package/dist/utils/generateID.js +6 -0
- package/dist/utils/headers.d.ts +43 -0
- package/dist/utils/headers.js +129 -0
- package/dist/utils/iconStrings.d.ts +4 -0
- package/dist/utils/iconStrings.js +13 -0
- package/dist/utils/integration-utils.d.ts +130 -0
- package/dist/utils/integration-utils.js +161 -0
- package/package.json +25 -9
- package/src/components/BaseHead.astro +0 -22
- package/src/components/Button.astro +0 -372
- package/src/components/Center.astro +0 -16
- package/src/components/Checkbox.astro +0 -250
- package/src/components/Dropdown/Dropdown.astro +0 -314
- package/src/components/Dropdown/dropdown.ts +0 -258
- package/src/components/Dropdown/index.ts +0 -2
- package/src/components/Footer.astro +0 -137
- package/src/components/Modal/index.ts +0 -2
- package/src/components/Modal/modal.ts +0 -163
- package/src/components/RadioGroup.astro +0 -299
- package/src/components/SearchSelect.astro +0 -486
- package/src/components/Select.astro +0 -467
- package/src/components/Sidebar/helpers.ts +0 -179
- package/src/components/Sidebar/index.ts +0 -3
- package/src/components/Tabs/Tabs.astro +0 -393
- package/src/components/Tabs/index.ts +0 -2
- package/src/components/ThemeToggle.astro +0 -46
- package/src/components/Toast/Toaster.astro +0 -470
- package/src/components/Toast/index.ts +0 -2
- package/src/components/Toast/toast.ts +0 -16
- package/src/components/Toggle.astro +0 -214
- package/src/components/index.ts +0 -27
- package/src/components.ts +0 -26
- package/src/css/colors.css +0 -106
- package/src/css/global.css +0 -2
- package/src/css/resets.css +0 -54
- package/src/env.d.ts +0 -15
- package/src/integration.ts +0 -31
- package/src/layouts/RootLayout.astro +0 -33
- package/src/layouts/index.ts +0 -2
- package/src/layouts.ts +0 -1
- package/src/types/index.ts +0 -11
- package/src/utils/ThemeHelper.ts +0 -145
- package/src/utils/create-resolver.ts +0 -30
- package/src/utils/generateID.ts +0 -5
- package/src/utils/headers.ts +0 -190
- package/src/utils/iconStrings.ts +0 -29
- package/src/utils/index.ts +0 -1
- package/src/utils/virtual-module-plugin-builder.ts +0 -37
- /package/{src → dist}/components/Sidebar/Double.astro +0 -0
- /package/{src → dist}/components/Sidebar/Single.astro +0 -0
- /package/{src → dist}/icons/Checkmark.astro +0 -0
- /package/{src → dist}/icons/ChevronUpDown.astro +0 -0
- /package/{src → dist}/icons/User.astro +0 -0
- /package/{src → dist}/icons/X-Mark.astro +0 -0
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
class ModalHelper {
|
|
2
|
-
private element: HTMLDialogElement;
|
|
3
|
-
private cancelButton: HTMLButtonElement | undefined;
|
|
4
|
-
private confirmButton: HTMLButtonElement | undefined;
|
|
5
|
-
|
|
6
|
-
private isForm = false;
|
|
7
|
-
private modalForm: HTMLFormElement;
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* A helper to manage modals.
|
|
11
|
-
* @param id The ID of the modal.
|
|
12
|
-
* @param triggerID The ID of the element that should trigger the modal.
|
|
13
|
-
*/
|
|
14
|
-
constructor(id: string, triggerID?: string) {
|
|
15
|
-
const element = document.getElementById(id) as HTMLDialogElement;
|
|
16
|
-
|
|
17
|
-
if (!element) {
|
|
18
|
-
throw new Error(`No modal with ID ${id} found.`);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
this.element = element as HTMLDialogElement;
|
|
22
|
-
this.modalForm = document.getElementById(`${id}-form-element`) as HTMLFormElement;
|
|
23
|
-
|
|
24
|
-
const isDismissable = this.element.dataset.dismissable === 'true';
|
|
25
|
-
const isForm = this.element.dataset.form === 'true';
|
|
26
|
-
|
|
27
|
-
if (isDismissable) {
|
|
28
|
-
this.addDismissiveClickListener();
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
if (isForm) this.isForm = true;
|
|
32
|
-
|
|
33
|
-
this.addButtonListeners(id, isDismissable);
|
|
34
|
-
|
|
35
|
-
if (triggerID) {
|
|
36
|
-
this.bindTrigger(triggerID);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* A helper function which adds event listeners to the modal buttons to close the modal when clicked.
|
|
42
|
-
* @param id The ID of the modal.
|
|
43
|
-
* @param dismissable Whether the modal is dismissable.
|
|
44
|
-
*/
|
|
45
|
-
private addButtonListeners = (id: string, dismissable: boolean) => {
|
|
46
|
-
if (
|
|
47
|
-
dismissable ||
|
|
48
|
-
(!this.element.dataset.hasCancelButton && !this.element.dataset.hasActionButton)
|
|
49
|
-
) {
|
|
50
|
-
const xMarkButton = document.getElementById(`${id}-btn-x`) as HTMLButtonElement;
|
|
51
|
-
xMarkButton.addEventListener('click', this.hide);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if (!!this.element.dataset.hasCancelButton && !this.element.dataset.hasActionButton) return;
|
|
55
|
-
|
|
56
|
-
if (this.element.dataset.hasCancelButton) {
|
|
57
|
-
this.cancelButton = document.getElementById(`${id}-btn-cancel`) as HTMLButtonElement;
|
|
58
|
-
this.cancelButton.addEventListener('click', this.hide);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
if (this.element.dataset.hasActionButton) {
|
|
62
|
-
this.confirmButton = document.getElementById(`${id}-btn-confirm`) as HTMLButtonElement;
|
|
63
|
-
this.confirmButton.addEventListener('click', this.hide);
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* A helper function to close the modal when the user clicks outside of it.
|
|
69
|
-
*/
|
|
70
|
-
private addDismissiveClickListener = () => {
|
|
71
|
-
this.element.addEventListener('click', (e: MouseEvent) => {
|
|
72
|
-
if (!e.target) return;
|
|
73
|
-
|
|
74
|
-
const { left, right, top, bottom } = this.element.getBoundingClientRect();
|
|
75
|
-
|
|
76
|
-
const clickWithinModalBox =
|
|
77
|
-
e.clientX < right && e.clientX > left && e.clientY < bottom && e.clientY > top;
|
|
78
|
-
|
|
79
|
-
if (!clickWithinModalBox) {
|
|
80
|
-
this.element.close();
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* A function to show the modal.
|
|
87
|
-
*/
|
|
88
|
-
public show = () => {
|
|
89
|
-
this.element.showModal();
|
|
90
|
-
this.element.focus();
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* A function to hide the modal.
|
|
95
|
-
*/
|
|
96
|
-
public hide = () => {
|
|
97
|
-
this.element.close();
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* A function to add another trigger to show the modal with.
|
|
102
|
-
* @param elementID The ID of the element that should trigger the modal when clicked.
|
|
103
|
-
*/
|
|
104
|
-
public bindTrigger = (elementID: string) => {
|
|
105
|
-
const element = document.getElementById(elementID);
|
|
106
|
-
|
|
107
|
-
if (!element) {
|
|
108
|
-
throw new Error(`No element with ID ${elementID} found.`);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
element.addEventListener('click', this.show);
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Registers a callback for the cancel button.
|
|
116
|
-
* @param func The callback function.
|
|
117
|
-
*/
|
|
118
|
-
public registerCancelCallback = (func: () => void) => {
|
|
119
|
-
if (!this.cancelButton) {
|
|
120
|
-
throw new Error('Unable to register cancel callback without a cancel button.');
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
this.cancelButton.removeEventListener('click', this.hide);
|
|
124
|
-
|
|
125
|
-
this.cancelButton.addEventListener('click', () => {
|
|
126
|
-
func();
|
|
127
|
-
this.hide();
|
|
128
|
-
});
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Registers a callback for the confirm button.
|
|
133
|
-
* @param func The callback function. If the modal is a form, the function will be called with
|
|
134
|
-
* the form data as the first argument.
|
|
135
|
-
*/
|
|
136
|
-
public registerConfirmCallback = (func: (data?: FormData | undefined) => void) => {
|
|
137
|
-
if (!this.confirmButton) {
|
|
138
|
-
throw new Error('Unable to register cancel callback without a confirmation button.');
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
this.confirmButton.removeEventListener('click', this.hide);
|
|
142
|
-
|
|
143
|
-
if (this.isForm) {
|
|
144
|
-
this.modalForm.addEventListener('submit', (e) => {
|
|
145
|
-
e.preventDefault();
|
|
146
|
-
|
|
147
|
-
const formData = new FormData(this.modalForm);
|
|
148
|
-
|
|
149
|
-
func(formData);
|
|
150
|
-
this.hide();
|
|
151
|
-
|
|
152
|
-
setTimeout(() => this.modalForm.reset(), 450);
|
|
153
|
-
});
|
|
154
|
-
} else {
|
|
155
|
-
this.confirmButton.addEventListener('click', () => {
|
|
156
|
-
func();
|
|
157
|
-
this.hide();
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
export { ModalHelper };
|
|
@@ -1,299 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
import type { StudioCMSColorway } from '../utils/colors';
|
|
3
|
-
import { generateID } from '../utils/generateID';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* The props for the RadioGroup component.
|
|
7
|
-
*/
|
|
8
|
-
interface Option {
|
|
9
|
-
/**
|
|
10
|
-
* The label of the option.
|
|
11
|
-
*/
|
|
12
|
-
label: string;
|
|
13
|
-
/**
|
|
14
|
-
* The value of the option.
|
|
15
|
-
*/
|
|
16
|
-
value: string;
|
|
17
|
-
/**
|
|
18
|
-
* Whether the option is disabled.
|
|
19
|
-
*/
|
|
20
|
-
disabled?: boolean;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* The props for the RadioGroup component.
|
|
25
|
-
*/
|
|
26
|
-
interface Props {
|
|
27
|
-
/**
|
|
28
|
-
* The label of the radio group.
|
|
29
|
-
*/
|
|
30
|
-
label: string;
|
|
31
|
-
/**
|
|
32
|
-
* The color of the radio group. Defaults to `default`.
|
|
33
|
-
*/
|
|
34
|
-
color?: StudioCMSColorway;
|
|
35
|
-
/**
|
|
36
|
-
* The default value of the radio group. Needs to be one of the values in the options.
|
|
37
|
-
*/
|
|
38
|
-
defaultValue?: string;
|
|
39
|
-
/**
|
|
40
|
-
* The options to display in the radio group.
|
|
41
|
-
*/
|
|
42
|
-
options: Option[];
|
|
43
|
-
/**
|
|
44
|
-
* Whether the radio group is disabled. Defaults to `false`.
|
|
45
|
-
*/
|
|
46
|
-
disabled?: boolean;
|
|
47
|
-
/**
|
|
48
|
-
* The name of the radio group.
|
|
49
|
-
*/
|
|
50
|
-
name?: string;
|
|
51
|
-
/**
|
|
52
|
-
* Whether the radio group is required. Defaults to `false`.
|
|
53
|
-
*/
|
|
54
|
-
isRequired?: boolean;
|
|
55
|
-
/**
|
|
56
|
-
* Whether the radio group is horizontal. Defaults to `false`.
|
|
57
|
-
*/
|
|
58
|
-
horizontal?: boolean;
|
|
59
|
-
/**
|
|
60
|
-
* Additional classes to apply to the radio group.
|
|
61
|
-
*/
|
|
62
|
-
class?: string;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const {
|
|
66
|
-
label,
|
|
67
|
-
color = 'default',
|
|
68
|
-
defaultValue,
|
|
69
|
-
options,
|
|
70
|
-
disabled = false,
|
|
71
|
-
isRequired = false,
|
|
72
|
-
horizontal = false,
|
|
73
|
-
name = generateID('radio'),
|
|
74
|
-
class: className,
|
|
75
|
-
} = Astro.props;
|
|
76
|
-
---
|
|
77
|
-
|
|
78
|
-
<div
|
|
79
|
-
class="sui-radio-container"
|
|
80
|
-
class:list={[
|
|
81
|
-
disabled && "disabled",
|
|
82
|
-
horizontal && "horizontal",
|
|
83
|
-
color,
|
|
84
|
-
className
|
|
85
|
-
]}
|
|
86
|
-
>
|
|
87
|
-
<span>
|
|
88
|
-
{label} <span class="req-star">{isRequired && "*"}</span>
|
|
89
|
-
</span>
|
|
90
|
-
<div class="sui-radio-inputs" role="radiogroup">
|
|
91
|
-
{options.map(({ label, value, disabled: individuallyDisabled }, i) => (
|
|
92
|
-
<label
|
|
93
|
-
for={value}
|
|
94
|
-
class="sui-radio-label"
|
|
95
|
-
class:list={[ individuallyDisabled && "disabled" ]}
|
|
96
|
-
>
|
|
97
|
-
<div class="sui-radio-box-container">
|
|
98
|
-
<div
|
|
99
|
-
class="sui-radio-box"
|
|
100
|
-
role="radio"
|
|
101
|
-
tabindex={i === 0 ? 0 : -1}
|
|
102
|
-
aria-checked={value === defaultValue}
|
|
103
|
-
aria-label={label}
|
|
104
|
-
/>
|
|
105
|
-
</div>
|
|
106
|
-
<input
|
|
107
|
-
class="sui-radio-toggle"
|
|
108
|
-
type="radio"
|
|
109
|
-
value={value}
|
|
110
|
-
id={value}
|
|
111
|
-
name={name}
|
|
112
|
-
checked={value === defaultValue}
|
|
113
|
-
disabled={disabled || individuallyDisabled}
|
|
114
|
-
required={isRequired}
|
|
115
|
-
/>
|
|
116
|
-
<span>{label}</span>
|
|
117
|
-
</label>
|
|
118
|
-
))}
|
|
119
|
-
</div>
|
|
120
|
-
</div>
|
|
121
|
-
<script>
|
|
122
|
-
const elements = document.querySelectorAll<HTMLDivElement>('.sui-radio-container');
|
|
123
|
-
|
|
124
|
-
for (const element of elements) {
|
|
125
|
-
if (element.dataset.initialized) continue;
|
|
126
|
-
|
|
127
|
-
element.dataset.initialized = 'true';
|
|
128
|
-
|
|
129
|
-
const radioBoxes = element.querySelectorAll<HTMLDivElement>('.sui-radio-box');
|
|
130
|
-
|
|
131
|
-
let i = 0;
|
|
132
|
-
|
|
133
|
-
for (const radioBox of radioBoxes) {
|
|
134
|
-
radioBox.addEventListener('keydown', (e) => {
|
|
135
|
-
if (e.key === 'Enter' || e.key === " ") {
|
|
136
|
-
e.preventDefault();
|
|
137
|
-
|
|
138
|
-
const input = (e.target as HTMLDivElement).parentElement!.parentElement!.querySelector<HTMLInputElement>('.sui-radio-toggle')!;
|
|
139
|
-
|
|
140
|
-
if (input.disabled) return;
|
|
141
|
-
|
|
142
|
-
input.checked = true;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
if (e.key === 'ArrowRight' || e.key === 'ArrowDown') {
|
|
146
|
-
e.preventDefault();
|
|
147
|
-
|
|
148
|
-
let nextRadioBox: HTMLDivElement | undefined;
|
|
149
|
-
|
|
150
|
-
radioBoxes.forEach((box, index) => {
|
|
151
|
-
if (box === radioBox) nextRadioBox = radioBoxes[index + 1];
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
if (!nextRadioBox) return;
|
|
155
|
-
|
|
156
|
-
radioBox.tabIndex = -1;
|
|
157
|
-
nextRadioBox.tabIndex = 0;
|
|
158
|
-
nextRadioBox.focus();
|
|
159
|
-
nextRadioBox.click();
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
if (e.key === 'ArrowLeft' || e.key === 'ArrowUp') {
|
|
163
|
-
e.preventDefault();
|
|
164
|
-
|
|
165
|
-
let previousRadioBox: HTMLDivElement | undefined;
|
|
166
|
-
|
|
167
|
-
radioBoxes.forEach((box, index) => {
|
|
168
|
-
if (box === radioBox) previousRadioBox = radioBoxes[index - 1];
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
if (!previousRadioBox) return;
|
|
172
|
-
|
|
173
|
-
radioBox.tabIndex = -1;
|
|
174
|
-
previousRadioBox.tabIndex = 0;
|
|
175
|
-
previousRadioBox.focus();
|
|
176
|
-
previousRadioBox.click();
|
|
177
|
-
}
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
i++;
|
|
181
|
-
}
|
|
182
|
-
element.addEventListener('keydown', (e) => {
|
|
183
|
-
if (e.key !== 'Enter') return;
|
|
184
|
-
|
|
185
|
-
const checkbox = element.querySelector<HTMLInputElement>('.sui-checkbox');
|
|
186
|
-
|
|
187
|
-
if (!checkbox) return;
|
|
188
|
-
|
|
189
|
-
checkbox.click();
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
</script>
|
|
193
|
-
<style>
|
|
194
|
-
.sui-radio-container {
|
|
195
|
-
display: flex;
|
|
196
|
-
flex-direction: column;
|
|
197
|
-
gap: .5rem;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
.sui-radio-container.disabled {
|
|
201
|
-
opacity: 0.5;
|
|
202
|
-
color: hsl(var(--text-muted));
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
.sui-radio-label.disabled {
|
|
206
|
-
opacity: 0.5;
|
|
207
|
-
color: hsl(var(--text-muted));
|
|
208
|
-
pointer-events: none;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
.req-star {
|
|
212
|
-
color: hsl(var(--danger-base));
|
|
213
|
-
font-weight: 700;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
.sui-radio-inputs {
|
|
217
|
-
display: flex;
|
|
218
|
-
flex-direction: column;
|
|
219
|
-
gap: .75rem;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
.sui-radio-container.horizontal .sui-radio-inputs {
|
|
223
|
-
flex-direction: row;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
.sui-radio-label {
|
|
227
|
-
display: flex;
|
|
228
|
-
flex-direction: row;
|
|
229
|
-
gap: .5rem;
|
|
230
|
-
position: relative;
|
|
231
|
-
align-items: center;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
.sui-radio-label:hover .sui-radio-box {
|
|
235
|
-
outline-color: hsl(var(--default-hover));
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
.sui-radio-container:not(.disabled) .sui-radio-label:active .sui-radio-box {
|
|
239
|
-
outline-color: hsl(var(--default-active));
|
|
240
|
-
scale: 0.9;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
.sui-radio-label:has(.sui-radio-toggle:checked) .sui-radio-box {
|
|
244
|
-
background-color: hsl(var(--text-normal));
|
|
245
|
-
outline-color: hsl(var(--text-normal));
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
.sui-radio-container.primary .sui-radio-label:has(.sui-radio-toggle:checked) .sui-radio-box {
|
|
249
|
-
background-color: hsl(var(--primary-base));
|
|
250
|
-
outline-color: hsl(var(--primary-base));
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
.sui-radio-container.success .sui-radio-label:has(.sui-radio-toggle:checked) .sui-radio-box {
|
|
254
|
-
background-color: hsl(var(--success-base));
|
|
255
|
-
outline-color: hsl(var(--success-base));
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
.sui-radio-container.warning .sui-radio-label:has(.sui-radio-toggle:checked) .sui-radio-box {
|
|
259
|
-
background-color: hsl(var(--warning-base));
|
|
260
|
-
outline-color: hsl(var(--warning-base));
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
.sui-radio-container.danger .sui-radio-label:has(.sui-radio-toggle:checked) .sui-radio-box {
|
|
264
|
-
background-color: hsl(var(--danger-base));
|
|
265
|
-
outline-color: hsl(var(--danger-base));
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
.sui-radio-box-container {
|
|
269
|
-
width: 20px;
|
|
270
|
-
height: 20px;
|
|
271
|
-
display: flex;
|
|
272
|
-
flex-direction: row;
|
|
273
|
-
align-items: center;
|
|
274
|
-
justify-content: center;
|
|
275
|
-
cursor: pointer;
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
.sui-radio-box {
|
|
279
|
-
width: 12px;
|
|
280
|
-
height: 12px;
|
|
281
|
-
border-radius: 20px;
|
|
282
|
-
outline: 1px solid hsl(var(--default-base));
|
|
283
|
-
outline-offset: 4px;
|
|
284
|
-
transition: all .15s ease;
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
.sui-radio-box:focus-visible {
|
|
288
|
-
outline-color: hsl(var(--text-normal)) !important;
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
.sui-radio-toggle {
|
|
292
|
-
width: 0;
|
|
293
|
-
height: 0;
|
|
294
|
-
visibility: hidden;
|
|
295
|
-
opacity: 0;
|
|
296
|
-
margin: 0;
|
|
297
|
-
position: absolute;
|
|
298
|
-
}
|
|
299
|
-
</style>
|