@licklist/design 0.44.486-dev.19 → 0.44.486-dev.20

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.
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t,r,n,i=require("react");(e=i)&&"object"==typeof e&&"default"in e&&e.default;function f(){return f=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},f.apply(this,arguments)}exports.ReactComponent=function(e){return i.createElement("svg",f({width:7,height:11,fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),t||(t=i.createElement("rect",{x:.944,y:1.037,width:5.252,height:3.049,rx:1.5,fill:"#4CF973",stroke:"#fff"})),r||(r=i.createElement("rect",{x:.944,y:4.11,width:5.252,height:3.049,rx:1.5,fill:"#4CF973",stroke:"#fff"})),n||(n=i.createElement("rect",{x:.944,y:7.183,width:5.252,height:3.049,rx:1.5,fill:"#4CF973",stroke:"#fff"})))};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t,r,n,i=require("react");(e=i)&&"object"==typeof e&&"default"in e&&e.default;function f(){return f=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},f.apply(this,arguments)}exports.ReactComponent=function(e){return i.createElement("svg",f({width:7,height:11,fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),t||(t=i.createElement("rect",{x:1.241,y:1.037,width:5.252,height:3.049,rx:1.5,fill:"#E4E4E4",stroke:"#fff"})),r||(r=i.createElement("rect",{x:1.241,y:4.11,width:5.252,height:3.049,rx:1.5,fill:"#FDD054",stroke:"#fff"})),n||(n=i.createElement("rect",{x:1.241,y:7.183,width:5.252,height:3.049,rx:1.5,fill:"#FDD054",stroke:"#fff"})))};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t,r,n,f,i=require("react");(e=i)&&"object"==typeof e&&"default"in e&&e.default;function l(){return l=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},l.apply(this,arguments)}exports.ReactComponent=function(e){return i.createElement("svg",l({width:7,height:10,fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),t||(t=i.createElement("path",{fill:"#fff",d:"M.497 0h5.94v10H.497z"})),r||(r=i.createElement("rect",{x:.591,y:.5,width:5.752,height:3,rx:1.5,fill:"#E4E4E4",stroke:"#fff"})),n||(n=i.createElement("rect",{x:.591,y:3.5,width:5.752,height:3,rx:1.5,fill:"#E4E4E4",stroke:"#fff"})),f||(f=i.createElement("rect",{x:.591,y:6.5,width:5.752,height:3,rx:1.5,fill:"#E4E4E4",stroke:"#fff"})))};
@@ -7,6 +7,10 @@ export type DateTimeButtonProps<T = DateTime | string> = {
7
7
  onSelect: (date: T) => void;
8
8
  isOnlyTimeContainer?: boolean;
9
9
  price?: string | number | ReactElement | null;
10
+ resources?: {
11
+ booked: number;
12
+ total: number;
13
+ };
10
14
  };
11
- export declare const DateTimeButton: <T extends string | DateTime>({ date, isDisabled, isSelected, onSelect, isOnlyTimeContainer, price, }: DateTimeButtonProps<T>) => JSX.Element;
15
+ export declare const DateTimeButton: <T extends string | DateTime>({ date, isDisabled, isSelected, onSelect, isOnlyTimeContainer, price, resources, }: DateTimeButtonProps<T>) => JSX.Element;
12
16
  //# sourceMappingURL=DateTimeButton.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DateTimeButton.d.ts","sourceRoot":"","sources":["../../src/date-time-button/DateTimeButton.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAGjC,MAAM,MAAM,mBAAmB,CAAC,CAAC,GAAG,QAAQ,GAAG,MAAM,IAAI;IACvD,IAAI,EAAE,CAAC,CAAC;IACR,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,CAAC;IAC5B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,YAAY,GAAG,IAAI,CAAC;CAC/C,CAAC;AAEF,eAAO,MAAM,cAAc,+IA0D1B,CAAC"}
1
+ {"version":3,"file":"DateTimeButton.d.ts","sourceRoot":"","sources":["../../src/date-time-button/DateTimeButton.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AA8BjC,MAAM,MAAM,mBAAmB,CAAC,CAAC,GAAG,QAAQ,GAAG,MAAM,IAAI;IACvD,IAAI,EAAE,CAAC,CAAC;IACR,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,CAAC;IAC5B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,YAAY,GAAG,IAAI,CAAC;IAC9C,SAAS,CAAC,EAAE;QACV,MAAM,EAAE,MAAM,CAAC;QACf,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;CACH,CAAC;AAEF,eAAO,MAAM,cAAc,0JAiD1B,CAAC"}
@@ -1 +1 @@
1
- "use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=e(require("react")),n=e(require("clsx")),i=require("./DateContent.js");exports.DateTimeButton=function(e){var r=e.date,a=e.isDisabled,o=e.isSelected,s=e.onSelect,c=e.isOnlyTimeContainer,l=e.price,u="string"==typeof r;return t.createElement("button",{type:"button",onClick:function(){return s(r)},disabled:a,className:n("date-time-button",a&&"disabled",o&&"selected",u&&"time-button",c&&"only-time-container",!u&&"today")},u?r:t.createElement(i.DateContent,{date:r,isDisabled:a,isSelected:o}),l&&!a&&t.createElement("div",{className:"price"},l))};
1
+ "use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=e(require("react")),a=require("react-i18next"),l=e(require("clsx")),s=require("../assets/iframe/available.svg.js"),n=require("../assets/iframe/limited.svg.js"),i=require("../assets/iframe/soldOut.svg.js"),o=require("./DateContent.js");exports.DateTimeButton=function(e){var r,c,m=e.date,u=e.isDisabled,d=e.isSelected,b=e.onSelect,p=e.isOnlyTimeContainer,f=e.price,v=e.resources,g=a.useTranslation("Design").t,E="string"==typeof m,C=v&&(r=v.booked,c=v.total,r===c?{label:"soldOut",icon:t.createElement(i.ReactComponent,{className:"logo"})}:r/c<=.2?{label:"lotsOfSpace",icon:t.createElement(s.ReactComponent,{className:"logo"})}:r/c>=.8?{label:"limited",icon:t.createElement(n.ReactComponent,{className:"logo"})}:{label:"available",icon:t.createElement(s.ReactComponent,{className:"logo"})});return t.createElement("button",{type:"button",onClick:function(){return b(m)},disabled:u,className:l("date-time-button",u&&"disabled",d&&"selected",E&&"time-button",p&&"only-time-container",!E&&"today")},E?m:t.createElement(o.DateContent,{date:m,isDisabled:u,isSelected:d}),f&&!u&&t.createElement("div",{className:"price"},f),C&&t.createElement("div",{className:"resources"},C.icon,t.createElement("div",null,g(C.label))))};
@@ -1 +1 @@
1
- {"version":3,"file":"ReportForm.d.ts","sourceRoot":"","sources":["../../../src/report/form/ReportForm.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAE,iBAAiB,EAAE,MAAM,oDAAoD,CAAC;AAIvF,MAAM,WAAW,eAAgB,SAAQ,iBAAiB;IACxD,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,QAAQ,EAAE,CAAC,IAAI,KAAA,KAAK,IAAI,CAAC;CAC1B;AAED,wBAAgB,UAAU,CAAC,EACzB,QAAQ,EACR,MAAM,EACN,aAAa,GACd,EAAE,eAAe,GAAG,GAAG,CAAC,OAAO,CAqF/B"}
1
+ {"version":3,"file":"ReportForm.d.ts","sourceRoot":"","sources":["../../../src/report/form/ReportForm.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAE,iBAAiB,EAAE,MAAM,oDAAoD,CAAC;AAIvF,MAAM,WAAW,eAAgB,SAAQ,iBAAiB;IACxD,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,QAAQ,EAAE,CAAC,IAAI,KAAA,KAAK,IAAI,CAAC;CAC1B;AAED,wBAAgB,UAAU,CAAC,EACzB,QAAQ,EACR,MAAM,EACN,aAAa,GACd,EAAE,eAAe,eAqFjB"}
@@ -1 +1 @@
1
- {"version":3,"file":"RestrictedAccess.d.ts","sourceRoot":"","sources":["../../src/static/RestrictedAccess.tsx"],"names":[],"mappings":";AAMA,iBAAS,gBAAgB,IAAI,GAAG,CAAC,OAAO,CAoBvC;AAED,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"RestrictedAccess.d.ts","sourceRoot":"","sources":["../../src/static/RestrictedAccess.tsx"],"names":[],"mappings":";AAMA,iBAAS,gBAAgB,gBAoBxB;AAED,eAAe,gBAAgB,CAAC"}
@@ -100,14 +100,11 @@
100
100
  color: $snippet-calendar-button-font-color;
101
101
  }
102
102
 
103
- .info {
103
+ .resources {
104
104
  display: flex;
105
105
  justify-content: center;
106
+ align-items: center;
107
+ gap: 0.5rem;
106
108
  font-weight: 300;
107
109
  flex-direction: row;
108
-
109
- .logo {
110
- width: 0.5rem;
111
- margin-right: 0.5rem;
112
- }
113
110
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@licklist/design",
3
- "version": "0.44.486-dev.19",
3
+ "version": "0.44.486-dev.20",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+ssh://git@bitbucket.org/artelogicsoft/licklist_design.git"
@@ -78,3 +78,20 @@ WithPrice.args = {
78
78
  isOnlyTimeContainer: false,
79
79
  price: "from $8000",
80
80
  };
81
+
82
+ export const WithAvailability: Story<DateTimeButtonProps> = (args) => {
83
+ return <DateTimeButton {...args} />;
84
+ };
85
+
86
+ WithAvailability.args = {
87
+ date,
88
+ isSelected: false,
89
+ isDisabled: false,
90
+ onSelect: () => null,
91
+ isOnlyTimeContainer: false,
92
+ price: "from $8000",
93
+ resources: {
94
+ booked: 1,
95
+ total: 3,
96
+ },
97
+ };
@@ -1,8 +1,35 @@
1
1
  import React, { ReactElement } from "react";
2
2
  import clsx from "clsx";
3
3
  import { DateTime } from "luxon";
4
+ import { useTranslation } from "react-i18next";
5
+ import { ReactComponent as AvailableIcon } from "../assets/iframe/available.svg";
6
+ import { ReactComponent as LimitedIcon } from "../assets/iframe/limited.svg";
7
+ import { ReactComponent as SoldOutIcon } from "../assets/iframe/soldOut.svg";
4
8
  import { DateContent } from "./DateContent";
5
9
 
10
+ const LOTS_OF_SPACE_LIMIT = 0.2;
11
+ const LIMITED_LIMIT = 0.8;
12
+
13
+ const getAvailability = (
14
+ booked: number,
15
+ total: number
16
+ ): { label: string; icon: ReactElement } => {
17
+ if (booked === total) {
18
+ return { label: "soldOut", icon: <SoldOutIcon className="logo" /> };
19
+ }
20
+
21
+ // lots of space if less than 80% booked
22
+ if (booked / total <= LOTS_OF_SPACE_LIMIT) {
23
+ return { label: "lotsOfSpace", icon: <AvailableIcon className="logo" /> };
24
+ }
25
+
26
+ if (booked / total >= LIMITED_LIMIT) {
27
+ return { label: "limited", icon: <LimitedIcon className="logo" /> };
28
+ }
29
+
30
+ return { label: "available", icon: <AvailableIcon className="logo" /> };
31
+ };
32
+
6
33
  export type DateTimeButtonProps<T = DateTime | string> = {
7
34
  date: T;
8
35
  isSelected?: boolean;
@@ -10,6 +37,10 @@ export type DateTimeButtonProps<T = DateTime | string> = {
10
37
  onSelect: (date: T) => void;
11
38
  isOnlyTimeContainer?: boolean;
12
39
  price?: string | number | ReactElement | null;
40
+ resources?: {
41
+ booked: number;
42
+ total: number;
43
+ };
13
44
  };
14
45
 
15
46
  export const DateTimeButton = <T extends DateTime | string>({
@@ -19,22 +50,14 @@ export const DateTimeButton = <T extends DateTime | string>({
19
50
  onSelect,
20
51
  isOnlyTimeContainer,
21
52
  price,
53
+ resources,
22
54
  }: DateTimeButtonProps<T>) => {
23
- // const infoLogo = useMemo(() => {
24
- // if (info?.logo === infoLogoType.LIMIT) {
25
- // return <LimitedSvg />;
26
- // }
27
- // if (info?.logo === infoLogoType.AVAILABLE) {
28
- // return <AvailableSvg />;
29
- // }
30
- // if (info?.logo === infoLogoType.SOLD_OUT) {
31
- // return <SoldOutSvg />;
32
- // }
33
- // return null;
34
- // }, [info]);
35
-
55
+ const { t } = useTranslation("Design");
36
56
  const isTimeVariant = typeof date === "string";
37
57
 
58
+ const availability =
59
+ resources && getAvailability(resources.booked, resources.total);
60
+
38
61
  return (
39
62
  <button
40
63
  type="button"
@@ -61,13 +84,12 @@ export const DateTimeButton = <T extends DateTime | string>({
61
84
 
62
85
  {price && !isDisabled && <div className="price">{price}</div>}
63
86
 
64
- {/* TODO uncomment when adding availability */}
65
- {/* {info && (
66
- <div className="info">
67
- {info.logo && <Logo className="logo" logo={infoLogo} />}
68
- <div>{info.description}</div>
87
+ {availability && (
88
+ <div className="resources">
89
+ {availability.icon}
90
+ <div>{t(availability.label)}</div>
69
91
  </div>
70
- )} */}
92
+ )}
71
93
  </button>
72
94
  );
73
95
  };
@@ -1,4 +1,4 @@
1
- import React from "react";
1
+ import React, { ReactElement } from "react";
2
2
  import { useFormContext } from "react-hook-form";
3
3
  import en from "react-phone-number-input/locale/en.json";
4
4
  import { LocationInputValues } from ".";
@@ -13,7 +13,7 @@ export function LocationInputDescription() {
13
13
  "postcode",
14
14
  "country",
15
15
  ] as const;
16
- const fields = fieldNames.reduce<JSX.Element[]>((acc, field) => {
16
+ const fields = fieldNames.reduce<ReactElement[]>((acc, field) => {
17
17
  const value = values?.[field];
18
18
  if (!value) return acc;
19
19
 
@@ -15,7 +15,7 @@ export function ReportForm({
15
15
  onSubmit,
16
16
  onHide,
17
17
  hasPermission,
18
- }: ReportFormProps): JSX.Element {
18
+ }: ReportFormProps) {
19
19
  const { t } = useTranslation(["App"]);
20
20
  const fromDateInput = useRef<HTMLInputDateElement | null>(null);
21
21
  const toDateInput = useRef<HTMLInputDateElement | null>(null);
@@ -4,7 +4,7 @@ import RouteService from "@licklist/plugins/dist/services/Route/RouteService";
4
4
  import { useTranslation } from "react-i18next";
5
5
  import Icon from "./Icon";
6
6
 
7
- function RestrictedAccess(): JSX.Element {
7
+ function RestrictedAccess() {
8
8
  const { t } = useTranslation("Design");
9
9
 
10
10
  return (
@@ -100,14 +100,11 @@
100
100
  color: $snippet-calendar-button-font-color;
101
101
  }
102
102
 
103
- .info {
103
+ .resources {
104
104
  display: flex;
105
105
  justify-content: center;
106
+ align-items: center;
107
+ gap: 0.5rem;
106
108
  font-weight: 300;
107
109
  flex-direction: row;
108
-
109
- .logo {
110
- width: 0.5rem;
111
- margin-right: 0.5rem;
112
- }
113
110
  }