@vinyasa/form 1.0.22
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/README.md +188 -0
- package/dist/cjs/autocomplete.cjs +344 -0
- package/dist/cjs/autocomplete.css +308 -0
- package/dist/cjs/checkbox.cjs +299 -0
- package/dist/cjs/checkbox.css +175 -0
- package/dist/cjs/color-picker.cjs +363 -0
- package/dist/cjs/color-picker.css +248 -0
- package/dist/cjs/combobox.cjs +394 -0
- package/dist/cjs/combobox.css +308 -0
- package/dist/cjs/date-picker.cjs +357 -0
- package/dist/cjs/date-picker.css +295 -0
- package/dist/cjs/dropzone.cjs +438 -0
- package/dist/cjs/dropzone.css +293 -0
- package/dist/cjs/file-upload.cjs +428 -0
- package/dist/cjs/file-upload.css +250 -0
- package/dist/cjs/icon-button.cjs +183 -0
- package/dist/cjs/index.cjs +3780 -0
- package/dist/cjs/index.css +1229 -0
- package/dist/cjs/input.cjs +340 -0
- package/dist/cjs/input.css +139 -0
- package/dist/cjs/multi-select.cjs +436 -0
- package/dist/cjs/multi-select.css +308 -0
- package/dist/cjs/number-input.cjs +458 -0
- package/dist/cjs/number-input.css +250 -0
- package/dist/cjs/otp-input.cjs +355 -0
- package/dist/cjs/otp-input.css +194 -0
- package/dist/cjs/password-input.cjs +368 -0
- package/dist/cjs/password-input.css +139 -0
- package/dist/cjs/radio-group.cjs +301 -0
- package/dist/cjs/radio-group.css +181 -0
- package/dist/cjs/range-slider.cjs +276 -0
- package/dist/cjs/range-slider.css +46 -0
- package/dist/cjs/rich-text-editor.cjs +570 -0
- package/dist/cjs/rich-text-editor.css +213 -0
- package/dist/cjs/search-input.cjs +380 -0
- package/dist/cjs/search-input.css +139 -0
- package/dist/cjs/select.cjs +407 -0
- package/dist/cjs/select.css +213 -0
- package/dist/cjs/slider.cjs +188 -0
- package/dist/cjs/slider.css +46 -0
- package/dist/cjs/switch.cjs +294 -0
- package/dist/cjs/switch.css +183 -0
- package/dist/cjs/tags-input.cjs +348 -0
- package/dist/cjs/tags-input.css +328 -0
- package/dist/cjs/textarea.cjs +361 -0
- package/dist/cjs/textarea.css +139 -0
- package/dist/cjs/time-picker.cjs +408 -0
- package/dist/cjs/time-picker.css +308 -0
- package/dist/cjs/toggle-button.cjs +172 -0
- package/dist/esm/27.css +46 -0
- package/dist/esm/27.js +38 -0
- package/dist/esm/2942.css +111 -0
- package/dist/esm/2942.js +13 -0
- package/dist/esm/2995.css +135 -0
- package/dist/esm/2995.js +117 -0
- package/dist/esm/3876.js +27 -0
- package/dist/esm/4557.js +39 -0
- package/dist/esm/6720.css +164 -0
- package/dist/esm/6720.js +19 -0
- package/dist/esm/autocomplete.d.ts +2 -0
- package/dist/esm/autocomplete.js +95 -0
- package/dist/esm/checkbox.css +36 -0
- package/dist/esm/checkbox.d.ts +2 -0
- package/dist/esm/checkbox.js +38 -0
- package/dist/esm/color-picker.css +109 -0
- package/dist/esm/color-picker.d.ts +2 -0
- package/dist/esm/color-picker.js +130 -0
- package/dist/esm/combobox.d.ts +2 -0
- package/dist/esm/combobox.js +126 -0
- package/dist/esm/components/autocomplete/Autocomplete.d.ts +21 -0
- package/dist/esm/components/autocomplete/index.d.ts +3 -0
- package/dist/esm/components/checkbox/Checkbox.css.d.ts +2 -0
- package/dist/esm/components/checkbox/Checkbox.d.ts +7 -0
- package/dist/esm/components/checkbox/index.d.ts +3 -0
- package/dist/esm/components/color-picker/ColorPicker.css.d.ts +11 -0
- package/dist/esm/components/color-picker/ColorPicker.d.ts +28 -0
- package/dist/esm/components/color-picker/index.d.ts +3 -0
- package/dist/esm/components/combobox/Combobox.d.ts +34 -0
- package/dist/esm/components/combobox/index.d.ts +3 -0
- package/dist/esm/components/date-picker/DatePicker.css.d.ts +18 -0
- package/dist/esm/components/date-picker/DatePicker.d.ts +29 -0
- package/dist/esm/components/date-picker/index.d.ts +3 -0
- package/dist/esm/components/dropzone/Dropzone.css.d.ts +4 -0
- package/dist/esm/components/dropzone/Dropzone.d.ts +20 -0
- package/dist/esm/components/dropzone/index.d.ts +3 -0
- package/dist/esm/components/file-upload/FileUpload.css.d.ts +11 -0
- package/dist/esm/components/file-upload/FileUpload.d.ts +20 -0
- package/dist/esm/components/file-upload/index.d.ts +3 -0
- package/dist/esm/components/icon-button/IconButton.d.ts +8 -0
- package/dist/esm/components/icon-button/index.d.ts +3 -0
- package/dist/esm/components/input/Input.d.ts +11 -0
- package/dist/esm/components/input/index.d.ts +3 -0
- package/dist/esm/components/multi-select/MultiSelect.d.ts +35 -0
- package/dist/esm/components/multi-select/index.d.ts +3 -0
- package/dist/esm/components/number-input/NumberInput.css.d.ts +51 -0
- package/dist/esm/components/number-input/NumberInput.d.ts +13 -0
- package/dist/esm/components/number-input/index.d.ts +3 -0
- package/dist/esm/components/otp-input/OtpInput.css.d.ts +6 -0
- package/dist/esm/components/otp-input/OtpInput.d.ts +16 -0
- package/dist/esm/components/otp-input/index.d.ts +3 -0
- package/dist/esm/components/password-input/PasswordInput.d.ts +11 -0
- package/dist/esm/components/password-input/index.d.ts +3 -0
- package/dist/esm/components/radio-group/RadioGroup.css.d.ts +3 -0
- package/dist/esm/components/radio-group/RadioGroup.d.ts +12 -0
- package/dist/esm/components/radio-group/index.d.ts +3 -0
- package/dist/esm/components/range-slider/RangeSlider.d.ts +11 -0
- package/dist/esm/components/range-slider/index.d.ts +3 -0
- package/dist/esm/components/rich-text-editor/RichTextEditor.css.d.ts +5 -0
- package/dist/esm/components/rich-text-editor/RichTextEditor.d.ts +18 -0
- package/dist/esm/components/rich-text-editor/index.d.ts +3 -0
- package/dist/esm/components/search-input/SearchInput.d.ts +13 -0
- package/dist/esm/components/search-input/index.d.ts +3 -0
- package/dist/esm/components/select/Select.css.d.ts +8 -0
- package/dist/esm/components/select/Select.d.ts +29 -0
- package/dist/esm/components/select/index.d.ts +3 -0
- package/dist/esm/components/slider/Slider.css.d.ts +4 -0
- package/dist/esm/components/slider/Slider.d.ts +12 -0
- package/dist/esm/components/slider/index.d.ts +3 -0
- package/dist/esm/components/switch/Switch.css.d.ts +2 -0
- package/dist/esm/components/switch/Switch.d.ts +7 -0
- package/dist/esm/components/switch/index.d.ts +3 -0
- package/dist/esm/components/tags-input/TagsInput.css.d.ts +1 -0
- package/dist/esm/components/tags-input/TagsInput.d.ts +18 -0
- package/dist/esm/components/tags-input/index.d.ts +3 -0
- package/dist/esm/components/textarea/Textarea.d.ts +13 -0
- package/dist/esm/components/textarea/index.d.ts +3 -0
- package/dist/esm/components/time-picker/TimePicker.d.ts +32 -0
- package/dist/esm/components/time-picker/index.d.ts +3 -0
- package/dist/esm/components/toggle-button/ToggleButton.d.ts +12 -0
- package/dist/esm/components/toggle-button/index.d.ts +3 -0
- package/dist/esm/date-picker.css +153 -0
- package/dist/esm/date-picker.d.ts +2 -0
- package/dist/esm/date-picker.js +118 -0
- package/dist/esm/dropzone.css +43 -0
- package/dist/esm/dropzone.d.ts +2 -0
- package/dist/esm/dropzone.js +137 -0
- package/dist/esm/field.css.d.ts +33 -0
- package/dist/esm/field.d.ts +24 -0
- package/dist/esm/file-upload.d.ts +2 -0
- package/dist/esm/file-upload.js +123 -0
- package/dist/esm/icon-button.d.ts +2 -0
- package/dist/esm/icon-button.js +29 -0
- package/dist/esm/index.d.ts +24 -0
- package/dist/esm/index.js +24 -0
- package/dist/esm/input.d.ts +2 -0
- package/dist/esm/input.js +39 -0
- package/dist/esm/multi-select.d.ts +2 -0
- package/dist/esm/multi-select.js +164 -0
- package/dist/esm/number-input.css +107 -0
- package/dist/esm/number-input.d.ts +2 -0
- package/dist/esm/number-input.js +153 -0
- package/dist/esm/otp-input.css +55 -0
- package/dist/esm/otp-input.d.ts +2 -0
- package/dist/esm/otp-input.js +56 -0
- package/dist/esm/password-input.d.ts +2 -0
- package/dist/esm/password-input.js +56 -0
- package/dist/esm/radio-group.css +42 -0
- package/dist/esm/radio-group.d.ts +2 -0
- package/dist/esm/radio-group.js +44 -0
- package/dist/esm/range-slider.d.ts +2 -0
- package/dist/esm/range-slider.js +22 -0
- package/dist/esm/rich-text-editor.css +74 -0
- package/dist/esm/rich-text-editor.d.ts +2 -0
- package/dist/esm/rich-text-editor.js +212 -0
- package/dist/esm/search-input.d.ts +2 -0
- package/dist/esm/search-input.js +62 -0
- package/dist/esm/select.css +73 -0
- package/dist/esm/select.d.ts +2 -0
- package/dist/esm/select.js +87 -0
- package/dist/esm/selectPopover.css.d.ts +17 -0
- package/dist/esm/slider.d.ts +2 -0
- package/dist/esm/slider.js +4 -0
- package/dist/esm/switch.css +44 -0
- package/dist/esm/switch.d.ts +2 -0
- package/dist/esm/switch.js +36 -0
- package/dist/esm/tags-input.css +16 -0
- package/dist/esm/tags-input.d.ts +2 -0
- package/dist/esm/tags-input.js +100 -0
- package/dist/esm/textarea.d.ts +2 -0
- package/dist/esm/textarea.js +58 -0
- package/dist/esm/time-picker.d.ts +2 -0
- package/dist/esm/time-picker.js +137 -0
- package/dist/esm/toggle-button.d.ts +2 -0
- package/dist/esm/toggle-button.js +4 -0
- package/package.json +255 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import "./date-picker.css";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { CalendarIcon, ChevronLeftIcon, ChevronRightIcon } from "@vinyasa/icons";
|
|
4
|
+
import { format } from "date-fns";
|
|
5
|
+
import { useId, useState } from "react";
|
|
6
|
+
import { DayPicker } from "react-day-picker";
|
|
7
|
+
import { field, describedByIds } from "./4557.js";
|
|
8
|
+
import { fieldControl } from "./2995.js";
|
|
9
|
+
import * as __rspack_external__radix_ui_react_popover_e2827c9f from "@radix-ui/react-popover";
|
|
10
|
+
var content = '_4znv390';
|
|
11
|
+
var day = '_4znv39c';
|
|
12
|
+
var dayButton = '_4znv39d';
|
|
13
|
+
var DatePicker_css_disabled = '_4znv39g';
|
|
14
|
+
var month = '_4znv397';
|
|
15
|
+
var monthCaption = '_4znv398';
|
|
16
|
+
var months = '_4znv396';
|
|
17
|
+
var nav = '_4znv399';
|
|
18
|
+
var navButton = '_4znv39a';
|
|
19
|
+
var outside = '_4znv39f';
|
|
20
|
+
var root = '_4znv395';
|
|
21
|
+
var selected = '_4znv39h';
|
|
22
|
+
var today = '_4znv39e';
|
|
23
|
+
var DatePicker_css_trigger = '_4znv391';
|
|
24
|
+
var triggerIcon = '_4znv394';
|
|
25
|
+
var triggerPlaceholder = '_4znv392';
|
|
26
|
+
var triggerText = '_4znv393';
|
|
27
|
+
var weekday = '_4znv39b';
|
|
28
|
+
const DatePicker = ({ value, defaultValue, onValueChange, placeholder = 'Pick a date', dateFormat = 'PPP', label, description, error, required, size, disabled, trigger, id: idProp })=>{
|
|
29
|
+
const [internalValue, setInternalValue] = useState(defaultValue);
|
|
30
|
+
const isControlled = void 0 !== value;
|
|
31
|
+
const currentValue = isControlled ? value : internalValue;
|
|
32
|
+
const [open, setOpen] = useState(false);
|
|
33
|
+
const generatedId = useId();
|
|
34
|
+
const id = idProp ?? generatedId;
|
|
35
|
+
const handleSelect = (date)=>{
|
|
36
|
+
if (!isControlled) setInternalValue(date);
|
|
37
|
+
onValueChange?.(date);
|
|
38
|
+
setOpen(false);
|
|
39
|
+
};
|
|
40
|
+
return /*#__PURE__*/ jsx(field, {
|
|
41
|
+
id: id,
|
|
42
|
+
label: label,
|
|
43
|
+
description: description,
|
|
44
|
+
error: error,
|
|
45
|
+
required: required,
|
|
46
|
+
children: /*#__PURE__*/ jsxs(__rspack_external__radix_ui_react_popover_e2827c9f.Root, {
|
|
47
|
+
open: open,
|
|
48
|
+
onOpenChange: setOpen,
|
|
49
|
+
children: [
|
|
50
|
+
/*#__PURE__*/ jsx(__rspack_external__radix_ui_react_popover_e2827c9f.Trigger, {
|
|
51
|
+
asChild: true,
|
|
52
|
+
children: trigger ?? /*#__PURE__*/ jsxs("button", {
|
|
53
|
+
type: "button",
|
|
54
|
+
id: id,
|
|
55
|
+
disabled: disabled,
|
|
56
|
+
className: `${fieldControl({
|
|
57
|
+
size,
|
|
58
|
+
invalid: Boolean(error)
|
|
59
|
+
})} ${DatePicker_css_trigger}`,
|
|
60
|
+
"aria-describedby": describedByIds(id, {
|
|
61
|
+
description,
|
|
62
|
+
error
|
|
63
|
+
}),
|
|
64
|
+
children: [
|
|
65
|
+
/*#__PURE__*/ jsx("span", {
|
|
66
|
+
className: currentValue ? triggerText : `${triggerText} ${triggerPlaceholder}`,
|
|
67
|
+
children: currentValue ? format(currentValue, dateFormat) : placeholder
|
|
68
|
+
}),
|
|
69
|
+
/*#__PURE__*/ jsx("span", {
|
|
70
|
+
className: triggerIcon,
|
|
71
|
+
"aria-hidden": "true",
|
|
72
|
+
children: /*#__PURE__*/ jsx(CalendarIcon, {})
|
|
73
|
+
})
|
|
74
|
+
]
|
|
75
|
+
})
|
|
76
|
+
}),
|
|
77
|
+
/*#__PURE__*/ jsx(__rspack_external__radix_ui_react_popover_e2827c9f.Content, {
|
|
78
|
+
className: content,
|
|
79
|
+
align: "start",
|
|
80
|
+
sideOffset: 4,
|
|
81
|
+
onOpenAutoFocus: (event)=>{
|
|
82
|
+
event.preventDefault();
|
|
83
|
+
},
|
|
84
|
+
children: /*#__PURE__*/ jsx(DayPicker, {
|
|
85
|
+
mode: "single",
|
|
86
|
+
selected: currentValue,
|
|
87
|
+
onSelect: handleSelect,
|
|
88
|
+
defaultMonth: currentValue,
|
|
89
|
+
classNames: {
|
|
90
|
+
root: root,
|
|
91
|
+
months: months,
|
|
92
|
+
month: month,
|
|
93
|
+
month_caption: monthCaption,
|
|
94
|
+
nav: nav,
|
|
95
|
+
button_previous: navButton,
|
|
96
|
+
button_next: navButton,
|
|
97
|
+
weekday: weekday,
|
|
98
|
+
day: day,
|
|
99
|
+
day_button: dayButton,
|
|
100
|
+
today: today,
|
|
101
|
+
outside: outside,
|
|
102
|
+
disabled: DatePicker_css_disabled,
|
|
103
|
+
selected: selected
|
|
104
|
+
},
|
|
105
|
+
components: {
|
|
106
|
+
Chevron: ({ orientation })=>'left' === orientation ? /*#__PURE__*/ jsx(ChevronLeftIcon, {}) : /*#__PURE__*/ jsx(ChevronRightIcon, {})
|
|
107
|
+
}
|
|
108
|
+
})
|
|
109
|
+
})
|
|
110
|
+
]
|
|
111
|
+
})
|
|
112
|
+
});
|
|
113
|
+
};
|
|
114
|
+
DatePicker.displayName = 'DatePicker';
|
|
115
|
+
const date_picker_DatePicker = DatePicker;
|
|
116
|
+
const date_picker = date_picker_DatePicker;
|
|
117
|
+
export default date_picker;
|
|
118
|
+
export { date_picker as DatePicker };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
.rnivxt0 {
|
|
2
|
+
justify-content: center;
|
|
3
|
+
align-items: center;
|
|
4
|
+
gap: var(--vinyasa-space2);
|
|
5
|
+
width: 100%;
|
|
6
|
+
padding: var(--vinyasa-space6);
|
|
7
|
+
border: 2px dashed var(--vinyasa-border-color-default);
|
|
8
|
+
border-radius: var(--vinyasa-radius-md);
|
|
9
|
+
color: var(--vinyasa-text-muted);
|
|
10
|
+
font-family: var(--vinyasa-font-family-sans);
|
|
11
|
+
font-size: var(--vinyasa-font-size-sm);
|
|
12
|
+
text-align: center;
|
|
13
|
+
cursor: pointer;
|
|
14
|
+
transition: border-color var(--vinyasa-motion-duration-fast) var(--vinyasa-motion-easing-standard), background-color var(--vinyasa-motion-duration-fast) var(--vinyasa-motion-easing-standard);
|
|
15
|
+
background-color: #0000;
|
|
16
|
+
flex-direction: column;
|
|
17
|
+
display: flex;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.rnivxt0:focus-visible {
|
|
21
|
+
border-color: var(--vinyasa-focus);
|
|
22
|
+
box-shadow: 0 0 0 1px var(--vinyasa-focus), 0 0 0 4px color-mix(in srgb, var(--vinyasa-focus) 16%, transparent);
|
|
23
|
+
outline: none;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.rnivxt0[data-disabled="true"] {
|
|
27
|
+
opacity: var(--vinyasa-opacity-disabled);
|
|
28
|
+
cursor: not-allowed;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.rnivxt1 {
|
|
32
|
+
border-color: var(--vinyasa-focus);
|
|
33
|
+
background-color: var(--vinyasa-secondary);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.rnivxt2 {
|
|
37
|
+
font-size: 1.5rem;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.rnivxt3 {
|
|
41
|
+
font-size: var(--vinyasa-font-size-xs);
|
|
42
|
+
}
|
|
43
|
+
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import "./dropzone.css";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { PaperclipIcon, UploadIcon, XIcon } from "@vinyasa/icons";
|
|
4
|
+
import { useId, useState } from "react";
|
|
5
|
+
import { useDropzone } from "react-dropzone";
|
|
6
|
+
import { field, describedByIds } from "./4557.js";
|
|
7
|
+
import { fileName, rejectionText, fileRemove, fileSize, fileNameIcon, fileList, fileRow, fileNameText, fileMeta, fileListWrapper } from "./2942.js";
|
|
8
|
+
var Dropzone_css_area = 'rnivxt0';
|
|
9
|
+
var areaActive = 'rnivxt1';
|
|
10
|
+
var hint = 'rnivxt3';
|
|
11
|
+
var icon = 'rnivxt2';
|
|
12
|
+
const formatFileSize = (bytes)=>{
|
|
13
|
+
if (bytes < 1024) return `${String(bytes)} B`;
|
|
14
|
+
if (bytes < 1048576) return `${(bytes / 1024).toFixed(1)} KB`;
|
|
15
|
+
return `${(bytes / 1048576).toFixed(1)} MB`;
|
|
16
|
+
};
|
|
17
|
+
const Dropzone = ({ value, onValueChange, accept, maxFiles, maxSize, label, description, error, required, disabled, id: idProp })=>{
|
|
18
|
+
const [internalFiles, setInternalFiles] = useState([]);
|
|
19
|
+
const isControlled = void 0 !== value;
|
|
20
|
+
const currentFiles = isControlled ? value : internalFiles;
|
|
21
|
+
const [rejectionMessage, setRejectionMessage] = useState();
|
|
22
|
+
const generatedId = useId();
|
|
23
|
+
const id = idProp ?? generatedId;
|
|
24
|
+
const setFiles = (next)=>{
|
|
25
|
+
if (!isControlled) setInternalFiles(next);
|
|
26
|
+
onValueChange?.(next);
|
|
27
|
+
};
|
|
28
|
+
const removeFile = (file)=>{
|
|
29
|
+
setFiles(currentFiles.filter((entry)=>entry !== file));
|
|
30
|
+
};
|
|
31
|
+
const { getRootProps, getInputProps, isDragActive } = useDropzone({
|
|
32
|
+
accept,
|
|
33
|
+
maxFiles,
|
|
34
|
+
maxSize,
|
|
35
|
+
disabled,
|
|
36
|
+
onDrop: (acceptedFiles, fileRejections)=>{
|
|
37
|
+
fileRejections.length > 0 ? setRejectionMessage(fileRejections[0]?.errors[0]?.message) : setRejectionMessage(void 0);
|
|
38
|
+
if (acceptedFiles.length > 0) setFiles([
|
|
39
|
+
...currentFiles,
|
|
40
|
+
...acceptedFiles
|
|
41
|
+
]);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
return /*#__PURE__*/ jsxs(field, {
|
|
45
|
+
id: id,
|
|
46
|
+
label: label,
|
|
47
|
+
description: description,
|
|
48
|
+
error: error,
|
|
49
|
+
required: required,
|
|
50
|
+
children: [
|
|
51
|
+
/*#__PURE__*/ jsxs("div", {
|
|
52
|
+
...getRootProps({
|
|
53
|
+
id,
|
|
54
|
+
'data-disabled': disabled
|
|
55
|
+
}),
|
|
56
|
+
className: isDragActive ? `${Dropzone_css_area} ${areaActive}` : Dropzone_css_area,
|
|
57
|
+
"aria-describedby": describedByIds(id, {
|
|
58
|
+
description,
|
|
59
|
+
error
|
|
60
|
+
}),
|
|
61
|
+
children: [
|
|
62
|
+
/*#__PURE__*/ jsx("input", {
|
|
63
|
+
...getInputProps()
|
|
64
|
+
}),
|
|
65
|
+
/*#__PURE__*/ jsx("span", {
|
|
66
|
+
className: icon,
|
|
67
|
+
"aria-hidden": "true",
|
|
68
|
+
children: /*#__PURE__*/ jsx(UploadIcon, {})
|
|
69
|
+
}),
|
|
70
|
+
/*#__PURE__*/ jsx("span", {
|
|
71
|
+
children: isDragActive ? 'Drop the files here…' : 'Drag files here, or click to browse'
|
|
72
|
+
}),
|
|
73
|
+
maxSize ? /*#__PURE__*/ jsxs("span", {
|
|
74
|
+
className: hint,
|
|
75
|
+
children: [
|
|
76
|
+
"Up to ",
|
|
77
|
+
formatFileSize(maxSize),
|
|
78
|
+
" per file"
|
|
79
|
+
]
|
|
80
|
+
}) : null
|
|
81
|
+
]
|
|
82
|
+
}),
|
|
83
|
+
rejectionMessage ? /*#__PURE__*/ jsx("p", {
|
|
84
|
+
className: rejectionText,
|
|
85
|
+
children: rejectionMessage
|
|
86
|
+
}) : null,
|
|
87
|
+
currentFiles.length > 0 ? /*#__PURE__*/ jsx("div", {
|
|
88
|
+
className: fileListWrapper,
|
|
89
|
+
children: /*#__PURE__*/ jsx("ul", {
|
|
90
|
+
className: fileList,
|
|
91
|
+
children: currentFiles.map((file)=>/*#__PURE__*/ jsxs("li", {
|
|
92
|
+
className: fileRow,
|
|
93
|
+
children: [
|
|
94
|
+
/*#__PURE__*/ jsxs("span", {
|
|
95
|
+
className: fileName,
|
|
96
|
+
children: [
|
|
97
|
+
/*#__PURE__*/ jsx(PaperclipIcon, {
|
|
98
|
+
"aria-hidden": "true",
|
|
99
|
+
className: fileNameIcon
|
|
100
|
+
}),
|
|
101
|
+
/*#__PURE__*/ jsx("span", {
|
|
102
|
+
className: fileNameText,
|
|
103
|
+
title: file.name,
|
|
104
|
+
children: file.name
|
|
105
|
+
})
|
|
106
|
+
]
|
|
107
|
+
}),
|
|
108
|
+
/*#__PURE__*/ jsxs("span", {
|
|
109
|
+
className: fileMeta,
|
|
110
|
+
children: [
|
|
111
|
+
/*#__PURE__*/ jsx("span", {
|
|
112
|
+
className: fileSize,
|
|
113
|
+
children: formatFileSize(file.size)
|
|
114
|
+
}),
|
|
115
|
+
/*#__PURE__*/ jsx("button", {
|
|
116
|
+
type: "button",
|
|
117
|
+
className: fileRemove,
|
|
118
|
+
"aria-label": `Remove ${file.name}`,
|
|
119
|
+
onClick: ()=>{
|
|
120
|
+
removeFile(file);
|
|
121
|
+
},
|
|
122
|
+
children: /*#__PURE__*/ jsx(XIcon, {})
|
|
123
|
+
})
|
|
124
|
+
]
|
|
125
|
+
})
|
|
126
|
+
]
|
|
127
|
+
}, `${file.name}-${String(file.lastModified)}`))
|
|
128
|
+
})
|
|
129
|
+
}) : null
|
|
130
|
+
]
|
|
131
|
+
});
|
|
132
|
+
};
|
|
133
|
+
Dropzone.displayName = 'Dropzone';
|
|
134
|
+
const dropzone_Dropzone = Dropzone;
|
|
135
|
+
const dropzone = dropzone_Dropzone;
|
|
136
|
+
export default dropzone;
|
|
137
|
+
export { dropzone as Dropzone };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export declare const fieldControl: import("@vanilla-extract/recipes").RuntimeFn<{
|
|
2
|
+
size: {
|
|
3
|
+
sm: {
|
|
4
|
+
padding: `var(--${string}) var(--${string})`;
|
|
5
|
+
fontSize: `var(--${string})`;
|
|
6
|
+
};
|
|
7
|
+
md: {
|
|
8
|
+
padding: `var(--${string}) var(--${string})`;
|
|
9
|
+
fontSize: `var(--${string})`;
|
|
10
|
+
};
|
|
11
|
+
lg: {
|
|
12
|
+
padding: `var(--${string}) var(--${string})`;
|
|
13
|
+
fontSize: `var(--${string})`;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
invalid: {
|
|
17
|
+
true: {
|
|
18
|
+
borderColor: `var(--${string})`;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
}>;
|
|
22
|
+
export declare const fieldGroup: string;
|
|
23
|
+
export declare const fieldIconLeading: string;
|
|
24
|
+
export declare const fieldIconTrailing: string;
|
|
25
|
+
export declare const fieldControlWithLeadingIcon: string;
|
|
26
|
+
export declare const fieldControlWithTrailingIcon: string;
|
|
27
|
+
export declare const fieldIconButton: string;
|
|
28
|
+
export declare const label: string;
|
|
29
|
+
export declare const requiredMark: string;
|
|
30
|
+
export declare const descriptionText: string;
|
|
31
|
+
export declare const errorText: string;
|
|
32
|
+
export declare const controlRow: string;
|
|
33
|
+
export declare const controlLabel: string;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
export interface FieldChromeProps {
|
|
3
|
+
id: string;
|
|
4
|
+
label?: ReactNode;
|
|
5
|
+
description?: ReactNode;
|
|
6
|
+
error?: ReactNode;
|
|
7
|
+
required?: boolean;
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
/**
|
|
10
|
+
* Omits `htmlFor` on the label — for a control whose real interactive
|
|
11
|
+
* element doesn't actually carry `id` (e.g. Combobox/Autocomplete, where
|
|
12
|
+
* cmdk's Command.Input always overwrites `id` with its own internally
|
|
13
|
+
* generated one). A `htmlFor` pointing at a nonexistent id wouldn't just
|
|
14
|
+
* be inert — clicking that label would silently fail to focus anything,
|
|
15
|
+
* for real users too, not only in tests.
|
|
16
|
+
*/
|
|
17
|
+
disableLabelFor?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export declare const describedByIds: (id: string, { description, error }: {
|
|
20
|
+
description?: ReactNode;
|
|
21
|
+
error?: ReactNode;
|
|
22
|
+
}) => string | undefined;
|
|
23
|
+
declare const FieldChrome: ({ id, label, description, error, required, children, disableLabelFor, }: FieldChromeProps) => import("react").JSX.Element;
|
|
24
|
+
export default FieldChrome;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { PaperclipIcon, UploadIcon, XIcon } from "@vinyasa/icons";
|
|
3
|
+
import { useId, useState } from "react";
|
|
4
|
+
import { useDropzone } from "react-dropzone";
|
|
5
|
+
import { field, describedByIds } from "./4557.js";
|
|
6
|
+
import { fileName, rejectionText, fileRemove, fileSize, fileNameIcon, fileList, fileRow, trigger, fileNameText, fileMeta, fileListWrapper } from "./2942.js";
|
|
7
|
+
const formatFileSize = (bytes)=>{
|
|
8
|
+
if (bytes < 1024) return `${String(bytes)} B`;
|
|
9
|
+
if (bytes < 1048576) return `${(bytes / 1024).toFixed(1)} KB`;
|
|
10
|
+
return `${(bytes / 1048576).toFixed(1)} MB`;
|
|
11
|
+
};
|
|
12
|
+
const FileUpload = ({ value, onValueChange, accept, maxFiles, maxSize, label, description, error, required, disabled, id: idProp })=>{
|
|
13
|
+
const [internalFiles, setInternalFiles] = useState([]);
|
|
14
|
+
const isControlled = void 0 !== value;
|
|
15
|
+
const currentFiles = isControlled ? value : internalFiles;
|
|
16
|
+
const [rejectionMessage, setRejectionMessage] = useState();
|
|
17
|
+
const generatedId = useId();
|
|
18
|
+
const id = idProp ?? generatedId;
|
|
19
|
+
const setFiles = (next)=>{
|
|
20
|
+
if (!isControlled) setInternalFiles(next);
|
|
21
|
+
onValueChange?.(next);
|
|
22
|
+
};
|
|
23
|
+
const removeFile = (file)=>{
|
|
24
|
+
setFiles(currentFiles.filter((entry)=>entry !== file));
|
|
25
|
+
};
|
|
26
|
+
const { getRootProps, getInputProps } = useDropzone({
|
|
27
|
+
accept,
|
|
28
|
+
maxFiles,
|
|
29
|
+
maxSize,
|
|
30
|
+
disabled,
|
|
31
|
+
onDrop: (acceptedFiles, fileRejections)=>{
|
|
32
|
+
fileRejections.length > 0 ? setRejectionMessage(fileRejections[0]?.errors[0]?.message) : setRejectionMessage(void 0);
|
|
33
|
+
if (acceptedFiles.length > 0) setFiles([
|
|
34
|
+
...currentFiles,
|
|
35
|
+
...acceptedFiles
|
|
36
|
+
]);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
return /*#__PURE__*/ jsxs(field, {
|
|
40
|
+
id: id,
|
|
41
|
+
label: label,
|
|
42
|
+
description: description,
|
|
43
|
+
error: error,
|
|
44
|
+
required: required,
|
|
45
|
+
children: [
|
|
46
|
+
/*#__PURE__*/ jsxs("button", {
|
|
47
|
+
type: "button",
|
|
48
|
+
...getRootProps({
|
|
49
|
+
id,
|
|
50
|
+
role: 'button',
|
|
51
|
+
'data-disabled': disabled,
|
|
52
|
+
disabled
|
|
53
|
+
}),
|
|
54
|
+
className: trigger,
|
|
55
|
+
"aria-describedby": describedByIds(id, {
|
|
56
|
+
description,
|
|
57
|
+
error
|
|
58
|
+
}),
|
|
59
|
+
children: [
|
|
60
|
+
/*#__PURE__*/ jsx("input", {
|
|
61
|
+
...getInputProps()
|
|
62
|
+
}),
|
|
63
|
+
/*#__PURE__*/ jsx(UploadIcon, {
|
|
64
|
+
"aria-hidden": "true"
|
|
65
|
+
}),
|
|
66
|
+
"Choose files"
|
|
67
|
+
]
|
|
68
|
+
}),
|
|
69
|
+
rejectionMessage ? /*#__PURE__*/ jsx("p", {
|
|
70
|
+
className: rejectionText,
|
|
71
|
+
children: rejectionMessage
|
|
72
|
+
}) : null,
|
|
73
|
+
currentFiles.length > 0 ? /*#__PURE__*/ jsx("div", {
|
|
74
|
+
className: fileListWrapper,
|
|
75
|
+
children: /*#__PURE__*/ jsx("ul", {
|
|
76
|
+
className: fileList,
|
|
77
|
+
children: currentFiles.map((file)=>/*#__PURE__*/ jsxs("li", {
|
|
78
|
+
className: fileRow,
|
|
79
|
+
children: [
|
|
80
|
+
/*#__PURE__*/ jsxs("span", {
|
|
81
|
+
className: fileName,
|
|
82
|
+
children: [
|
|
83
|
+
/*#__PURE__*/ jsx(PaperclipIcon, {
|
|
84
|
+
"aria-hidden": "true",
|
|
85
|
+
className: fileNameIcon
|
|
86
|
+
}),
|
|
87
|
+
/*#__PURE__*/ jsx("span", {
|
|
88
|
+
className: fileNameText,
|
|
89
|
+
title: file.name,
|
|
90
|
+
children: file.name
|
|
91
|
+
})
|
|
92
|
+
]
|
|
93
|
+
}),
|
|
94
|
+
/*#__PURE__*/ jsxs("span", {
|
|
95
|
+
className: fileMeta,
|
|
96
|
+
children: [
|
|
97
|
+
/*#__PURE__*/ jsx("span", {
|
|
98
|
+
className: fileSize,
|
|
99
|
+
children: formatFileSize(file.size)
|
|
100
|
+
}),
|
|
101
|
+
/*#__PURE__*/ jsx("button", {
|
|
102
|
+
type: "button",
|
|
103
|
+
className: fileRemove,
|
|
104
|
+
"aria-label": `Remove ${file.name}`,
|
|
105
|
+
onClick: ()=>{
|
|
106
|
+
removeFile(file);
|
|
107
|
+
},
|
|
108
|
+
children: /*#__PURE__*/ jsx(XIcon, {})
|
|
109
|
+
})
|
|
110
|
+
]
|
|
111
|
+
})
|
|
112
|
+
]
|
|
113
|
+
}, `${file.name}-${String(file.lastModified)}`))
|
|
114
|
+
})
|
|
115
|
+
}) : null
|
|
116
|
+
]
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
FileUpload.displayName = 'FileUpload';
|
|
120
|
+
const file_upload_FileUpload = FileUpload;
|
|
121
|
+
const file_upload = file_upload_FileUpload;
|
|
122
|
+
export default file_upload;
|
|
123
|
+
export { file_upload as FileUpload };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import _vinyasa_button from "@vinyasa/button";
|
|
3
|
+
import { forwardRef } from "react";
|
|
4
|
+
const dimensionBySize = {
|
|
5
|
+
sm: '2rem',
|
|
6
|
+
md: '2.5rem',
|
|
7
|
+
lg: '3rem'
|
|
8
|
+
};
|
|
9
|
+
const IconButton = /*#__PURE__*/ forwardRef(({ icon, size = 'md', style, ...rest }, ref)=>{
|
|
10
|
+
const dimension = dimensionBySize[size];
|
|
11
|
+
const squareStyle = {
|
|
12
|
+
padding: 0,
|
|
13
|
+
width: dimension,
|
|
14
|
+
height: dimension,
|
|
15
|
+
...style
|
|
16
|
+
};
|
|
17
|
+
return /*#__PURE__*/ jsx(_vinyasa_button, {
|
|
18
|
+
ref: ref,
|
|
19
|
+
size: size,
|
|
20
|
+
style: squareStyle,
|
|
21
|
+
...rest,
|
|
22
|
+
children: icon
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
IconButton.displayName = 'IconButton';
|
|
26
|
+
const icon_button_IconButton = IconButton;
|
|
27
|
+
const icon_button = icon_button_IconButton;
|
|
28
|
+
export default icon_button;
|
|
29
|
+
export { icon_button as IconButton };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export { default as Autocomplete, type AutocompleteProps } from './components/autocomplete';
|
|
2
|
+
export { default as Checkbox, type CheckboxProps } from './components/checkbox';
|
|
3
|
+
export { default as ColorPicker, type ColorPickerProps } from './components/color-picker';
|
|
4
|
+
export { default as Combobox, type ComboboxOption, type ComboboxProps, } from './components/combobox';
|
|
5
|
+
export { default as DatePicker, type DatePickerProps } from './components/date-picker';
|
|
6
|
+
export { default as Dropzone, type DropzoneProps } from './components/dropzone';
|
|
7
|
+
export { default as FileUpload, type FileUploadProps } from './components/file-upload';
|
|
8
|
+
export { default as IconButton, type IconButtonProps } from './components/icon-button';
|
|
9
|
+
export { default as Input, type InputProps, type InputSize } from './components/input';
|
|
10
|
+
export { default as MultiSelect, type MultiSelectOption, type MultiSelectProps, } from './components/multi-select';
|
|
11
|
+
export { default as NumberInput, type NumberInputProps, type NumberInputSize, } from './components/number-input';
|
|
12
|
+
export { default as OtpInput, type OtpInputProps } from './components/otp-input';
|
|
13
|
+
export { default as PasswordInput, type PasswordInputProps, type PasswordInputSize, } from './components/password-input';
|
|
14
|
+
export { default as RadioGroup, type RadioGroupProps, type RadioOption, } from './components/radio-group';
|
|
15
|
+
export { default as RangeSlider, type RangeSliderProps } from './components/range-slider';
|
|
16
|
+
export { default as RichTextEditor, type RichTextEditorProps } from './components/rich-text-editor';
|
|
17
|
+
export { default as SearchInput, type SearchInputProps, type SearchInputSize, } from './components/search-input';
|
|
18
|
+
export { default as Select, type SelectOption, type SelectProps } from './components/select';
|
|
19
|
+
export { default as Slider, type SliderProps } from './components/slider';
|
|
20
|
+
export { default as Switch, type SwitchProps } from './components/switch';
|
|
21
|
+
export { default as TagsInput, type TagsInputProps } from './components/tags-input';
|
|
22
|
+
export { default as Textarea, type TextareaProps, type TextareaSize } from './components/textarea';
|
|
23
|
+
export { default as TimePicker, type TimePickerProps } from './components/time-picker';
|
|
24
|
+
export { default as ToggleButton, type ToggleButtonProps } from './components/toggle-button';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export { Autocomplete } from "./autocomplete.js";
|
|
2
|
+
export { Checkbox } from "./checkbox.js";
|
|
3
|
+
export { ColorPicker } from "./color-picker.js";
|
|
4
|
+
export { Combobox } from "./combobox.js";
|
|
5
|
+
export { DatePicker } from "./date-picker.js";
|
|
6
|
+
export { Dropzone } from "./dropzone.js";
|
|
7
|
+
export { FileUpload } from "./file-upload.js";
|
|
8
|
+
export { IconButton } from "./icon-button.js";
|
|
9
|
+
export { Input } from "./input.js";
|
|
10
|
+
export { MultiSelect } from "./multi-select.js";
|
|
11
|
+
export { NumberInput } from "./number-input.js";
|
|
12
|
+
export { OtpInput } from "./otp-input.js";
|
|
13
|
+
export { PasswordInput } from "./password-input.js";
|
|
14
|
+
export { RadioGroup } from "./radio-group.js";
|
|
15
|
+
export { RangeSlider } from "./range-slider.js";
|
|
16
|
+
export { RichTextEditor } from "./rich-text-editor.js";
|
|
17
|
+
export { SearchInput } from "./search-input.js";
|
|
18
|
+
export { Select } from "./select.js";
|
|
19
|
+
export { Slider } from "./slider.js";
|
|
20
|
+
export { Switch } from "./switch.js";
|
|
21
|
+
export { TagsInput } from "./tags-input.js";
|
|
22
|
+
export { Textarea } from "./textarea.js";
|
|
23
|
+
export { TimePicker } from "./time-picker.js";
|
|
24
|
+
export { ToggleButton } from "./toggle-button.js";
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useId } from "react";
|
|
3
|
+
import { fieldControl } from "./2995.js";
|
|
4
|
+
import { field, describedByIds } from "./4557.js";
|
|
5
|
+
const Input = /*#__PURE__*/ forwardRef(({ label, description, error, required, size, id: idProp, className, ...rest }, ref)=>{
|
|
6
|
+
const generatedId = useId();
|
|
7
|
+
const id = idProp ?? generatedId;
|
|
8
|
+
const classes = className ? `${fieldControl({
|
|
9
|
+
size,
|
|
10
|
+
invalid: Boolean(error)
|
|
11
|
+
})} ${className}` : fieldControl({
|
|
12
|
+
size,
|
|
13
|
+
invalid: Boolean(error)
|
|
14
|
+
});
|
|
15
|
+
return /*#__PURE__*/ jsx(field, {
|
|
16
|
+
id: id,
|
|
17
|
+
label: label,
|
|
18
|
+
description: description,
|
|
19
|
+
error: error,
|
|
20
|
+
required: required,
|
|
21
|
+
children: /*#__PURE__*/ jsx("input", {
|
|
22
|
+
ref: ref,
|
|
23
|
+
id: id,
|
|
24
|
+
className: classes,
|
|
25
|
+
required: required,
|
|
26
|
+
"aria-invalid": error ? true : void 0,
|
|
27
|
+
"aria-describedby": describedByIds(id, {
|
|
28
|
+
description,
|
|
29
|
+
error
|
|
30
|
+
}),
|
|
31
|
+
...rest
|
|
32
|
+
})
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
Input.displayName = 'Input';
|
|
36
|
+
const input_Input = Input;
|
|
37
|
+
const input = input_Input;
|
|
38
|
+
export default input;
|
|
39
|
+
export { input as Input };
|