@sikka/hawa 0.0.248 → 0.0.249
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/styles.css +8 -3
- package/es/elements/DragDropImages.d.ts +5 -4
- package/es/index.es.js +3 -58
- package/lib/elements/DragDropImages.d.ts +5 -4
- package/lib/index.js +3 -58
- package/package.json +5 -1
- package/src/elements/DragDropImages.tsx +28 -11
- package/src/elements/HawaAlert.tsx +6 -3
- package/src/styles.css +8 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sikka/hawa",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.249",
|
|
4
4
|
"description": "SaaS Oriented UI Kit",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.es.js",
|
|
@@ -81,6 +81,10 @@
|
|
|
81
81
|
"webpack": "^5.75.0",
|
|
82
82
|
"tailwindcss": "^3.3.3"
|
|
83
83
|
},
|
|
84
|
+
"peerDependencies": {
|
|
85
|
+
"react-dom": ">=17.0.1",
|
|
86
|
+
"react": ">=17.0.1"
|
|
87
|
+
},
|
|
84
88
|
"resolutions": {
|
|
85
89
|
"@storybook/react/webpack": "^5",
|
|
86
90
|
"@storybook/core-common/webpack": "^5",
|
|
@@ -2,6 +2,8 @@ import React, { useEffect, useState } from "react"
|
|
|
2
2
|
import { useDropzone } from "react-dropzone"
|
|
3
3
|
import { HawaAlert } from "./HawaAlert"
|
|
4
4
|
import { HawaButton } from "./HawaButton"
|
|
5
|
+
import { TbDragDrop } from "react-icons/tb"
|
|
6
|
+
import clsx from "clsx"
|
|
5
7
|
//TODO: This element needs more improvements and testing
|
|
6
8
|
type DragDropImagesTypes = {
|
|
7
9
|
/** The text label above the component. Consistant with the other form input fields */
|
|
@@ -19,10 +21,11 @@ type DragDropImagesTypes = {
|
|
|
19
21
|
errorMessages: string
|
|
20
22
|
/** The translation object, use this to replace the default text with any translated text you want.*/
|
|
21
23
|
texts: {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
errorUploading: any
|
|
25
|
+
clickHereToUpload: any
|
|
26
|
+
maxFileSize: any
|
|
27
|
+
tooManyFiles: any
|
|
28
|
+
fileTooLarge: any
|
|
26
29
|
}
|
|
27
30
|
}
|
|
28
31
|
|
|
@@ -102,7 +105,7 @@ export const DragDropImages: React.FunctionComponent<DragDropImagesTypes> = ({
|
|
|
102
105
|
)
|
|
103
106
|
})
|
|
104
107
|
const thumbs = files?.map((file: any, index: any) => (
|
|
105
|
-
<div className="relative m-3 rounded
|
|
108
|
+
<div className="relative m-3 rounded ">
|
|
106
109
|
<button
|
|
107
110
|
onClick={(e) => {
|
|
108
111
|
e.stopPropagation()
|
|
@@ -158,11 +161,17 @@ export const DragDropImages: React.FunctionComponent<DragDropImagesTypes> = ({
|
|
|
158
161
|
)}
|
|
159
162
|
<div
|
|
160
163
|
{...getRootProps({})}
|
|
161
|
-
className=
|
|
164
|
+
className={clsx(
|
|
165
|
+
"flex flex-col justify-center rounded border border-dashed border-black transition-all hover:bg-gray-100 ",
|
|
166
|
+
isDragActive ? "bg-layoutPrimary-500" : "bg-white"
|
|
167
|
+
)}
|
|
162
168
|
>
|
|
163
169
|
<input {...getInputProps()} />
|
|
164
|
-
<div className="pt-4 text-center">
|
|
165
|
-
|
|
170
|
+
<div className="flex flex-col items-center justify-center gap-2 pt-4 text-center">
|
|
171
|
+
<TbDragDrop size={22} />
|
|
172
|
+
{<texts.clickHereToUpload />}
|
|
173
|
+
</div>
|
|
174
|
+
<div className="py-4 text-center text-xs">
|
|
166
175
|
{texts.maxFileSize} {max}
|
|
167
176
|
</div>
|
|
168
177
|
<div className="flex justify-center ">
|
|
@@ -190,11 +199,19 @@ export const DragDropImages: React.FunctionComponent<DragDropImagesTypes> = ({
|
|
|
190
199
|
{thumbs}
|
|
191
200
|
</aside>
|
|
192
201
|
) : null}
|
|
193
|
-
<div className="px-
|
|
202
|
+
<div className="px-4">
|
|
194
203
|
{fileRejections[0]?.errors[0]?.code === "too-many-files" ? (
|
|
195
|
-
<HawaAlert
|
|
204
|
+
<HawaAlert
|
|
205
|
+
title={texts.errorUploading}
|
|
206
|
+
text={texts.tooManyFiles}
|
|
207
|
+
severity="error"
|
|
208
|
+
/>
|
|
196
209
|
) : fileRejections[0]?.errors[0]?.code === "file-too-large" ? (
|
|
197
|
-
<HawaAlert
|
|
210
|
+
<HawaAlert
|
|
211
|
+
title={texts.errorUploading}
|
|
212
|
+
text={texts.fileTooLarge}
|
|
213
|
+
severity="error"
|
|
214
|
+
/>
|
|
198
215
|
) : (
|
|
199
216
|
errs
|
|
200
217
|
)}
|
|
@@ -105,7 +105,7 @@ export const HawaAlert: React.FunctionComponent<AlertTypes> = ({
|
|
|
105
105
|
<div ref={alertRef}>
|
|
106
106
|
<div
|
|
107
107
|
className={clsx(
|
|
108
|
-
"mb-4 flex flex-col rounded p-4 text-sm",
|
|
108
|
+
"relative mb-4 flex flex-col rounded p-4 text-sm transition-all",
|
|
109
109
|
styleVariant[variant][props.severity],
|
|
110
110
|
closed ? "opacity-0" : "opacity-100"
|
|
111
111
|
)}
|
|
@@ -114,6 +114,7 @@ export const HawaAlert: React.FunctionComponent<AlertTypes> = ({
|
|
|
114
114
|
>
|
|
115
115
|
<span className="font-medium">{props.title}</span>
|
|
116
116
|
<span>{" " + props.text}</span>
|
|
117
|
+
|
|
117
118
|
{props.actions && (
|
|
118
119
|
<div className="mt-2 flex flex-row gap-2">
|
|
119
120
|
{props.actions.map((act, index) => (
|
|
@@ -130,12 +131,14 @@ export const HawaAlert: React.FunctionComponent<AlertTypes> = ({
|
|
|
130
131
|
)}
|
|
131
132
|
<button
|
|
132
133
|
type="button"
|
|
133
|
-
className="absolute right-
|
|
134
|
+
className="absolute right-4 top-4 inline-flex h-8 w-8 translate-y-1 rounded p-1.5 text-gray-400 hover:bg-gray-100 hover:text-gray-900 focus:ring-2 focus:ring-gray-300 dark:bg-gray-800 dark:text-gray-500 dark:hover:bg-gray-700 dark:hover:text-white"
|
|
134
135
|
data-dismiss-target="#alert-default"
|
|
135
136
|
aria-label="Close"
|
|
136
137
|
onClick={() => {
|
|
137
138
|
setClosed(true)
|
|
138
|
-
|
|
139
|
+
setTimeout(() => {
|
|
140
|
+
alertRef.current.removeChild(alertRef.current.children[0])
|
|
141
|
+
}, 200)
|
|
139
142
|
}}
|
|
140
143
|
>
|
|
141
144
|
<span className="sr-only">Close</span>
|
package/src/styles.css
CHANGED
|
@@ -639,9 +639,6 @@ video {
|
|
|
639
639
|
.right-4 {
|
|
640
640
|
right: 1rem;
|
|
641
641
|
}
|
|
642
|
-
.right-8 {
|
|
643
|
-
right: 2rem;
|
|
644
|
-
}
|
|
645
642
|
.top-0 {
|
|
646
643
|
top: 0px;
|
|
647
644
|
}
|
|
@@ -1124,6 +1121,10 @@ video {
|
|
|
1124
1121
|
--tw-translate-y: -50%;
|
|
1125
1122
|
transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
|
|
1126
1123
|
}
|
|
1124
|
+
.translate-y-1 {
|
|
1125
|
+
--tw-translate-y: 0.25rem;
|
|
1126
|
+
transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
|
|
1127
|
+
}
|
|
1127
1128
|
.translate-y-1\/2 {
|
|
1128
1129
|
--tw-translate-y: 50%;
|
|
1129
1130
|
transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
|
|
@@ -1768,6 +1769,10 @@ video {
|
|
|
1768
1769
|
padding-top: 0.75rem;
|
|
1769
1770
|
padding-bottom: 0.75rem;
|
|
1770
1771
|
}
|
|
1772
|
+
.py-4 {
|
|
1773
|
+
padding-top: 1rem;
|
|
1774
|
+
padding-bottom: 1rem;
|
|
1775
|
+
}
|
|
1771
1776
|
.py-5 {
|
|
1772
1777
|
padding-top: 1.25rem;
|
|
1773
1778
|
padding-bottom: 1.25rem;
|