@chayns-components/date 5.0.0-beta.583 → 5.0.0-beta.588
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/lib/cjs/components/opening-times/OpeningTimes.js +16 -7
- package/lib/cjs/components/opening-times/OpeningTimes.js.map +1 -1
- package/lib/cjs/components/opening-times/hint-text/HintText.styles.js +1 -3
- package/lib/cjs/components/opening-times/hint-text/HintText.styles.js.map +1 -1
- package/lib/cjs/components/opening-times/opening-inputs/OpeningInputs.styles.js +5 -1
- package/lib/cjs/components/opening-times/opening-inputs/OpeningInputs.styles.js.map +1 -1
- package/lib/esm/components/opening-times/OpeningTimes.js +12 -9
- package/lib/esm/components/opening-times/OpeningTimes.js.map +1 -1
- package/lib/esm/components/opening-times/hint-text/HintText.styles.js +5 -10
- package/lib/esm/components/opening-times/hint-text/HintText.styles.js.map +1 -1
- package/lib/esm/components/opening-times/opening-inputs/OpeningInputs.styles.js +8 -1
- package/lib/esm/components/opening-times/opening-inputs/OpeningInputs.styles.js.map +1 -1
- package/lib/types/components/opening-times/opening-inputs/OpeningInputs.styles.d.ts +3 -1
- package/package.json +3 -3
|
@@ -28,6 +28,7 @@ const OpeningTimes = ({
|
|
|
28
28
|
const [newOpeningTimes, setNewOpeningTimes] = (0, _react.useState)();
|
|
29
29
|
const [invalidOpeningTimes, setInvalidOpeningTimes] = (0, _react.useState)([]);
|
|
30
30
|
const ref = (0, _react.useRef)(null);
|
|
31
|
+
const popupRef = (0, _react.useRef)(null);
|
|
31
32
|
(0, _react.useEffect)(() => {
|
|
32
33
|
setNewOpeningTimes(openingTimes);
|
|
33
34
|
}, [openingTimes]);
|
|
@@ -180,23 +181,31 @@ const OpeningTimes = ({
|
|
|
180
181
|
weekdayId
|
|
181
182
|
} = singleDay;
|
|
182
183
|
const weekday = (_weekdays$find2 = weekdays.find(weekDay => weekDay.id === weekdayId)) === null || _weekdays$find2 === void 0 ? void 0 : _weekdays$find2.name;
|
|
183
|
-
|
|
184
|
+
return /*#__PURE__*/_react.default.createElement(_OpeningTimes.StyledOpeningTimesWrapper, {
|
|
184
185
|
key: `currentDay__${currentDayId}`,
|
|
185
186
|
style: size && {
|
|
186
187
|
width: size.width
|
|
188
|
+
},
|
|
189
|
+
onMouseEnter: () => {
|
|
190
|
+
var _popupRef$current;
|
|
191
|
+
return (_popupRef$current = popupRef.current) === null || _popupRef$current === void 0 ? void 0 : _popupRef$current.show();
|
|
192
|
+
},
|
|
193
|
+
onMouseLeave: () => {
|
|
194
|
+
var _popupRef$current2;
|
|
195
|
+
return (_popupRef$current2 = popupRef.current) === null || _popupRef$current2 === void 0 ? void 0 : _popupRef$current2.hide();
|
|
187
196
|
}
|
|
188
|
-
}, /*#__PURE__*/_react.default.createElement(
|
|
197
|
+
}, /*#__PURE__*/_react.default.createElement(_core.Popup, {
|
|
198
|
+
ref: popupRef,
|
|
199
|
+
content: /*#__PURE__*/_react.default.createElement(_OpeningTimes.StyledOpeningTimesTooltipContent, {
|
|
200
|
+
key: "opening-time-tooltip"
|
|
201
|
+
}, content)
|
|
202
|
+
}, /*#__PURE__*/_react.default.createElement(_OpeningTimes.StyledOpeningTimesWeekDay, null, weekday)), /*#__PURE__*/_react.default.createElement(_OpeningInputs.default, {
|
|
189
203
|
closedText: closedText,
|
|
190
204
|
onInvalid: handleUpdateInvalidIds,
|
|
191
205
|
id: id,
|
|
192
206
|
times: times,
|
|
193
207
|
editMode: editMode
|
|
194
208
|
}));
|
|
195
|
-
return /*#__PURE__*/_react.default.createElement(_core.Tooltip, {
|
|
196
|
-
item: /*#__PURE__*/_react.default.createElement(_OpeningTimes.StyledOpeningTimesTooltipContent, {
|
|
197
|
-
key: "opening-time-tooltip"
|
|
198
|
-
}, content)
|
|
199
|
-
}, element);
|
|
200
209
|
}, [currentDayId, editMode, newOpeningTimes, weekdays, size, closedText, handleUpdateInvalidIds, content]);
|
|
201
210
|
const shouldShowHint = (0, _react.useMemo)(() => invalidOpeningTimes.length > 0, [invalidOpeningTimes.length]);
|
|
202
211
|
return (0, _react.useMemo)(() => /*#__PURE__*/_react.default.createElement(_OpeningTimes.StyledOpeningTimes, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpeningTimes.js","names":["_core","require","_react","_interopRequireWildcard","_openingTimes","_HintText","_interopRequireDefault","_OpeningInputs","_OpeningTimes","obj","__esModule","default","_getRequireWildcardCache","e","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","OpeningTimes","closedText","currentDayId","editMode","hintText","hintTextPosition","HintTextPosition","Bottom","openingTimes","weekdays","onChange","onTimeAdd","onTimeRemove","newOpeningTimes","setNewOpeningTimes","useState","invalidOpeningTimes","setInvalidOpeningTimes","ref","useRef","useEffect","handleCheckBoxChange","useCallback","id","prevOpeningTimes","updatedOpeningTimes","map","openingTime","isDisabled","enabledDays","filter","item","handleChange","newTime","newTimes","times","time","handleAdd","dayId","handleUpdateInvalidIds","openingTimeId","invalidTimeIds","prevState","updatedInvalidOpeningTimes","invalidOpeningTime","some","updatedInvalidOpeningId","length","push","updatedInvalidOpeningTime","handleRemove","content","useMemo","items","forEach","weekdayId","_weekdays$find","weekday","find","weekDay","name","createElement","StyledOpeningTimesWrapper","key","Checkbox","isChecked","StyledOpeningTimesWeekDay","onInvalid","onRemove","onAdd","size","useElementSize","displayedContent","_weekdays$find2","singleDay","element","style","width","Tooltip","StyledOpeningTimesTooltipContent","shouldShowHint","StyledOpeningTimes","Top","text","displayName","_default","exports"],"sources":["../../../../src/components/opening-times/OpeningTimes.tsx"],"sourcesContent":["import { Checkbox, Tooltip, useElementSize } from '@chayns-components/core';\nimport React, {\n FC,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n type ReactElement,\n} from 'react';\nimport {\n HintTextPosition,\n type OnChange,\n type OnTimeAdd,\n type OpeningTime,\n type Time,\n type Weekday,\n} from '../../types/openingTimes';\nimport HintText from './hint-text/HintText';\nimport OpeningInputs from './opening-inputs/OpeningInputs';\nimport {\n StyledOpeningTimes,\n StyledOpeningTimesTooltipContent,\n StyledOpeningTimesWeekDay,\n StyledOpeningTimesWrapper,\n} from './OpeningTimes.styles';\n\nexport type OpeningTimesProps = {\n /**\n * The text that should be displayed when a day is closed.\n */\n closedText?: string;\n /**\n * If set just the current day is displayed and the whole week in a tooltip.\n */\n currentDayId?: OpeningTime['id'];\n /**\n * Whether the opening times can be edited.\n */\n editMode?: boolean;\n /**\n * The text that should be displayed if times are colliding.\n */\n hintText?: string;\n /**\n * The position of the hint text.\n */\n hintTextPosition?: HintTextPosition;\n /**\n * Function to be executed when a time is changed or a day is enabled/disabled.\n * @param openingTimes\n */\n onChange?: ({ time, enabledDays }: OnChange) => void;\n /**\n * Function to be executed when a time is added.\n */\n onTimeAdd?: ({ time, dayId }: OnTimeAdd) => void;\n /**\n * Function to be executed when a time is removed.\n */\n onTimeRemove?: (id: string) => void;\n /**\n * The opening times corresponding to its weekday.\n */\n openingTimes: OpeningTime[];\n /**\n * The weekdays that should be displayed.\n */\n weekdays: Weekday[];\n};\n\nconst OpeningTimes: FC<OpeningTimesProps> = ({\n closedText = 'closed',\n currentDayId,\n editMode = false,\n hintText,\n hintTextPosition = HintTextPosition.Bottom,\n openingTimes,\n weekdays,\n onChange,\n onTimeAdd,\n onTimeRemove,\n}) => {\n const [newOpeningTimes, setNewOpeningTimes] = useState<OpeningTime[]>();\n const [invalidOpeningTimes, setInvalidOpeningTimes] = useState<\n { openingTimeId: string; invalidTimeIds: string[] }[]\n >([]);\n\n const ref = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n setNewOpeningTimes(openingTimes);\n }, [openingTimes]);\n\n const handleCheckBoxChange = useCallback(\n (id: string) => {\n setNewOpeningTimes((prevOpeningTimes) => {\n const updatedOpeningTimes = (prevOpeningTimes ?? []).map((openingTime) => {\n if (openingTime.id === id) {\n return { ...openingTime, isDisabled: !openingTime.isDisabled };\n }\n return openingTime;\n });\n\n if (typeof onChange === 'function') {\n onChange({\n enabledDays: updatedOpeningTimes\n .filter((item) => !item.isDisabled)\n .map((item) => item.id),\n });\n }\n\n return updatedOpeningTimes;\n });\n },\n [onChange],\n );\n\n const handleChange = useCallback(\n (newTime: Time, id: string) => {\n setNewOpeningTimes((prevOpeningTimes) => {\n const updatedOpeningTimes = (prevOpeningTimes ?? []).map((openingTime) => {\n if (openingTime.id === id) {\n const newTimes = openingTime.times.map((time) => {\n if (time.id === newTime.id) {\n return newTime;\n }\n\n return time;\n });\n\n return { ...openingTime, times: newTimes };\n }\n return openingTime;\n });\n\n if (typeof onChange === 'function') {\n onChange({ time: newTime });\n }\n\n return updatedOpeningTimes;\n });\n },\n [onChange],\n );\n\n const handleAdd = useCallback(\n (time: Time, id: string) => {\n setNewOpeningTimes((prevOpeningTimes) =>\n (prevOpeningTimes ?? []).map((openingTime) => {\n if (openingTime.id === id) {\n return { ...openingTime, times: [...openingTime.times, time] };\n }\n return openingTime;\n }),\n );\n\n if (typeof onTimeAdd === 'function') {\n onTimeAdd({ dayId: id, time });\n }\n },\n [onTimeAdd],\n );\n\n const handleUpdateInvalidIds = useCallback(\n (openingTimeId: string, invalidTimeIds: string[]) => {\n setInvalidOpeningTimes((prevState) => {\n let updatedInvalidOpeningTimes = prevState.map((invalidOpeningTime) => {\n if (invalidOpeningTime.openingTimeId === openingTimeId) {\n return {\n openingTimeId,\n invalidTimeIds,\n };\n }\n\n return invalidOpeningTime;\n });\n\n if (\n !updatedInvalidOpeningTimes.some(\n ({ openingTimeId: updatedInvalidOpeningId }) =>\n updatedInvalidOpeningId === openingTimeId,\n ) &&\n invalidTimeIds.length > 0\n ) {\n updatedInvalidOpeningTimes.push({ openingTimeId, invalidTimeIds });\n }\n\n updatedInvalidOpeningTimes = updatedInvalidOpeningTimes.filter(\n (updatedInvalidOpeningTime) =>\n updatedInvalidOpeningTime.invalidTimeIds.length !== 0,\n );\n\n return updatedInvalidOpeningTimes;\n });\n },\n [],\n );\n\n const handleRemove = useCallback(\n (id: string) => {\n setNewOpeningTimes((prevOpeningTimes) =>\n (prevOpeningTimes ?? []).map((openingTime) => {\n const newTimes = openingTime.times.filter((time) => time.id !== id);\n\n return { ...openingTime, times: newTimes };\n }),\n );\n\n if (typeof onTimeRemove === 'function') {\n onTimeRemove(id);\n }\n },\n [onTimeRemove],\n );\n\n const content = useMemo(() => {\n const items: ReactElement[] = [];\n\n if (!newOpeningTimes) {\n return items;\n }\n\n newOpeningTimes.forEach(({ times, id, weekdayId, isDisabled }) => {\n const weekday = weekdays.find((weekDay) => weekDay.id === weekdayId)?.name;\n\n if (!weekday) {\n return;\n }\n\n items.push(\n <StyledOpeningTimesWrapper key={`openingTimes__${id}`}>\n {editMode ? (\n <Checkbox isChecked={!isDisabled} onChange={() => handleCheckBoxChange(id)}>\n {weekday}\n </Checkbox>\n ) : (\n <StyledOpeningTimesWeekDay>{weekday}</StyledOpeningTimesWeekDay>\n )}\n <OpeningInputs\n closedText={closedText}\n id={id}\n times={times}\n isDisabled={isDisabled}\n onInvalid={handleUpdateInvalidIds}\n onChange={(newTime) => handleChange(newTime, id)}\n onRemove={handleRemove}\n onAdd={handleAdd}\n editMode={editMode}\n />\n </StyledOpeningTimesWrapper>,\n );\n });\n\n return items;\n }, [\n closedText,\n editMode,\n handleAdd,\n handleChange,\n handleCheckBoxChange,\n handleRemove,\n handleUpdateInvalidIds,\n newOpeningTimes,\n weekdays,\n ]);\n\n const size = useElementSize(ref);\n\n const displayedContent = useMemo(() => {\n if (!currentDayId || editMode) {\n return content;\n }\n\n const singleDay = newOpeningTimes?.find(({ id }) => id === currentDayId);\n\n if (!singleDay) {\n return content;\n }\n\n const { id, times, weekdayId } = singleDay;\n\n const weekday = weekdays.find((weekDay) => weekDay.id === weekdayId)?.name;\n\n const element = (\n <StyledOpeningTimesWrapper\n key={`currentDay__${currentDayId}`}\n style={size && { width: size.width }}\n >\n <StyledOpeningTimesWeekDay>{weekday}</StyledOpeningTimesWeekDay>\n <OpeningInputs\n closedText={closedText}\n onInvalid={handleUpdateInvalidIds}\n id={id}\n times={times}\n editMode={editMode}\n />\n </StyledOpeningTimesWrapper>\n );\n\n return (\n <Tooltip\n item={\n <StyledOpeningTimesTooltipContent key=\"opening-time-tooltip\">\n {content}\n </StyledOpeningTimesTooltipContent>\n }\n >\n {element}\n </Tooltip>\n );\n }, [\n currentDayId,\n editMode,\n newOpeningTimes,\n weekdays,\n size,\n closedText,\n handleUpdateInvalidIds,\n content,\n ]);\n\n const shouldShowHint = useMemo(\n () => invalidOpeningTimes.length > 0,\n [invalidOpeningTimes.length],\n );\n\n return useMemo(\n () => (\n <StyledOpeningTimes ref={ref}>\n {shouldShowHint && hintText && hintTextPosition === HintTextPosition.Top && (\n <HintText text={hintText} />\n )}\n {displayedContent}\n {shouldShowHint && hintText && hintTextPosition === HintTextPosition.Bottom && (\n <HintText text={hintText} />\n )}\n </StyledOpeningTimes>\n ),\n [displayedContent, hintText, hintTextPosition, shouldShowHint],\n );\n};\n\nOpeningTimes.displayName = 'OpeningTimes';\n\nexport default OpeningTimes;\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,uBAAA,CAAAF,OAAA;AASA,IAAAG,aAAA,GAAAH,OAAA;AAQA,IAAAI,SAAA,GAAAC,sBAAA,CAAAL,OAAA;AACA,IAAAM,cAAA,GAAAD,sBAAA,CAAAL,OAAA;AACA,IAAAO,aAAA,GAAAP,OAAA;AAK+B,SAAAK,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAV,wBAAAU,C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openingTimes","_HintText","_interopRequireDefault","_OpeningInputs","_OpeningTimes","obj","__esModule","default","_getRequireWildcardCache","e","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","OpeningTimes","closedText","currentDayId","editMode","hintText","hintTextPosition","HintTextPosition","Bottom","openingTimes","weekdays","onChange","onTimeAdd","onTimeRemove","newOpeningTimes","setNewOpeningTimes","useState","invalidOpeningTimes","setInvalidOpeningTimes","ref","useRef","popupRef","useEffect","handleCheckBoxChange","useCallback","id","prevOpeningTimes","updatedOpeningTimes","map","openingTime","isDisabled","enabledDays","filter","item","handleChange","newTime","newTimes","times","time","handleAdd","dayId","handleUpdateInvalidIds","openingTimeId","invalidTimeIds","prevState","updatedInvalidOpeningTimes","invalidOpeningTime","some","updatedInvalidOpeningId","length","push","updatedInvalidOpeningTime","handleRemove","content","useMemo","items","forEach","weekdayId","_weekdays$find","weekday","find","weekDay","name","createElement","StyledOpeningTimesWrapper","key","Checkbox","isChecked","StyledOpeningTimesWeekDay","onInvalid","onRemove","onAdd","size","useElementSize","displayedContent","_weekdays$find2","singleDay","style","width","onMouseEnter","_popupRef$current","current","show","onMouseLeave","_popupRef$current2","hide","Popup","StyledOpeningTimesTooltipContent","shouldShowHint","StyledOpeningTimes","Top","text","displayName","_default","exports"],"sources":["../../../../src/components/opening-times/OpeningTimes.tsx"],"sourcesContent":["import { Checkbox, Popup, useElementSize, type PopupRef } from '@chayns-components/core';\nimport React, {\n FC,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n type ReactElement,\n} from 'react';\nimport {\n HintTextPosition,\n type OnChange,\n type OnTimeAdd,\n type OpeningTime,\n type Time,\n type Weekday,\n} from '../../types/openingTimes';\nimport HintText from './hint-text/HintText';\nimport OpeningInputs from './opening-inputs/OpeningInputs';\nimport {\n StyledOpeningTimes,\n StyledOpeningTimesTooltipContent,\n StyledOpeningTimesWeekDay,\n StyledOpeningTimesWrapper,\n} from './OpeningTimes.styles';\n\nexport type OpeningTimesProps = {\n /**\n * The text that should be displayed when a day is closed.\n */\n closedText?: string;\n /**\n * If set just the current day is displayed and the whole week in a tooltip.\n */\n currentDayId?: OpeningTime['id'];\n /**\n * Whether the opening times can be edited.\n */\n editMode?: boolean;\n /**\n * The text that should be displayed if times are colliding.\n */\n hintText?: string;\n /**\n * The position of the hint text.\n */\n hintTextPosition?: HintTextPosition;\n /**\n * Function to be executed when a time is changed or a day is enabled/disabled.\n * @param openingTimes\n */\n onChange?: ({ time, enabledDays }: OnChange) => void;\n /**\n * Function to be executed when a time is added.\n */\n onTimeAdd?: ({ time, dayId }: OnTimeAdd) => void;\n /**\n * Function to be executed when a time is removed.\n */\n onTimeRemove?: (id: string) => void;\n /**\n * The opening times corresponding to its weekday.\n */\n openingTimes: OpeningTime[];\n /**\n * The weekdays that should be displayed.\n */\n weekdays: Weekday[];\n};\n\nconst OpeningTimes: FC<OpeningTimesProps> = ({\n closedText = 'closed',\n currentDayId,\n editMode = false,\n hintText,\n hintTextPosition = HintTextPosition.Bottom,\n openingTimes,\n weekdays,\n onChange,\n onTimeAdd,\n onTimeRemove,\n}) => {\n const [newOpeningTimes, setNewOpeningTimes] = useState<OpeningTime[]>();\n const [invalidOpeningTimes, setInvalidOpeningTimes] = useState<\n { openingTimeId: string; invalidTimeIds: string[] }[]\n >([]);\n\n const ref = useRef<HTMLDivElement>(null);\n const popupRef = useRef<PopupRef>(null);\n\n useEffect(() => {\n setNewOpeningTimes(openingTimes);\n }, [openingTimes]);\n\n const handleCheckBoxChange = useCallback(\n (id: string) => {\n setNewOpeningTimes((prevOpeningTimes) => {\n const updatedOpeningTimes = (prevOpeningTimes ?? []).map((openingTime) => {\n if (openingTime.id === id) {\n return { ...openingTime, isDisabled: !openingTime.isDisabled };\n }\n return openingTime;\n });\n\n if (typeof onChange === 'function') {\n onChange({\n enabledDays: updatedOpeningTimes\n .filter((item) => !item.isDisabled)\n .map((item) => item.id),\n });\n }\n\n return updatedOpeningTimes;\n });\n },\n [onChange],\n );\n\n const handleChange = useCallback(\n (newTime: Time, id: string) => {\n setNewOpeningTimes((prevOpeningTimes) => {\n const updatedOpeningTimes = (prevOpeningTimes ?? []).map((openingTime) => {\n if (openingTime.id === id) {\n const newTimes = openingTime.times.map((time) => {\n if (time.id === newTime.id) {\n return newTime;\n }\n\n return time;\n });\n\n return { ...openingTime, times: newTimes };\n }\n return openingTime;\n });\n\n if (typeof onChange === 'function') {\n onChange({ time: newTime });\n }\n\n return updatedOpeningTimes;\n });\n },\n [onChange],\n );\n\n const handleAdd = useCallback(\n (time: Time, id: string) => {\n setNewOpeningTimes((prevOpeningTimes) =>\n (prevOpeningTimes ?? []).map((openingTime) => {\n if (openingTime.id === id) {\n return { ...openingTime, times: [...openingTime.times, time] };\n }\n return openingTime;\n }),\n );\n\n if (typeof onTimeAdd === 'function') {\n onTimeAdd({ dayId: id, time });\n }\n },\n [onTimeAdd],\n );\n\n const handleUpdateInvalidIds = useCallback(\n (openingTimeId: string, invalidTimeIds: string[]) => {\n setInvalidOpeningTimes((prevState) => {\n let updatedInvalidOpeningTimes = prevState.map((invalidOpeningTime) => {\n if (invalidOpeningTime.openingTimeId === openingTimeId) {\n return {\n openingTimeId,\n invalidTimeIds,\n };\n }\n\n return invalidOpeningTime;\n });\n\n if (\n !updatedInvalidOpeningTimes.some(\n ({ openingTimeId: updatedInvalidOpeningId }) =>\n updatedInvalidOpeningId === openingTimeId,\n ) &&\n invalidTimeIds.length > 0\n ) {\n updatedInvalidOpeningTimes.push({ openingTimeId, invalidTimeIds });\n }\n\n updatedInvalidOpeningTimes = updatedInvalidOpeningTimes.filter(\n (updatedInvalidOpeningTime) =>\n updatedInvalidOpeningTime.invalidTimeIds.length !== 0,\n );\n\n return updatedInvalidOpeningTimes;\n });\n },\n [],\n );\n\n const handleRemove = useCallback(\n (id: string) => {\n setNewOpeningTimes((prevOpeningTimes) =>\n (prevOpeningTimes ?? []).map((openingTime) => {\n const newTimes = openingTime.times.filter((time) => time.id !== id);\n\n return { ...openingTime, times: newTimes };\n }),\n );\n\n if (typeof onTimeRemove === 'function') {\n onTimeRemove(id);\n }\n },\n [onTimeRemove],\n );\n\n const content = useMemo(() => {\n const items: ReactElement[] = [];\n\n if (!newOpeningTimes) {\n return items;\n }\n\n newOpeningTimes.forEach(({ times, id, weekdayId, isDisabled }) => {\n const weekday = weekdays.find((weekDay) => weekDay.id === weekdayId)?.name;\n\n if (!weekday) {\n return;\n }\n\n items.push(\n <StyledOpeningTimesWrapper key={`openingTimes__${id}`}>\n {editMode ? (\n <Checkbox isChecked={!isDisabled} onChange={() => handleCheckBoxChange(id)}>\n {weekday}\n </Checkbox>\n ) : (\n <StyledOpeningTimesWeekDay>{weekday}</StyledOpeningTimesWeekDay>\n )}\n <OpeningInputs\n closedText={closedText}\n id={id}\n times={times}\n isDisabled={isDisabled}\n onInvalid={handleUpdateInvalidIds}\n onChange={(newTime) => handleChange(newTime, id)}\n onRemove={handleRemove}\n onAdd={handleAdd}\n editMode={editMode}\n />\n </StyledOpeningTimesWrapper>,\n );\n });\n\n return items;\n }, [\n closedText,\n editMode,\n handleAdd,\n handleChange,\n handleCheckBoxChange,\n handleRemove,\n handleUpdateInvalidIds,\n newOpeningTimes,\n weekdays,\n ]);\n\n const size = useElementSize(ref);\n\n const displayedContent = useMemo(() => {\n if (!currentDayId || editMode) {\n return content;\n }\n\n const singleDay = newOpeningTimes?.find(({ id }) => id === currentDayId);\n\n if (!singleDay) {\n return content;\n }\n\n const { id, times, weekdayId } = singleDay;\n\n const weekday = weekdays.find((weekDay) => weekDay.id === weekdayId)?.name;\n\n return (\n <StyledOpeningTimesWrapper\n key={`currentDay__${currentDayId}`}\n style={size && { width: size.width }}\n onMouseEnter={() => popupRef.current?.show()}\n onMouseLeave={() => popupRef.current?.hide()}\n >\n <Popup\n ref={popupRef}\n content={\n <StyledOpeningTimesTooltipContent key=\"opening-time-tooltip\">\n {content}\n </StyledOpeningTimesTooltipContent>\n }\n >\n <StyledOpeningTimesWeekDay>{weekday}</StyledOpeningTimesWeekDay>\n </Popup>\n <OpeningInputs\n closedText={closedText}\n onInvalid={handleUpdateInvalidIds}\n id={id}\n times={times}\n editMode={editMode}\n />\n </StyledOpeningTimesWrapper>\n );\n }, [\n currentDayId,\n editMode,\n newOpeningTimes,\n weekdays,\n size,\n closedText,\n handleUpdateInvalidIds,\n content,\n ]);\n\n const shouldShowHint = useMemo(\n () => invalidOpeningTimes.length > 0,\n [invalidOpeningTimes.length],\n );\n\n return useMemo(\n () => (\n <StyledOpeningTimes ref={ref}>\n {shouldShowHint && hintText && hintTextPosition === HintTextPosition.Top && (\n <HintText text={hintText} />\n )}\n {displayedContent}\n {shouldShowHint && hintText && hintTextPosition === HintTextPosition.Bottom && (\n <HintText text={hintText} />\n )}\n </StyledOpeningTimes>\n ),\n [displayedContent, hintText, hintTextPosition, shouldShowHint],\n );\n};\n\nOpeningTimes.displayName = 'OpeningTimes';\n\nexport default OpeningTimes;\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,uBAAA,CAAAF,OAAA;AASA,IAAAG,aAAA,GAAAH,OAAA;AAQA,IAAAI,SAAA,GAAAC,sBAAA,CAAAL,OAAA;AACA,IAAAM,cAAA,GAAAD,sBAAA,CAAAL,OAAA;AACA,IAAAO,aAAA,GAAAP,OAAA;AAK+B,SAAAK,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAV,wBAAAU,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,C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,CAAAM,OAAQ;IAAC6G,IAAI,EAAEtF;EAAS,CAAE,CAEf,CACvB,EACD,CAACqE,gBAAgB,EAAErE,QAAQ,EAAEC,gBAAgB,EAAEkF,cAAc,CACjE,CAAC;AACL,CAAC;AAEDvF,YAAY,CAAC2F,WAAW,GAAG,cAAc;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAhH,OAAA,GAE3BmB,YAAY","ignoreList":[]}
|
|
@@ -11,9 +11,7 @@ const StyledHintText = exports.StyledHintText = _styledComponents.default.div`
|
|
|
11
11
|
border-style: solid;
|
|
12
12
|
border-color: #9f5f00;
|
|
13
13
|
background-color: #fff3e0;
|
|
14
|
-
color:
|
|
15
|
-
theme
|
|
16
|
-
}) => theme.text};
|
|
14
|
+
color: #222;
|
|
17
15
|
padding: 8px 12px;
|
|
18
16
|
|
|
19
17
|
border-radius: ${({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HintText.styles.js","names":["_styledComponents","_interopRequireDefault","require","obj","__esModule","default","StyledHintText","exports","styled","div","theme","
|
|
1
|
+
{"version":3,"file":"HintText.styles.js","names":["_styledComponents","_interopRequireDefault","require","obj","__esModule","default","StyledHintText","exports","styled","div","theme","cardBorderRadius","cardShadow"],"sources":["../../../../../src/components/opening-times/hint-text/HintText.styles.ts"],"sourcesContent":["import type { WithTheme } from '@chayns-components/core';\nimport styled from 'styled-components';\n\ntype StyledHintTextProp = WithTheme<unknown>;\n\nexport const StyledHintText = styled.div<StyledHintTextProp>`\n border-width: 1px;\n border-style: solid;\n border-color: #9f5f00;\n background-color: #fff3e0;\n color: #222;\n padding: 8px 12px;\n\n border-radius: ${({ theme }: StyledHintTextProp) => theme.cardBorderRadius}px;\n box-shadow: 0 2px 6px 0 rgba(0, 0, 0, ${({ theme }: StyledHintTextProp) => theme.cardShadow});\n`;\n"],"mappings":";;;;;;AACA,IAAAA,iBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAuC,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAIhC,MAAMG,cAAc,GAAAC,OAAA,CAAAD,cAAA,GAAGE,yBAAM,CAACC,GAAwB;AAC7D;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB,CAAC;EAAEC;AAA0B,CAAC,KAAKA,KAAK,CAACC,gBAAiB;AAC/E,4CAA4C,CAAC;EAAED;AAA0B,CAAC,KAAKA,KAAK,CAACE,UAAW;AAChG,CAAC","ignoreList":[]}
|
|
@@ -12,5 +12,9 @@ const StyledOpeningInputs = exports.StyledOpeningInputs = (0, _styledComponents.
|
|
|
12
12
|
flex-direction: column;
|
|
13
13
|
//gap: 8px;
|
|
14
14
|
`;
|
|
15
|
-
const StyledOpeningInputPreview = exports.StyledOpeningInputPreview = _styledComponents.default.div
|
|
15
|
+
const StyledOpeningInputPreview = exports.StyledOpeningInputPreview = _styledComponents.default.div`
|
|
16
|
+
color: ${({
|
|
17
|
+
theme
|
|
18
|
+
}) => theme.text};
|
|
19
|
+
`;
|
|
16
20
|
//# sourceMappingURL=OpeningInputs.styles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpeningInputs.styles.js","names":["_framerMotion","require","_styledComponents","_interopRequireDefault","obj","__esModule","default","StyledOpeningInputs","exports","styled","motion","div","StyledOpeningInputPreview"],"sources":["../../../../../src/components/opening-times/opening-inputs/OpeningInputs.styles.ts"],"sourcesContent":["import { motion } from 'framer-motion';\nimport styled from 'styled-components';\n\nexport const StyledOpeningInputs = styled(motion.div)`\n display: flex;\n flex-direction: column;\n //gap: 8px;\n`;\n\nexport const StyledOpeningInputPreview = styled.div
|
|
1
|
+
{"version":3,"file":"OpeningInputs.styles.js","names":["_framerMotion","require","_styledComponents","_interopRequireDefault","obj","__esModule","default","StyledOpeningInputs","exports","styled","motion","div","StyledOpeningInputPreview","theme","text"],"sources":["../../../../../src/components/opening-times/opening-inputs/OpeningInputs.styles.ts"],"sourcesContent":["import type { WithTheme } from '@chayns-components/core';\nimport { motion } from 'framer-motion';\nimport styled from 'styled-components';\n\nexport const StyledOpeningInputs = styled(motion.div)`\n display: flex;\n flex-direction: column;\n //gap: 8px;\n`;\n\ntype StyledOpeningInputPreviewProps = WithTheme<unknown>;\n\nexport const StyledOpeningInputPreview = styled.div<StyledOpeningInputPreviewProps>`\n color: ${({ theme }: StyledOpeningInputPreviewProps) => theme.text};\n`;\n"],"mappings":";;;;;;AACA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAC,sBAAA,CAAAF,OAAA;AAAuC,SAAAE,uBAAAC,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAEhC,MAAMG,mBAAmB,GAAAC,OAAA,CAAAD,mBAAA,GAAG,IAAAE,yBAAM,EAACC,oBAAM,CAACC,GAAG,CAAE;AACtD;AACA;AACA;AACA,CAAC;AAIM,MAAMC,yBAAyB,GAAAJ,OAAA,CAAAI,yBAAA,GAAGH,yBAAM,CAACE,GAAoC;AACpF,aAAa,CAAC;EAAEE;AAAsC,CAAC,KAAKA,KAAK,CAACC,IAAK;AACvE,CAAC","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Checkbox,
|
|
1
|
+
import { Checkbox, Popup, useElementSize } from '@chayns-components/core';
|
|
2
2
|
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
3
3
|
import { HintTextPosition } from '../../types/openingTimes';
|
|
4
4
|
import HintText from './hint-text/HintText';
|
|
@@ -20,6 +20,7 @@ const OpeningTimes = _ref => {
|
|
|
20
20
|
const [newOpeningTimes, setNewOpeningTimes] = useState();
|
|
21
21
|
const [invalidOpeningTimes, setInvalidOpeningTimes] = useState([]);
|
|
22
22
|
const ref = useRef(null);
|
|
23
|
+
const popupRef = useRef(null);
|
|
23
24
|
useEffect(() => {
|
|
24
25
|
setNewOpeningTimes(openingTimes);
|
|
25
26
|
}, [openingTimes]);
|
|
@@ -177,23 +178,25 @@ const OpeningTimes = _ref => {
|
|
|
177
178
|
weekdayId
|
|
178
179
|
} = singleDay;
|
|
179
180
|
const weekday = weekdays.find(weekDay => weekDay.id === weekdayId)?.name;
|
|
180
|
-
|
|
181
|
+
return /*#__PURE__*/React.createElement(StyledOpeningTimesWrapper, {
|
|
181
182
|
key: `currentDay__${currentDayId}`,
|
|
182
183
|
style: size && {
|
|
183
184
|
width: size.width
|
|
184
|
-
}
|
|
185
|
-
|
|
185
|
+
},
|
|
186
|
+
onMouseEnter: () => popupRef.current?.show(),
|
|
187
|
+
onMouseLeave: () => popupRef.current?.hide()
|
|
188
|
+
}, /*#__PURE__*/React.createElement(Popup, {
|
|
189
|
+
ref: popupRef,
|
|
190
|
+
content: /*#__PURE__*/React.createElement(StyledOpeningTimesTooltipContent, {
|
|
191
|
+
key: "opening-time-tooltip"
|
|
192
|
+
}, content)
|
|
193
|
+
}, /*#__PURE__*/React.createElement(StyledOpeningTimesWeekDay, null, weekday)), /*#__PURE__*/React.createElement(OpeningInputs, {
|
|
186
194
|
closedText: closedText,
|
|
187
195
|
onInvalid: handleUpdateInvalidIds,
|
|
188
196
|
id: id,
|
|
189
197
|
times: times,
|
|
190
198
|
editMode: editMode
|
|
191
199
|
}));
|
|
192
|
-
return /*#__PURE__*/React.createElement(Tooltip, {
|
|
193
|
-
item: /*#__PURE__*/React.createElement(StyledOpeningTimesTooltipContent, {
|
|
194
|
-
key: "opening-time-tooltip"
|
|
195
|
-
}, content)
|
|
196
|
-
}, element);
|
|
197
200
|
}, [currentDayId, editMode, newOpeningTimes, weekdays, size, closedText, handleUpdateInvalidIds, content]);
|
|
198
201
|
const shouldShowHint = useMemo(() => invalidOpeningTimes.length > 0, [invalidOpeningTimes.length]);
|
|
199
202
|
return useMemo(() => /*#__PURE__*/React.createElement(StyledOpeningTimes, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpeningTimes.js","names":["Checkbox","Tooltip","useElementSize","React","useCallback","useEffect","useMemo","useRef","useState","HintTextPosition","HintText","OpeningInputs","StyledOpeningTimes","StyledOpeningTimesTooltipContent","StyledOpeningTimesWeekDay","StyledOpeningTimesWrapper","OpeningTimes","_ref","closedText","currentDayId","editMode","hintText","hintTextPosition","Bottom","openingTimes","weekdays","onChange","onTimeAdd","onTimeRemove","newOpeningTimes","setNewOpeningTimes","invalidOpeningTimes","setInvalidOpeningTimes","ref","handleCheckBoxChange","id","prevOpeningTimes","updatedOpeningTimes","map","openingTime","isDisabled","enabledDays","filter","item","handleChange","newTime","newTimes","times","time","handleAdd","dayId","handleUpdateInvalidIds","openingTimeId","invalidTimeIds","prevState","updatedInvalidOpeningTimes","invalidOpeningTime","some","_ref2","updatedInvalidOpeningId","length","push","updatedInvalidOpeningTime","handleRemove","content","items","forEach","_ref3","weekdayId","weekday","find","weekDay","name","createElement","key","isChecked","onInvalid","onRemove","onAdd","size","displayedContent","singleDay","_ref4","element","style","width","shouldShowHint","Top","text","displayName"],"sources":["../../../../src/components/opening-times/OpeningTimes.tsx"],"sourcesContent":["import { Checkbox, Tooltip, useElementSize } from '@chayns-components/core';\nimport React, {\n FC,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n type ReactElement,\n} from 'react';\nimport {\n HintTextPosition,\n type OnChange,\n type OnTimeAdd,\n type OpeningTime,\n type Time,\n type Weekday,\n} from '../../types/openingTimes';\nimport HintText from './hint-text/HintText';\nimport OpeningInputs from './opening-inputs/OpeningInputs';\nimport {\n StyledOpeningTimes,\n StyledOpeningTimesTooltipContent,\n StyledOpeningTimesWeekDay,\n StyledOpeningTimesWrapper,\n} from './OpeningTimes.styles';\n\nexport type OpeningTimesProps = {\n /**\n * The text that should be displayed when a day is closed.\n */\n closedText?: string;\n /**\n * If set just the current day is displayed and the whole week in a tooltip.\n */\n currentDayId?: OpeningTime['id'];\n /**\n * Whether the opening times can be edited.\n */\n editMode?: boolean;\n /**\n * The text that should be displayed if times are colliding.\n */\n hintText?: string;\n /**\n * The position of the hint text.\n */\n hintTextPosition?: HintTextPosition;\n /**\n * Function to be executed when a time is changed or a day is enabled/disabled.\n * @param openingTimes\n */\n onChange?: ({ time, enabledDays }: OnChange) => void;\n /**\n * Function to be executed when a time is added.\n */\n onTimeAdd?: ({ time, dayId }: OnTimeAdd) => void;\n /**\n * Function to be executed when a time is removed.\n */\n onTimeRemove?: (id: string) => void;\n /**\n * The opening times corresponding to its weekday.\n */\n openingTimes: OpeningTime[];\n /**\n * The weekdays that should be displayed.\n */\n weekdays: Weekday[];\n};\n\nconst OpeningTimes: FC<OpeningTimesProps> = ({\n closedText = 'closed',\n currentDayId,\n editMode = false,\n hintText,\n hintTextPosition = HintTextPosition.Bottom,\n openingTimes,\n weekdays,\n onChange,\n onTimeAdd,\n onTimeRemove,\n}) => {\n const [newOpeningTimes, setNewOpeningTimes] = useState<OpeningTime[]>();\n const [invalidOpeningTimes, setInvalidOpeningTimes] = useState<\n { openingTimeId: string; invalidTimeIds: string[] }[]\n >([]);\n\n const ref = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n setNewOpeningTimes(openingTimes);\n }, [openingTimes]);\n\n const handleCheckBoxChange = useCallback(\n (id: string) => {\n setNewOpeningTimes((prevOpeningTimes) => {\n const updatedOpeningTimes = (prevOpeningTimes ?? []).map((openingTime) => {\n if (openingTime.id === id) {\n return { ...openingTime, isDisabled: !openingTime.isDisabled };\n }\n return openingTime;\n });\n\n if (typeof onChange === 'function') {\n onChange({\n enabledDays: updatedOpeningTimes\n .filter((item) => !item.isDisabled)\n .map((item) => item.id),\n });\n }\n\n return updatedOpeningTimes;\n });\n },\n [onChange],\n );\n\n const handleChange = useCallback(\n (newTime: Time, id: string) => {\n setNewOpeningTimes((prevOpeningTimes) => {\n const updatedOpeningTimes = (prevOpeningTimes ?? []).map((openingTime) => {\n if (openingTime.id === id) {\n const newTimes = openingTime.times.map((time) => {\n if (time.id === newTime.id) {\n return newTime;\n }\n\n return time;\n });\n\n return { ...openingTime, times: newTimes };\n }\n return openingTime;\n });\n\n if (typeof onChange === 'function') {\n onChange({ time: newTime });\n }\n\n return updatedOpeningTimes;\n });\n },\n [onChange],\n );\n\n const handleAdd = useCallback(\n (time: Time, id: string) => {\n setNewOpeningTimes((prevOpeningTimes) =>\n (prevOpeningTimes ?? []).map((openingTime) => {\n if (openingTime.id === id) {\n return { ...openingTime, times: [...openingTime.times, time] };\n }\n return openingTime;\n }),\n );\n\n if (typeof onTimeAdd === 'function') {\n onTimeAdd({ dayId: id, time });\n }\n },\n [onTimeAdd],\n );\n\n const handleUpdateInvalidIds = useCallback(\n (openingTimeId: string, invalidTimeIds: string[]) => {\n setInvalidOpeningTimes((prevState) => {\n let updatedInvalidOpeningTimes = prevState.map((invalidOpeningTime) => {\n if (invalidOpeningTime.openingTimeId === openingTimeId) {\n return {\n openingTimeId,\n invalidTimeIds,\n };\n }\n\n return invalidOpeningTime;\n });\n\n if (\n !updatedInvalidOpeningTimes.some(\n ({ openingTimeId: updatedInvalidOpeningId }) =>\n updatedInvalidOpeningId === openingTimeId,\n ) &&\n invalidTimeIds.length > 0\n ) {\n updatedInvalidOpeningTimes.push({ openingTimeId, invalidTimeIds });\n }\n\n updatedInvalidOpeningTimes = updatedInvalidOpeningTimes.filter(\n (updatedInvalidOpeningTime) =>\n updatedInvalidOpeningTime.invalidTimeIds.length !== 0,\n );\n\n return updatedInvalidOpeningTimes;\n });\n },\n [],\n );\n\n const handleRemove = useCallback(\n (id: string) => {\n setNewOpeningTimes((prevOpeningTimes) =>\n (prevOpeningTimes ?? []).map((openingTime) => {\n const newTimes = openingTime.times.filter((time) => time.id !== id);\n\n return { ...openingTime, times: newTimes };\n }),\n );\n\n if (typeof onTimeRemove === 'function') {\n onTimeRemove(id);\n }\n },\n [onTimeRemove],\n );\n\n const content = useMemo(() => {\n const items: ReactElement[] = [];\n\n if (!newOpeningTimes) {\n return items;\n }\n\n newOpeningTimes.forEach(({ times, id, weekdayId, isDisabled }) => {\n const weekday = weekdays.find((weekDay) => weekDay.id === weekdayId)?.name;\n\n if (!weekday) {\n return;\n }\n\n items.push(\n <StyledOpeningTimesWrapper key={`openingTimes__${id}`}>\n {editMode ? (\n <Checkbox isChecked={!isDisabled} onChange={() => handleCheckBoxChange(id)}>\n {weekday}\n </Checkbox>\n ) : (\n <StyledOpeningTimesWeekDay>{weekday}</StyledOpeningTimesWeekDay>\n )}\n <OpeningInputs\n closedText={closedText}\n id={id}\n times={times}\n isDisabled={isDisabled}\n onInvalid={handleUpdateInvalidIds}\n onChange={(newTime) => handleChange(newTime, id)}\n onRemove={handleRemove}\n onAdd={handleAdd}\n editMode={editMode}\n />\n </StyledOpeningTimesWrapper>,\n );\n });\n\n return items;\n }, [\n closedText,\n editMode,\n handleAdd,\n handleChange,\n handleCheckBoxChange,\n handleRemove,\n handleUpdateInvalidIds,\n newOpeningTimes,\n weekdays,\n ]);\n\n const size = useElementSize(ref);\n\n const displayedContent = useMemo(() => {\n if (!currentDayId || editMode) {\n return content;\n }\n\n const singleDay = newOpeningTimes?.find(({ id }) => id === currentDayId);\n\n if (!singleDay) {\n return content;\n }\n\n const { id, times, weekdayId } = singleDay;\n\n const weekday = weekdays.find((weekDay) => weekDay.id === weekdayId)?.name;\n\n const element = (\n <StyledOpeningTimesWrapper\n key={`currentDay__${currentDayId}`}\n style={size && { width: size.width }}\n >\n <StyledOpeningTimesWeekDay>{weekday}</StyledOpeningTimesWeekDay>\n <OpeningInputs\n closedText={closedText}\n onInvalid={handleUpdateInvalidIds}\n id={id}\n times={times}\n editMode={editMode}\n />\n </StyledOpeningTimesWrapper>\n );\n\n return (\n <Tooltip\n item={\n <StyledOpeningTimesTooltipContent key=\"opening-time-tooltip\">\n {content}\n </StyledOpeningTimesTooltipContent>\n }\n >\n {element}\n </Tooltip>\n );\n }, [\n currentDayId,\n editMode,\n newOpeningTimes,\n weekdays,\n size,\n closedText,\n handleUpdateInvalidIds,\n content,\n ]);\n\n const shouldShowHint = useMemo(\n () => invalidOpeningTimes.length > 0,\n [invalidOpeningTimes.length],\n );\n\n return useMemo(\n () => (\n <StyledOpeningTimes ref={ref}>\n {shouldShowHint && hintText && hintTextPosition === HintTextPosition.Top && (\n <HintText text={hintText} />\n )}\n {displayedContent}\n {shouldShowHint && hintText && hintTextPosition === HintTextPosition.Bottom && (\n <HintText text={hintText} />\n )}\n </StyledOpeningTimes>\n ),\n [displayedContent, hintText, hintTextPosition, shouldShowHint],\n );\n};\n\nOpeningTimes.displayName = 'OpeningTimes';\n\nexport default OpeningTimes;\n"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,OAAO,EAAEC,cAAc,QAAQ,yBAAyB;AAC3E,OAAOC,KAAK,IAERC,WAAW,EACXC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,QAAQ,QAEL,OAAO;AACd,SACIC,gBAAgB,QAMb,0BAA0B;AACjC,OAAOC,QAAQ,MAAM,sBAAsB;AAC3C,OAAOC,aAAa,MAAM,gCAAgC;AAC1D,SACIC,kBAAkB,EAClBC,gCAAgC,EAChCC,yBAAyB,EACzBC,yBAAyB,QACtB,uBAAuB;AA8C9B,MAAMC,YAAmC,GAAGC,IAAA,IAWtC;EAAA,IAXuC;IACzCC,UAAU,GAAG,QAAQ;IACrBC,YAAY;IACZC,QAAQ,GAAG,KAAK;IAChBC,QAAQ;IACRC,gBAAgB,GAAGb,gBAAgB,CAACc,MAAM;IAC1CC,YAAY;IACZC,QAAQ;IACRC,QAAQ;IACRC,SAAS;IACTC;EACJ,CAAC,GAAAX,IAAA;EACG,MAAM,CAACY,eAAe,EAAEC,kBAAkB,CAAC,GAAGtB,QAAQ,CAAgB,CAAC;EACvE,MAAM,CAACuB,mBAAmB,EAAEC,sBAAsB,CAAC,GAAGxB,QAAQ,CAE5D,EAAE,CAAC;EAEL,MAAMyB,GAAG,GAAG1B,MAAM,CAAiB,IAAI,CAAC;EAExCF,SAAS,CAAC,MAAM;IACZ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AO,CACV,mBACIH,KAAA,CAAAsE,aAAA,CAAC7D,kBAAkB;IAACqB,GAAG,EAAEA;EAAI,GACxBqD,cAAc,IAAIjE,QAAQ,IAAIC,gBAAgB,KAAKb,gBAAgB,CAAC8E,GAAG,iBACpEpF,KAAA,CAAAsE,aAAA,CAAC/D,QAAQ;IAAC8E,IAAI,EAAEnE;EAAS,CAAE,CAC9B,EACA2D,gBAAgB,EAChBM,cAAc,IAAIjE,QAAQ,IAAIC,gBAAgB,KAAKb,gBAAgB,CAACc,MAAM,iBACvEpB,KAAA,CAAAsE,aAAA,CAAC/D,QAAQ;IAAC8E,IAAI,EAAEnE;EAAS,CAAE,CAEf,CACvB,EACD,CAAC2D,gBAAgB,EAAE3D,QAAQ,EAAEC,gBAAgB,EAAEgE,cAAc,CACjE,CAAC;AACL,CAAC;AAEDtE,YAAY,CAACyE,WAAW,GAAG,cAAc;AAEzC,eAAezE,YAAY","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"OpeningTimes.js","names":["Checkbox","Popup","useElementSize","React","useCallback","useEffect","useMemo","useRef","useState","HintTextPosition","HintText","OpeningInputs","StyledOpeningTimes","StyledOpeningTimesTooltipContent","StyledOpeningTimesWeekDay","StyledOpeningTimesWrapper","OpeningTimes","_ref","closedText","currentDayId","editMode","hintText","hintTextPosition","Bottom","openingTimes","weekdays","onChange","onTimeAdd","onTimeRemove","newOpeningTimes","setNewOpeningTimes","invalidOpeningTimes","setInvalidOpeningTimes","ref","popupRef","handleCheckBoxChange","id","prevOpeningTimes","updatedOpeningTimes","map","openingTime","isDisabled","enabledDays","filter","item","handleChange","newTime","newTimes","times","time","handleAdd","dayId","handleUpdateInvalidIds","openingTimeId","invalidTimeIds","prevState","updatedInvalidOpeningTimes","invalidOpeningTime","some","_ref2","updatedInvalidOpeningId","length","push","updatedInvalidOpeningTime","handleRemove","content","items","forEach","_ref3","weekdayId","weekday","find","weekDay","name","createElement","key","isChecked","onInvalid","onRemove","onAdd","size","displayedContent","singleDay","_ref4","style","width","onMouseEnter","current","show","onMouseLeave","hide","shouldShowHint","Top","text","displayName"],"sources":["../../../../src/components/opening-times/OpeningTimes.tsx"],"sourcesContent":["import { Checkbox, Popup, useElementSize, type PopupRef } from '@chayns-components/core';\nimport React, {\n FC,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n type ReactElement,\n} from 'react';\nimport {\n HintTextPosition,\n type OnChange,\n type OnTimeAdd,\n type OpeningTime,\n type Time,\n type Weekday,\n} from '../../types/openingTimes';\nimport HintText from './hint-text/HintText';\nimport OpeningInputs from './opening-inputs/OpeningInputs';\nimport {\n StyledOpeningTimes,\n StyledOpeningTimesTooltipContent,\n StyledOpeningTimesWeekDay,\n StyledOpeningTimesWrapper,\n} from './OpeningTimes.styles';\n\nexport type OpeningTimesProps = {\n /**\n * The text that should be displayed when a day is closed.\n */\n closedText?: string;\n /**\n * If set just the current day is displayed and the whole week in a tooltip.\n */\n currentDayId?: OpeningTime['id'];\n /**\n * Whether the opening times can be edited.\n */\n editMode?: boolean;\n /**\n * The text that should be displayed if times are colliding.\n */\n hintText?: string;\n /**\n * The position of the hint text.\n */\n hintTextPosition?: HintTextPosition;\n /**\n * Function to be executed when a time is changed or a day is enabled/disabled.\n * @param openingTimes\n */\n onChange?: ({ time, enabledDays }: OnChange) => void;\n /**\n * Function to be executed when a time is added.\n */\n onTimeAdd?: ({ time, dayId }: OnTimeAdd) => void;\n /**\n * Function to be executed when a time is removed.\n */\n onTimeRemove?: (id: string) => void;\n /**\n * The opening times corresponding to its weekday.\n */\n openingTimes: OpeningTime[];\n /**\n * The weekdays that should be displayed.\n */\n weekdays: Weekday[];\n};\n\nconst OpeningTimes: FC<OpeningTimesProps> = ({\n closedText = 'closed',\n currentDayId,\n editMode = false,\n hintText,\n hintTextPosition = HintTextPosition.Bottom,\n openingTimes,\n weekdays,\n onChange,\n onTimeAdd,\n onTimeRemove,\n}) => {\n const [newOpeningTimes, setNewOpeningTimes] = useState<OpeningTime[]>();\n const [invalidOpeningTimes, setInvalidOpeningTimes] = useState<\n { openingTimeId: string; invalidTimeIds: string[] }[]\n >([]);\n\n const ref = useRef<HTMLDivElement>(null);\n const popupRef = useRef<PopupRef>(null);\n\n useEffect(() => {\n setNewOpeningTimes(openingTimes);\n }, [openingTimes]);\n\n const handleCheckBoxChange = useCallback(\n (id: string) => {\n setNewOpeningTimes((prevOpeningTimes) => {\n const updatedOpeningTimes = (prevOpeningTimes ?? []).map((openingTime) => {\n if (openingTime.id === id) {\n return { ...openingTime, isDisabled: !openingTime.isDisabled };\n }\n return openingTime;\n });\n\n if (typeof onChange === 'function') {\n onChange({\n enabledDays: updatedOpeningTimes\n .filter((item) => !item.isDisabled)\n .map((item) => item.id),\n });\n }\n\n return updatedOpeningTimes;\n });\n },\n [onChange],\n );\n\n const handleChange = useCallback(\n (newTime: Time, id: string) => {\n setNewOpeningTimes((prevOpeningTimes) => {\n const updatedOpeningTimes = (prevOpeningTimes ?? []).map((openingTime) => {\n if (openingTime.id === id) {\n const newTimes = openingTime.times.map((time) => {\n if (time.id === newTime.id) {\n return newTime;\n }\n\n return time;\n });\n\n return { ...openingTime, times: newTimes };\n }\n return openingTime;\n });\n\n if (typeof onChange === 'function') {\n onChange({ time: newTime });\n }\n\n return updatedOpeningTimes;\n });\n },\n [onChange],\n );\n\n const handleAdd = useCallback(\n (time: Time, id: string) => {\n setNewOpeningTimes((prevOpeningTimes) =>\n (prevOpeningTimes ?? []).map((openingTime) => {\n if (openingTime.id === id) {\n return { ...openingTime, times: [...openingTime.times, time] };\n }\n return openingTime;\n }),\n );\n\n if (typeof onTimeAdd === 'function') {\n onTimeAdd({ dayId: id, time });\n }\n },\n [onTimeAdd],\n );\n\n const handleUpdateInvalidIds = useCallback(\n (openingTimeId: string, invalidTimeIds: string[]) => {\n setInvalidOpeningTimes((prevState) => {\n let updatedInvalidOpeningTimes = prevState.map((invalidOpeningTime) => {\n if (invalidOpeningTime.openingTimeId === openingTimeId) {\n return {\n openingTimeId,\n invalidTimeIds,\n };\n }\n\n return invalidOpeningTime;\n });\n\n if (\n !updatedInvalidOpeningTimes.some(\n ({ openingTimeId: updatedInvalidOpeningId }) =>\n updatedInvalidOpeningId === openingTimeId,\n ) &&\n invalidTimeIds.length > 0\n ) {\n updatedInvalidOpeningTimes.push({ openingTimeId, invalidTimeIds });\n }\n\n updatedInvalidOpeningTimes = updatedInvalidOpeningTimes.filter(\n (updatedInvalidOpeningTime) =>\n updatedInvalidOpeningTime.invalidTimeIds.length !== 0,\n );\n\n return updatedInvalidOpeningTimes;\n });\n },\n [],\n );\n\n const handleRemove = useCallback(\n (id: string) => {\n setNewOpeningTimes((prevOpeningTimes) =>\n (prevOpeningTimes ?? []).map((openingTime) => {\n const newTimes = openingTime.times.filter((time) => time.id !== id);\n\n return { ...openingTime, times: newTimes };\n }),\n );\n\n if (typeof onTimeRemove === 'function') {\n onTimeRemove(id);\n }\n },\n [onTimeRemove],\n );\n\n const content = useMemo(() => {\n const items: ReactElement[] = [];\n\n if (!newOpeningTimes) {\n return items;\n }\n\n newOpeningTimes.forEach(({ times, id, weekdayId, isDisabled }) => {\n const weekday = weekdays.find((weekDay) => weekDay.id === weekdayId)?.name;\n\n if (!weekday) {\n return;\n }\n\n items.push(\n <StyledOpeningTimesWrapper key={`openingTimes__${id}`}>\n {editMode ? (\n <Checkbox isChecked={!isDisabled} onChange={() => handleCheckBoxChange(id)}>\n {weekday}\n </Checkbox>\n ) : (\n <StyledOpeningTimesWeekDay>{weekday}</StyledOpeningTimesWeekDay>\n )}\n <OpeningInputs\n closedText={closedText}\n id={id}\n times={times}\n isDisabled={isDisabled}\n onInvalid={handleUpdateInvalidIds}\n onChange={(newTime) => handleChange(newTime, id)}\n onRemove={handleRemove}\n onAdd={handleAdd}\n editMode={editMode}\n />\n </StyledOpeningTimesWrapper>,\n );\n });\n\n return items;\n }, [\n closedText,\n editMode,\n handleAdd,\n handleChange,\n handleCheckBoxChange,\n handleRemove,\n handleUpdateInvalidIds,\n newOpeningTimes,\n weekdays,\n ]);\n\n const size = useElementSize(ref);\n\n const displayedContent = useMemo(() => {\n if (!currentDayId || editMode) {\n return content;\n }\n\n const singleDay = newOpeningTimes?.find(({ id }) => id === currentDayId);\n\n if (!singleDay) {\n return content;\n }\n\n const { id, times, weekdayId } = singleDay;\n\n const weekday = weekdays.find((weekDay) => weekDay.id === weekdayId)?.name;\n\n return (\n <StyledOpeningTimesWrapper\n key={`currentDay__${currentDayId}`}\n style={size && { width: size.width }}\n onMouseEnter={() => popupRef.current?.show()}\n onMouseLeave={() => popupRef.current?.hide()}\n >\n <Popup\n ref={popupRef}\n content={\n <StyledOpeningTimesTooltipContent key=\"opening-time-tooltip\">\n {content}\n </StyledOpeningTimesTooltipContent>\n }\n >\n <StyledOpeningTimesWeekDay>{weekday}</StyledOpeningTimesWeekDay>\n </Popup>\n <OpeningInputs\n closedText={closedText}\n onInvalid={handleUpdateInvalidIds}\n id={id}\n times={times}\n editMode={editMode}\n />\n </StyledOpeningTimesWrapper>\n );\n }, [\n currentDayId,\n editMode,\n newOpeningTimes,\n weekdays,\n size,\n closedText,\n handleUpdateInvalidIds,\n content,\n ]);\n\n const shouldShowHint = useMemo(\n () => invalidOpeningTimes.length > 0,\n [invalidOpeningTimes.length],\n );\n\n return useMemo(\n () => (\n <StyledOpeningTimes ref={ref}>\n {shouldShowHint && hintText && hintTextPosition === HintTextPosition.Top && (\n <HintText text={hintText} />\n )}\n {displayedContent}\n {shouldShowHint && hintText && hintTextPosition === HintTextPosition.Bottom && (\n <HintText text={hintText} />\n )}\n </StyledOpeningTimes>\n ),\n [displayedContent, hintText, hintTextPosition, shouldShowHint],\n );\n};\n\nOpeningTimes.displayName = 'OpeningTimes';\n\nexport default OpeningTimes;\n"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,KAAK,EAAEC,cAAc,QAAuB,yBAAyB;AACxF,OAAOC,KAAK,IAERC,WAAW,EACXC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,QAAQ,QAEL,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ACc,MAAM,iBACvEpB,KAAA,CAAAuE,aAAA,CAAChE,QAAQ;IAACmF,IAAI,EAAExE;EAAS,CAAE,CAEf,CACvB,EACD,CAAC4D,gBAAgB,EAAE5D,QAAQ,EAAEC,gBAAgB,EAAEqE,cAAc,CACjE,CAAC;AACL,CAAC;AAED3E,YAAY,CAAC8E,WAAW,GAAG,cAAc;AAEzC,eAAe9E,YAAY","ignoreList":[]}
|
|
@@ -4,24 +4,19 @@ export const StyledHintText = styled.div`
|
|
|
4
4
|
border-style: solid;
|
|
5
5
|
border-color: #9f5f00;
|
|
6
6
|
background-color: #fff3e0;
|
|
7
|
-
color:
|
|
8
|
-
let {
|
|
9
|
-
theme
|
|
10
|
-
} = _ref;
|
|
11
|
-
return theme.text;
|
|
12
|
-
}};
|
|
7
|
+
color: #222;
|
|
13
8
|
padding: 8px 12px;
|
|
14
9
|
|
|
15
|
-
border-radius: ${
|
|
10
|
+
border-radius: ${_ref => {
|
|
16
11
|
let {
|
|
17
12
|
theme
|
|
18
|
-
} =
|
|
13
|
+
} = _ref;
|
|
19
14
|
return theme.cardBorderRadius;
|
|
20
15
|
}}px;
|
|
21
|
-
box-shadow: 0 2px 6px 0 rgba(0, 0, 0, ${
|
|
16
|
+
box-shadow: 0 2px 6px 0 rgba(0, 0, 0, ${_ref2 => {
|
|
22
17
|
let {
|
|
23
18
|
theme
|
|
24
|
-
} =
|
|
19
|
+
} = _ref2;
|
|
25
20
|
return theme.cardShadow;
|
|
26
21
|
}});
|
|
27
22
|
`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HintText.styles.js","names":["styled","StyledHintText","div","_ref","theme","
|
|
1
|
+
{"version":3,"file":"HintText.styles.js","names":["styled","StyledHintText","div","_ref","theme","cardBorderRadius","_ref2","cardShadow"],"sources":["../../../../../src/components/opening-times/hint-text/HintText.styles.ts"],"sourcesContent":["import type { WithTheme } from '@chayns-components/core';\nimport styled from 'styled-components';\n\ntype StyledHintTextProp = WithTheme<unknown>;\n\nexport const StyledHintText = styled.div<StyledHintTextProp>`\n border-width: 1px;\n border-style: solid;\n border-color: #9f5f00;\n background-color: #fff3e0;\n color: #222;\n padding: 8px 12px;\n\n border-radius: ${({ theme }: StyledHintTextProp) => theme.cardBorderRadius}px;\n box-shadow: 0 2px 6px 0 rgba(0, 0, 0, ${({ theme }: StyledHintTextProp) => theme.cardShadow});\n`;\n"],"mappings":"AACA,OAAOA,MAAM,MAAM,mBAAmB;AAItC,OAAO,MAAMC,cAAc,GAAGD,MAAM,CAACE,GAAwB;AAC7D;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqBC,IAAA;EAAA,IAAC;IAAEC;EAA0B,CAAC,GAAAD,IAAA;EAAA,OAAKC,KAAK,CAACC,gBAAgB;AAAA,CAAC;AAC/E,4CAA4CC,KAAA;EAAA,IAAC;IAAEF;EAA0B,CAAC,GAAAE,KAAA;EAAA,OAAKF,KAAK,CAACG,UAAU;AAAA,CAAC;AAChG,CAAC","ignoreList":[]}
|
|
@@ -5,5 +5,12 @@ export const StyledOpeningInputs = styled(motion.div)`
|
|
|
5
5
|
flex-direction: column;
|
|
6
6
|
//gap: 8px;
|
|
7
7
|
`;
|
|
8
|
-
export const StyledOpeningInputPreview = styled.div
|
|
8
|
+
export const StyledOpeningInputPreview = styled.div`
|
|
9
|
+
color: ${_ref => {
|
|
10
|
+
let {
|
|
11
|
+
theme
|
|
12
|
+
} = _ref;
|
|
13
|
+
return theme.text;
|
|
14
|
+
}};
|
|
15
|
+
`;
|
|
9
16
|
//# sourceMappingURL=OpeningInputs.styles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpeningInputs.styles.js","names":["motion","styled","StyledOpeningInputs","div","StyledOpeningInputPreview"],"sources":["../../../../../src/components/opening-times/opening-inputs/OpeningInputs.styles.ts"],"sourcesContent":["import { motion } from 'framer-motion';\nimport styled from 'styled-components';\n\nexport const StyledOpeningInputs = styled(motion.div)`\n display: flex;\n flex-direction: column;\n //gap: 8px;\n`;\n\nexport const StyledOpeningInputPreview = styled.div
|
|
1
|
+
{"version":3,"file":"OpeningInputs.styles.js","names":["motion","styled","StyledOpeningInputs","div","StyledOpeningInputPreview","_ref","theme","text"],"sources":["../../../../../src/components/opening-times/opening-inputs/OpeningInputs.styles.ts"],"sourcesContent":["import type { WithTheme } from '@chayns-components/core';\nimport { motion } from 'framer-motion';\nimport styled from 'styled-components';\n\nexport const StyledOpeningInputs = styled(motion.div)`\n display: flex;\n flex-direction: column;\n //gap: 8px;\n`;\n\ntype StyledOpeningInputPreviewProps = WithTheme<unknown>;\n\nexport const StyledOpeningInputPreview = styled.div<StyledOpeningInputPreviewProps>`\n color: ${({ theme }: StyledOpeningInputPreviewProps) => theme.text};\n`;\n"],"mappings":"AACA,SAASA,MAAM,QAAQ,eAAe;AACtC,OAAOC,MAAM,MAAM,mBAAmB;AAEtC,OAAO,MAAMC,mBAAmB,GAAGD,MAAM,CAACD,MAAM,CAACG,GAAG,CAAE;AACtD;AACA;AACA;AACA,CAAC;AAID,OAAO,MAAMC,yBAAyB,GAAGH,MAAM,CAACE,GAAoC;AACpF,aAAaE,IAAA;EAAA,IAAC;IAAEC;EAAsC,CAAC,GAAAD,IAAA;EAAA,OAAKC,KAAK,CAACC,IAAI;AAAA,CAAC;AACvE,CAAC","ignoreList":[]}
|
|
@@ -263,4 +263,6 @@ export declare const StyledOpeningInputs: import("styled-components").IStyledCom
|
|
|
263
263
|
} & import("framer-motion").MotionProps & import("react").RefAttributes<HTMLDivElement>, "ref"> & {
|
|
264
264
|
ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
|
|
265
265
|
}, never>> & Omit<import("framer-motion").ForwardRefComponent<HTMLDivElement, import("framer-motion").HTMLMotionProps<"div">>, keyof import("react").Component<any, {}, any>>;
|
|
266
|
-
export declare const StyledOpeningInputPreview: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").
|
|
266
|
+
export declare const StyledOpeningInputPreview: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
|
|
267
|
+
theme: import("@chayns-components/core/lib/types/components/color-scheme-provider/ColorSchemeProvider").Theme;
|
|
268
|
+
}>>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chayns-components/date",
|
|
3
|
-
"version": "5.0.0-beta.
|
|
3
|
+
"version": "5.0.0-beta.588",
|
|
4
4
|
"description": "A set of beautiful React components for developing your own applications with chayns.",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"browserslist": [
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"typescript": "^5.4.5"
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
|
-
"@chayns-components/core": "^5.0.0-beta.
|
|
70
|
+
"@chayns-components/core": "^5.0.0-beta.588",
|
|
71
71
|
"date-fns": "^2.30.0",
|
|
72
72
|
"uuid": "^9.0.1"
|
|
73
73
|
},
|
|
@@ -81,5 +81,5 @@
|
|
|
81
81
|
"publishConfig": {
|
|
82
82
|
"access": "public"
|
|
83
83
|
},
|
|
84
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "b9221aca396a2b31d289b677d5cb21b67938df02"
|
|
85
85
|
}
|