@sikka/hawa 0.0.213 → 0.0.215

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sikka/hawa",
3
- "version": "0.0.213",
3
+ "version": "0.0.215",
4
4
  "description": "SaaS Oriented UI Kit",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.es.js",
@@ -26,9 +26,9 @@
26
26
  "test": "echo \"Error: no test specified\" && exit 1",
27
27
  "start": "start-storybook -p 6006 -s public",
28
28
  "storybook": "start-storybook -p 6006 -s public",
29
- "build-storybook": "build-storybook",
30
29
  "generate-css": "postcss src/tailwind.css -o src/styles.css && mkdir -p dist && cp src/styles.css dist/",
31
30
  "deploy-storybook": "storybook-to-ghpages",
31
+ "build-storybook": "build-storybook",
32
32
  "build-lib": "rollup -c",
33
33
  "build:styles": " node tools/build-styles"
34
34
  },
@@ -21,10 +21,10 @@ export const Newsletter: React.FunctionComponent<TNewsletter> = ({
21
21
  <HawaContainer variant={variant} centered={true}>
22
22
  <div className="p-4 pt-0">
23
23
  <h1 className="font-bold">
24
- {texts.wantToStayUpdated ?? "Want to stay updated?"}
24
+ {texts?.wantToStayUpdated ?? "Want to stay updated?"}
25
25
  </h1>
26
26
  <span>
27
- {texts.subscribeToNewsletter ?? "Subscribe to our newsletter"}
27
+ {texts?.subscribeToNewsletter ?? "Subscribe to our newsletter"}
28
28
  </span>
29
29
  </div>
30
30
  <form
@@ -42,7 +42,7 @@ export const Newsletter: React.FunctionComponent<TNewsletter> = ({
42
42
  margin="none"
43
43
  />
44
44
  <HawaButton size="full" margins="none">
45
- {texts.submit ?? "Submit"}
45
+ {texts?.submit ?? "Submit"}
46
46
  </HawaButton>
47
47
  </form>
48
48
  </HawaContainer>
@@ -5,14 +5,14 @@ import { HawaContainer } from "../../layout"
5
5
  type NotFoundTypes = {
6
6
  variant?: "outlined" | "contained" | "neobrutalism"
7
7
  texts?: {
8
- pageNotFound: string
9
- ifLost: string
10
- home: string
8
+ pageNotFound?: string
9
+ ifLost?: string
10
+ home?: string
11
11
  }
12
12
  }
13
13
 
14
14
  export const NotFound: React.FunctionComponent<NotFoundTypes> = ({
15
- variant,
15
+ variant = "contained",
16
16
  texts,
17
17
  }) => {
18
18
  return (
@@ -20,13 +20,13 @@ export const NotFound: React.FunctionComponent<NotFoundTypes> = ({
20
20
  <div className="flex flex-col items-center dark:text-white">
21
21
  <div className="text-center text-6xl font-bold ">404</div>
22
22
  <div className="m-2 text-center text-xl font-bold ">
23
- {texts.pageNotFound ?? "Page Not Found"}
23
+ {texts?.pageNotFound ?? "Page Not Found"}
24
24
  </div>
25
25
  <div className="text-center ">
26
- {texts.ifLost ?? "If you're lost please contact us help@sikka.io"}
26
+ {texts?.ifLost ?? "If you're lost please contact us help@sikka.io"}
27
27
  </div>
28
28
  <HawaButton color="primary" width="full">
29
- {texts.home ?? "Home"}
29
+ {texts?.home ?? "Home"}
30
30
  </HawaButton>
31
31
  </div>
32
32
  </HawaContainer>
@@ -67,6 +67,7 @@ export const CheckoutForm: React.FunctionComponent<CheckoutFormTypes> = (
67
67
  </div>
68
68
  <div className="rounded border border-gray-300">
69
69
  <HawaTable
70
+ pagination={false}
70
71
  direction={isArabic ? "rtl" : "ltr"}
71
72
  columns={[
72
73
  { hidden: false, value: "Product" },
@@ -87,8 +87,9 @@ export const HawaAlert: React.FunctionComponent<AlertTypes> = ({
87
87
  <span>{" " + props.text}</span>
88
88
  {props.actions && (
89
89
  <div className="mt-2 flex flex-row gap-2">
90
- {props.actions.map((act) => (
90
+ {props.actions.map((act, index) => (
91
91
  <HawaButton
92
+ key={index}
92
93
  variant={act.variant}
93
94
  onClick={act.onClick()}
94
95
  margins="none"
@@ -28,6 +28,7 @@ export const HawaLogoButton: React.FunctionComponent<LogoButtonTypes> = (
28
28
  src={
29
29
  "https://upload.wikimedia.org/wikipedia/commons/5/53/Google_%22G%22_Logo.svg"
30
30
  }
31
+ className="h-6"
31
32
  />
32
33
  )
33
34
  break
@@ -175,13 +175,17 @@ export const HawaMenu: React.FunctionComponent<TMenuTypes> = ({
175
175
  key={o}
176
176
  className="bg-layout-1200 flex flex-col gap-1 p-1 text-gray-700 dark:text-gray-200"
177
177
  >
178
- {group?.map((item) => {
178
+ {group?.map((item, indx) => {
179
179
  return item.element ? (
180
- <li className="cursor-pointer items-center rounded hover:bg-gray-200 rtl:flex-row-reverse dark:hover:bg-gray-600 dark:hover:text-white">
180
+ <li
181
+ key={indx}
182
+ className="cursor-pointer items-center rounded hover:bg-gray-200 rtl:flex-row-reverse dark:hover:bg-gray-600 dark:hover:text-white"
183
+ >
181
184
  {item.element}
182
185
  </li>
183
186
  ) : (
184
187
  <li
188
+ key={indx}
185
189
  onClick={() => item?.action(actionedItem)}
186
190
  className={clsx(
187
191
  item.isButton
@@ -40,9 +40,10 @@ export const HawaPanelTabs: React.FunctionComponent<PanelTabsTypes> = (
40
40
  </ul>
41
41
  </div>
42
42
  <div id="myTabContent">
43
- {props.options.map((option: any) => {
43
+ {props.options.map((option: any, indx) => {
44
44
  return (
45
45
  <div
46
+ key={indx}
46
47
  className="rounded bg-gray-50 p-4 dark:bg-gray-800"
47
48
  id={option.value}
48
49
  role="tabpanel"
@@ -90,8 +90,9 @@ export const HawaSnackbar: FC<THawaSnackBar> = ({
90
90
  <div className="text-sm font-normal">{description}</div>
91
91
  {actions && (
92
92
  <div className="mt-2 flex flex-row gap-2">
93
- {actions.map((act) => (
93
+ {actions.map((act, i) => (
94
94
  <HawaButton
95
+ key={i}
95
96
  variant={act.variant}
96
97
  onClick={act.onClick()}
97
98
  margins="none"
@@ -29,7 +29,10 @@ export const HawaStepper: React.FunctionComponent<THawaTimeline> = ({
29
29
  >
30
30
  {props.steps.map((step: any, i: number) => {
31
31
  return (
32
- <div className="my-2 flex w-auto flex-row flex-wrap justify-start ">
32
+ <div
33
+ key={i}
34
+ className="my-2 flex w-auto flex-row flex-wrap justify-start "
35
+ >
33
36
  <div
34
37
  className={
35
38
  orientation === "vertical"
@@ -11,6 +11,7 @@ import { BsChevronRight, BsFilter, BsPlus, BsThreeDots } from "react-icons/bs"
11
11
  // TODO: pass the onSearch handler to the parent
12
12
 
13
13
  type TableTypes = {
14
+ pagination?: boolean
14
15
  columns: any[string]
15
16
  actions?: ActionItems[][]
16
17
  direction?: "rtl" | "ltr"
@@ -47,6 +48,7 @@ export const HawaTable: React.FunctionComponent<TableTypes> = ({
47
48
  highlightFirst = false,
48
49
  direction = "ltr",
49
50
  bordersWidth = "1",
51
+ pagination = true,
50
52
  ...props
51
53
  }) => {
52
54
  const [perPage, setPerPage] = useState(10)
@@ -256,71 +258,92 @@ export const HawaTable: React.FunctionComponent<TableTypes> = ({
256
258
  </table>
257
259
  </div>
258
260
 
259
- <div className="flex flex-row items-center justify-between ">
260
- {/* Pagination Pages */}
261
- {range.length > 1 ? (
262
- <div className="flex w-fit flex-row items-stretch justify-center gap-2 overflow-clip rounded ">
263
- {/* Previous Page Button */}
264
- <div
265
- className={clsx(
266
- "flex h-6 w-6 rotate-180 items-center justify-center rounded bg-gray-100 p-1 text-xs hover:bg-layoutPrimary-700 "
267
- )}
268
- onClick={() =>
269
- page <= 1 ? setPage(range.length) : setPage(page - 1)
270
- }
271
- >
272
- <BsChevronRight />
273
- </div>
274
- {/* Numbered Pagination */}
275
- <div className="flex flex-row items-center overflow-clip rounded transition-all">
276
- {/* The first page */}
277
- {range.length > 6 &&
278
- range.map((el, index) => {
279
- if (index <= 0) {
280
- return (
281
- <button
282
- key={index}
283
- className={clsx(
284
- "w-10 p-1 text-xs hover:bg-gray-200",
285
- page === el
286
- ? "bg-buttonPrimary-500 text-white hover:bg-buttonPrimary-500"
287
- : "bg-gray-100"
288
- )}
289
- onClick={() => setPage(el)}
290
- >
291
- {el}
292
- </button>
293
- )
294
- }
295
- })}
296
- {/* The Current Page / Input */}
297
- {range?.length > 6 && (
298
- <input
299
- type={"text"}
300
- className=" w-10 bg-gray-100 p-1 text-center text-xs"
301
- defaultValue={
302
- page !== 0 || page !== range.length - 1 ? page : "..."
303
- }
304
- value={
305
- page == 1 || page == range.length
306
- ? "..."
307
- : enteredPage
308
- ? enteredPage
309
- : page
310
- }
311
- onChange={(e) => setEnteredPage(parseInt(e.target.value))}
312
- onKeyDown={(e) => {
313
- if (e.key === "Enter") {
314
- setPage(enteredPage)
315
- setEnteredPage(null)
261
+ {pagination && (
262
+ <div className="flex flex-row items-center justify-between ">
263
+ {/* Pagination Pages */}
264
+ {range.length > 1 ? (
265
+ <div className="flex w-fit flex-row items-stretch justify-center gap-2 overflow-clip rounded ">
266
+ {/* Previous Page Button */}
267
+ <div
268
+ className={clsx(
269
+ "flex h-6 w-6 rotate-180 items-center justify-center rounded bg-gray-100 p-1 text-xs hover:bg-layoutPrimary-700 "
270
+ )}
271
+ onClick={() =>
272
+ page <= 1 ? setPage(range.length) : setPage(page - 1)
273
+ }
274
+ >
275
+ <BsChevronRight />
276
+ </div>
277
+ {/* Numbered Pagination */}
278
+ <div className="flex flex-row items-center overflow-clip rounded transition-all">
279
+ {/* The first page */}
280
+ {range.length > 6 &&
281
+ range.map((el, index) => {
282
+ if (index <= 0) {
283
+ return (
284
+ <button
285
+ key={index}
286
+ className={clsx(
287
+ "w-10 p-1 text-xs hover:bg-gray-200",
288
+ page === el
289
+ ? "bg-buttonPrimary-500 text-white hover:bg-buttonPrimary-500"
290
+ : "bg-gray-100"
291
+ )}
292
+ onClick={() => setPage(el)}
293
+ >
294
+ {el}
295
+ </button>
296
+ )
297
+ }
298
+ })}
299
+ {/* The Current Page / Input */}
300
+ {range?.length > 6 && (
301
+ <input
302
+ type={"text"}
303
+ className=" w-10 bg-gray-100 p-1 text-center text-xs"
304
+ defaultValue={
305
+ page !== 0 || page !== range.length - 1 ? page : "..."
306
+ }
307
+ value={
308
+ page == 1 || page == range.length
309
+ ? "..."
310
+ : enteredPage
311
+ ? enteredPage
312
+ : page
313
+ }
314
+ onChange={(e) => setEnteredPage(parseInt(e.target.value))}
315
+ onKeyDown={(e) => {
316
+ if (e.key === "Enter") {
317
+ setPage(enteredPage)
318
+ setEnteredPage(null)
319
+ }
320
+ }}
321
+ />
322
+ )}
323
+ {/* The last page */}
324
+ {range?.length > 6 &&
325
+ range.map((el, index) => {
326
+ if (index >= range.length - 1) {
327
+ return (
328
+ <button
329
+ key={index}
330
+ className={clsx(
331
+ "w-10 p-1 text-xs hover:bg-gray-200",
332
+ page === el
333
+ ? "bg-buttonPrimary-500 text-white hover:bg-buttonPrimary-500"
334
+ : "bg-gray-100"
335
+ )}
336
+ onClick={() => setPage(el)}
337
+ >
338
+ {el}
339
+ </button>
340
+ )
316
341
  }
317
- }}
318
- />
319
- )}
320
- {/* The last page */}
321
- {range?.length > 6 &&
322
- range.map((el, index) => {
323
- if (index >= range.length - 1) {
342
+ })}
343
+
344
+ {/* All Pages if less than 6 pages */}
345
+ {range?.length <= 6 &&
346
+ range.map((el, index) => {
324
347
  return (
325
348
  <button
326
349
  key={index}
@@ -335,78 +358,59 @@ export const HawaTable: React.FunctionComponent<TableTypes> = ({
335
358
  {el}
336
359
  </button>
337
360
  )
338
- }
339
- })}
340
-
341
- {/* All Pages if less than 6 pages */}
342
- {range?.length <= 6 &&
343
- range.map((el, index) => {
344
- return (
345
- <button
346
- key={index}
347
- className={clsx(
348
- "w-10 p-1 text-xs hover:bg-gray-200",
349
- page === el
350
- ? "bg-buttonPrimary-500 text-white hover:bg-buttonPrimary-500"
351
- : "bg-gray-100"
352
- )}
353
- onClick={() => setPage(el)}
354
- >
355
- {el}
356
- </button>
357
- )
358
- })}
359
- </div>
360
- {/* Next Page Button */}
361
- <div
362
- onClick={() =>
363
- page >= range.length ? setPage(1) : setPage(page + 1)
364
- }
365
- className={clsx(
366
- "flex h-6 w-6 items-center justify-center rounded bg-gray-100 p-1 text-xs hover:bg-layoutPrimary-700 "
367
- )}
368
- >
369
- <BsChevronRight />
370
- </div>
371
- </div>
372
- ) : (
373
- <div></div>
374
- )}
375
- {/* Pagination Settings */}
376
- {props.rows ? (
377
- <div className="flex w-fit flex-row items-center gap-2 ">
378
- <div className="text-xs ">
379
- {props.rows.length} {props.texts?.items ?? "Items"}
361
+ })}
362
+ </div>
363
+ {/* Next Page Button */}
364
+ <div
365
+ onClick={() =>
366
+ page >= range.length ? setPage(1) : setPage(page + 1)
367
+ }
368
+ className={clsx(
369
+ "flex h-6 w-6 items-center justify-center rounded bg-gray-100 p-1 text-xs hover:bg-layoutPrimary-700 "
370
+ )}
371
+ >
372
+ <BsChevronRight />
373
+ </div>
380
374
  </div>
375
+ ) : (
376
+ <div></div>
377
+ )}
378
+ {/* Pagination Settings */}
379
+ {props.rows ? (
380
+ <div className="flex w-fit flex-row items-center gap-2 ">
381
+ <div className="text-xs ">
382
+ {props.rows.length} {props.texts?.items ?? "Items"}
383
+ </div>
381
384
 
382
- <select
383
- value={perPage}
384
- className="h-6 rounded text-xs"
385
- onChange={(e) => {
386
- setPerPage(parseInt(e.target.value))
387
- }}
388
- >
389
- <option value={10} style={{ fontSize: 10 }}>
390
- 10 / {props.texts?.page ?? "Page"}
391
- </option>
392
- <option value={20} style={{ fontSize: 10 }}>
393
- 20 / {props.texts?.page ?? "Page"}
394
- </option>
395
- <option value={30} style={{ fontSize: 10 }}>
396
- 30 / {props.texts?.page ?? "Page"}
397
- </option>
398
- <option value={50} style={{ fontSize: 10 }}>
399
- 50 / {props.texts?.page ?? "Page"}
400
- </option>
401
- <option value={100} style={{ fontSize: 10 }}>
402
- 100 / {props.texts?.page ?? "Page"}
403
- </option>
404
- </select>
405
- </div>
406
- ) : (
407
- <div></div>
408
- )}
409
- </div>
385
+ <select
386
+ value={perPage}
387
+ className="h-6 rounded text-xs"
388
+ onChange={(e) => {
389
+ setPerPage(parseInt(e.target.value))
390
+ }}
391
+ >
392
+ <option value={10} style={{ fontSize: 10 }}>
393
+ 10 / {props.texts?.page ?? "Page"}
394
+ </option>
395
+ <option value={20} style={{ fontSize: 10 }}>
396
+ 20 / {props.texts?.page ?? "Page"}
397
+ </option>
398
+ <option value={30} style={{ fontSize: 10 }}>
399
+ 30 / {props.texts?.page ?? "Page"}
400
+ </option>
401
+ <option value={50} style={{ fontSize: 10 }}>
402
+ 50 / {props.texts?.page ?? "Page"}
403
+ </option>
404
+ <option value={100} style={{ fontSize: 10 }}>
405
+ 100 / {props.texts?.page ?? "Page"}
406
+ </option>
407
+ </select>
408
+ </div>
409
+ ) : (
410
+ <div></div>
411
+ )}
412
+ </div>
413
+ )}
410
414
  </div>
411
415
  )
412
416
  }
@@ -5,7 +5,7 @@ import React, { useState } from "react"
5
5
 
6
6
  type TabsTypes = {
7
7
  options?: any
8
- onChangeTab?: any
8
+ onChangeTab?: (option) => void
9
9
  defaultValue?: any
10
10
  orientation?: "horizontal" | "vertical"
11
11
  direction?: "rtl" | "ltr"
@@ -101,7 +101,7 @@ export const HawaTabs: React.FunctionComponent<TabsTypes> = ({
101
101
  aria-current="page"
102
102
  onClick={() => {
103
103
  setSelectedOption(opt.value)
104
- props.onChangeTab(opt)
104
+ props?.onChangeTab(opt)
105
105
  }}
106
106
  className={clsx(
107
107
  opt.value === selectedOption
@@ -127,9 +127,9 @@ export const HawaTabs: React.FunctionComponent<TabsTypes> = ({
127
127
  </ul>
128
128
 
129
129
  <div className="flex-1 transition-all">
130
- {props.options.map((tab) => (
130
+ {props.options.map((tab, i) => (
131
131
  <div
132
- key={tab.value}
132
+ key={i}
133
133
  className={clsx(selectedOption === tab.value ? "" : "hidden")}
134
134
  >
135
135
  {tab.content}
@@ -101,8 +101,8 @@ export const InvoiceAccordion: React.FunctionComponent<
101
101
  )}
102
102
  >
103
103
  <div className="border-b pb-2">{props.invoiceDescription}</div>
104
- {props.products?.map((product) => (
105
- <div className="flex flex-row border-b pb-4">
104
+ {props.products?.map((product, i) => (
105
+ <div key={i} className="flex flex-row border-b pb-4">
106
106
  <div className="w-full">
107
107
  <InvoiceItemProp start label={texts.plan} text={product.plan} />
108
108
  </div>
@@ -24,11 +24,12 @@ export const SubsectionList: React.FunctionComponent<SubsectionListTypes> = ({
24
24
  const [selectedSection, setSelectedSection] = useState(null)
25
25
  return (
26
26
  <div className="w-full max-w-2xs rounded bg-layoutPrimary-500 p-4 ">
27
- {subsections.map((ss) => (
28
- <div className="my-0">
27
+ {subsections.map((ss, i) => (
28
+ <div key={i} className="my-0">
29
29
  {ss.title && <div className="my-4 font-bold">{ss.title}</div>}
30
- {ss.sections.map((s) => (
30
+ {ss.sections.map((s, i) => (
31
31
  <SubsectionItem
32
+ key={i}
32
33
  onItemClick={() => setSelectedSection(s.value)}
33
34
  selected={selectedSection}
34
35
  value={s.value}
@@ -21,8 +21,9 @@ export const AppSidebar: React.FC<Props> = ({ isOpen, onClose, items }) => {
21
21
  Close
22
22
  </button>
23
23
  <nav>
24
- {items.map((item) => (
24
+ {items.map((item, i) => (
25
25
  <a
26
+ key={i}
26
27
  href="#"
27
28
  onClick={item.onClick}
28
29
  className="block p-4 font-bold text-white hover:bg-gray-700 hover:text-gray-400"
@@ -333,9 +333,9 @@ export const HawaAppLayout: React.FunctionComponent<HawaAppLayoutTypes> = ({
333
333
  </div>
334
334
  {/* Drawer Items */}
335
335
  <div className="mt-14 mb-8">
336
- {props.drawerItems?.map((dSection, j) => (
336
+ {props.drawerItems?.map((dSection, dIndex) => (
337
337
  <div
338
- key={j}
338
+ key={dIndex}
339
339
  className={clsx("flex flex-col items-stretch justify-center")}
340
340
  >
341
341
  {dSection?.map((dItem, i) => {
@@ -406,8 +406,9 @@ export const HawaAppLayout: React.FunctionComponent<HawaAppLayoutTypes> = ({
406
406
  : 0,
407
407
  }}
408
408
  >
409
- {dItem.subItems?.map((subIt) => (
409
+ {dItem.subItems?.map((subIt, s) => (
410
410
  <div
411
+ key={s}
411
412
  className={clsx(
412
413
  "flex flex-row gap-2 overflow-x-clip rounded p-2 px-2 text-xs",
413
414
  isRTL ? "text-right" : "text-left",
@@ -434,7 +435,7 @@ export const HawaAppLayout: React.FunctionComponent<HawaAppLayoutTypes> = ({
434
435
  </div>
435
436
  )
436
437
  })}
437
- {j !== props.drawerItems.length - 1 && (
438
+ {dIndex !== props.drawerItems.length - 1 && (
438
439
  <div className="my-2 h-[1px] w-10/12 self-center bg-buttonPrimary-500 text-center "></div>
439
440
  )}
440
441
  </div>
@@ -24,8 +24,9 @@ export const HawaBottomAppBar: React.FunctionComponent<BottomAppBarTypes> = (
24
24
  className="flex w-full flex-row items-center justify-evenly rounded bg-gray-200"
25
25
  // variant="outlined"
26
26
  >
27
- {props.appBarContent.map((singleContent: any) => (
27
+ {props.appBarContent.map((singleContent: any, i) => (
28
28
  <div
29
+ key={i}
29
30
  className="m-1 flex h-full w-full flex-col items-center justify-center rounded p-2 transition-all hover:cursor-pointer hover:bg-buttonPrimary-700 hover:text-white"
30
31
  onClick={singleContent.action}
31
32
  >
@@ -102,8 +102,11 @@ export const HawaSiteLayout: React.FunctionComponent<HawaSiteLayoutTypes> = ({
102
102
  >
103
103
  {size > 600 ? (
104
104
  <div className="flex flex-row gap-2 ">
105
- {props.navItems?.map(({ label }) => (
106
- <div className="rounded bg-none p-2 transition-all hover:bg-gray-100">
105
+ {props.navItems?.map(({ label }, i) => (
106
+ <div
107
+ key={i}
108
+ className="rounded bg-none p-2 transition-all hover:bg-gray-100"
109
+ >
107
110
  {label}
108
111
  </div>
109
112
  ))}