sag_components 2.0.0-beta195 → 2.0.0-beta197
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/index.d.ts +3 -1
- package/dist/index.esm.js +145 -31
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +145 -31
- package/dist/index.js.map +1 -1
- package/dist/types/components/WeeksPicker/WeeksCalendar.d.ts +16 -6
- package/dist/types/components/WeeksPicker/WeeksPicker.d.ts +3 -1
- package/dist/types/components/WeeksPicker/WeeksPicker.stories.d.ts +33 -13
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1282,7 +1282,7 @@ declare function ModalWithOverlay(props: any): react_jsx_runtime.JSX.Element;
|
|
|
1282
1282
|
|
|
1283
1283
|
declare function DropdownNew(props: any): react_jsx_runtime.JSX.Element;
|
|
1284
1284
|
|
|
1285
|
-
declare function WeeksPicker({ label, disabled, borderColor, borderColorFocus, textColor, hoverColor, required, placeholder, borderRadius, year, width, height, withMarginBottom, onChange, selectedValue, }: {
|
|
1285
|
+
declare function WeeksPicker({ label, disabled, borderColor, borderColorFocus, textColor, hoverColor, required, placeholder, borderRadius, year, width, height, withMarginBottom, onChange, selectedValue, allowedWeekRange, restrictToRange, }: {
|
|
1286
1286
|
label: any;
|
|
1287
1287
|
disabled: any;
|
|
1288
1288
|
borderColor: any;
|
|
@@ -1298,6 +1298,8 @@ declare function WeeksPicker({ label, disabled, borderColor, borderColorFocus, t
|
|
|
1298
1298
|
withMarginBottom?: boolean;
|
|
1299
1299
|
onChange: any;
|
|
1300
1300
|
selectedValue: any;
|
|
1301
|
+
allowedWeekRange?: any;
|
|
1302
|
+
restrictToRange?: boolean;
|
|
1301
1303
|
}): react_jsx_runtime.JSX.Element;
|
|
1302
1304
|
|
|
1303
1305
|
declare function Input({ label, labelEmptyValue, size, selectedValue, placeHolder, onChange, onClick, onBlur, required, disabled, isDarkerBackground, width, height, error, errorMessage, labelColor, leftIcon, rightIcon, password, leftIconOnClick, rightIconOnClick, multiline, rows, maxLength, }: {
|
package/dist/index.esm.js
CHANGED
|
@@ -12252,13 +12252,16 @@ const Td$1 = styled.td`
|
|
|
12252
12252
|
`;
|
|
12253
12253
|
const Tr = styled.tr`
|
|
12254
12254
|
border-bottom: 1px solid #f3f4f6;
|
|
12255
|
-
${
|
|
12256
|
-
|
|
12257
|
-
|
|
12258
|
-
|
|
12255
|
+
${_ref => {
|
|
12256
|
+
let {
|
|
12257
|
+
enableHover,
|
|
12258
|
+
selectHoverColor
|
|
12259
|
+
} = _ref;
|
|
12260
|
+
return enableHover && `&:hover {
|
|
12259
12261
|
background-color: ${selectHoverColor};
|
|
12260
12262
|
cursor: pointer;
|
|
12261
|
-
}
|
|
12263
|
+
}`;
|
|
12264
|
+
}}
|
|
12262
12265
|
`;
|
|
12263
12266
|
const InfoText = styled.div`
|
|
12264
12267
|
font-weight: 400;
|
|
@@ -34719,6 +34722,8 @@ const ModalWithOverlay = props => {
|
|
|
34719
34722
|
}, children)));
|
|
34720
34723
|
};
|
|
34721
34724
|
|
|
34725
|
+
// src/components/WeeksPicker/WeeksCalendar.styles.js
|
|
34726
|
+
|
|
34722
34727
|
/* ──────────────────────────────────────────
|
|
34723
34728
|
COLORS – map to your design-system tokens
|
|
34724
34729
|
Change only here if the palette shifts
|
|
@@ -34730,7 +34735,9 @@ const c = {
|
|
|
34730
34735
|
primary: "#016672",
|
|
34731
34736
|
// apply / highlight
|
|
34732
34737
|
primaryLight: "#d1e7ea",
|
|
34733
|
-
border: "#e0e0e0"
|
|
34738
|
+
border: "#e0e0e0",
|
|
34739
|
+
disabled: "#f5f5f5",
|
|
34740
|
+
disabledText: "#bdbdbd"
|
|
34734
34741
|
};
|
|
34735
34742
|
|
|
34736
34743
|
/* ───────────────────────── wrapper */
|
|
@@ -34770,34 +34777,56 @@ const WeekCell = styled.div`
|
|
|
34770
34777
|
text-align: center;
|
|
34771
34778
|
cursor: pointer;
|
|
34772
34779
|
color: ${c.textSecondary};
|
|
34773
|
-
transition: background 0.15s ease;
|
|
34774
|
-
|
|
34780
|
+
transition: background 0.15s ease, opacity 0.15s ease, color 0.15s ease;
|
|
34781
|
+
border-radius: 4px;
|
|
34775
34782
|
|
|
34783
|
+
/* Disabled state - highest priority */
|
|
34776
34784
|
${({
|
|
34777
|
-
$
|
|
34778
|
-
}) => $
|
|
34785
|
+
$disabled
|
|
34786
|
+
}) => $disabled && css`
|
|
34787
|
+
opacity: 0.3;
|
|
34788
|
+
cursor: not-allowed;
|
|
34789
|
+
background: ${c.disabled} !important;
|
|
34790
|
+
color: ${c.disabledText} !important;
|
|
34791
|
+
|
|
34792
|
+
&:hover {
|
|
34793
|
+
background: ${c.disabled} !important;
|
|
34794
|
+
color: ${c.disabledText} !important;
|
|
34795
|
+
}
|
|
34796
|
+
`}
|
|
34779
34797
|
|
|
34798
|
+
/* Selected state - only if not disabled */
|
|
34799
|
+
${({
|
|
34800
|
+
$selected,
|
|
34801
|
+
$disabled
|
|
34802
|
+
}) => $selected && !$disabled && css`
|
|
34780
34803
|
background: ${c.primary};
|
|
34781
34804
|
color: #FFFFFF;
|
|
34782
34805
|
`}
|
|
34783
34806
|
|
|
34784
|
-
/*
|
|
34807
|
+
/* Range middle highlighting - only if not disabled */
|
|
34785
34808
|
${({
|
|
34786
|
-
$isRangeMiddle
|
|
34787
|
-
|
|
34809
|
+
$isRangeMiddle,
|
|
34810
|
+
$disabled
|
|
34811
|
+
}) => $isRangeMiddle && !$disabled && css`
|
|
34788
34812
|
background: ${c.primaryLight};
|
|
34789
34813
|
border-radius: 0px;
|
|
34790
34814
|
color: ${c.text};
|
|
34791
34815
|
`}
|
|
34792
34816
|
|
|
34793
|
-
|
|
34794
|
-
|
|
34795
|
-
|
|
34796
|
-
|
|
34817
|
+
/* Hover state - only if not disabled */
|
|
34818
|
+
${({
|
|
34819
|
+
$disabled
|
|
34820
|
+
}) => !$disabled && css`
|
|
34821
|
+
&:hover {
|
|
34822
|
+
background: ${c.primaryLight};
|
|
34823
|
+
color: ${c.text};
|
|
34824
|
+
}
|
|
34825
|
+
`}
|
|
34826
|
+
|
|
34827
|
+
/* Typography */
|
|
34797
34828
|
text-align: center;
|
|
34798
34829
|
font-feature-settings: "liga" off;
|
|
34799
|
-
|
|
34800
|
-
/* Content/P3 Regular */
|
|
34801
34830
|
font-family: Poppins;
|
|
34802
34831
|
font-size: 12px;
|
|
34803
34832
|
font-style: normal;
|
|
@@ -34830,15 +34859,20 @@ css`
|
|
|
34830
34859
|
}
|
|
34831
34860
|
`;
|
|
34832
34861
|
|
|
34862
|
+
// src/components/WeeksPicker/WeeksCalendar.jsx
|
|
34863
|
+
|
|
34833
34864
|
/**
|
|
34834
34865
|
* WeeksCalendar
|
|
34835
34866
|
* -------------
|
|
34836
34867
|
* Props
|
|
34837
|
-
* • year
|
|
34838
|
-
* • defaultStartWeek
|
|
34839
|
-
* • defaultEndWeek
|
|
34840
|
-
* •
|
|
34841
|
-
* •
|
|
34868
|
+
* • year — four-digit year (required)
|
|
34869
|
+
* • defaultStartWeek — number | null
|
|
34870
|
+
* • defaultEndWeek — number | null
|
|
34871
|
+
* • backgroundColor — string (default: "#066768")
|
|
34872
|
+
* • hoverBackgroundColor — string (default: "#E6F0F0")
|
|
34873
|
+
* • allowedWeekRange — { startWeek: number, endWeek: number } | null
|
|
34874
|
+
* • onApply(start,end) — callback, both numbers (inclusive)
|
|
34875
|
+
* • onCancel() — callback
|
|
34842
34876
|
*/
|
|
34843
34877
|
const WeeksCalendar = ({
|
|
34844
34878
|
year,
|
|
@@ -34846,6 +34880,8 @@ const WeeksCalendar = ({
|
|
|
34846
34880
|
defaultEndWeek = null,
|
|
34847
34881
|
backgroundColor = "#066768",
|
|
34848
34882
|
hoverBackgroundColor = "#E6F0F0",
|
|
34883
|
+
allowedWeekRange = null,
|
|
34884
|
+
// New prop for range restriction
|
|
34849
34885
|
onApply,
|
|
34850
34886
|
onCancel
|
|
34851
34887
|
}) => {
|
|
@@ -34863,14 +34899,29 @@ const WeeksCalendar = ({
|
|
|
34863
34899
|
const hasSelection = startWeek !== null;
|
|
34864
34900
|
const isRange = hasSelection && endWeek !== null && endWeek !== startWeek;
|
|
34865
34901
|
const weeks = useMemo(() => [...Array(53)].map((_, i) => i + 1), []);
|
|
34902
|
+
|
|
34903
|
+
// Check if a week is disabled based on allowed range
|
|
34904
|
+
const isWeekDisabled = week => {
|
|
34905
|
+
if (!allowedWeekRange) return false;
|
|
34906
|
+
const {
|
|
34907
|
+
startWeek: allowedStart,
|
|
34908
|
+
endWeek: allowedEnd
|
|
34909
|
+
} = allowedWeekRange;
|
|
34910
|
+
return week < allowedStart || week > allowedEnd;
|
|
34911
|
+
};
|
|
34866
34912
|
const handleCellClick = week => {
|
|
34867
|
-
//
|
|
34913
|
+
// Don't allow selection of disabled weeks
|
|
34914
|
+
if (isWeekDisabled(week)) {
|
|
34915
|
+
return;
|
|
34916
|
+
}
|
|
34868
34917
|
|
|
34918
|
+
// first click → start
|
|
34869
34919
|
if (!hasSelection) {
|
|
34870
34920
|
setStartWeek(week);
|
|
34871
34921
|
setEndWeek(null);
|
|
34872
34922
|
return;
|
|
34873
34923
|
}
|
|
34924
|
+
|
|
34874
34925
|
// second click → decide range or single
|
|
34875
34926
|
if (hasSelection && endWeek === null) {
|
|
34876
34927
|
// second click on same cell turns it to single selection
|
|
@@ -34883,6 +34934,7 @@ const WeeksCalendar = ({
|
|
|
34883
34934
|
setStartWeek(week < startWeek ? week : startWeek);
|
|
34884
34935
|
return;
|
|
34885
34936
|
}
|
|
34937
|
+
|
|
34886
34938
|
// any later click resets selection and starts over
|
|
34887
34939
|
setStartWeek(week);
|
|
34888
34940
|
setEndWeek(null);
|
|
@@ -34898,11 +34950,14 @@ const WeeksCalendar = ({
|
|
|
34898
34950
|
columns: 6
|
|
34899
34951
|
}, weeks.map(wk => {
|
|
34900
34952
|
const selected = wk === startWeek || isRange && wk >= startWeek && wk <= endWeek;
|
|
34953
|
+
const disabled = isWeekDisabled(wk);
|
|
34954
|
+
const isRangeMiddle = selected && wk !== startWeek && wk !== endWeek;
|
|
34901
34955
|
return /*#__PURE__*/React$1.createElement(WeekCell, {
|
|
34902
34956
|
key: wk,
|
|
34903
34957
|
"data-week": wk,
|
|
34904
34958
|
$selected: selected,
|
|
34905
|
-
$isRangeMiddle:
|
|
34959
|
+
$isRangeMiddle: isRangeMiddle,
|
|
34960
|
+
$disabled: disabled,
|
|
34906
34961
|
onClick: () => handleCellClick(wk)
|
|
34907
34962
|
}, wk);
|
|
34908
34963
|
})), /*#__PURE__*/React$1.createElement(Footer, null, /*#__PURE__*/React$1.createElement(Button$1, {
|
|
@@ -34936,6 +34991,12 @@ WeeksCalendar.propTypes = {
|
|
|
34936
34991
|
year: PropTypes.number.isRequired,
|
|
34937
34992
|
defaultStartWeek: PropTypes.number,
|
|
34938
34993
|
defaultEndWeek: PropTypes.number,
|
|
34994
|
+
backgroundColor: PropTypes.string,
|
|
34995
|
+
hoverBackgroundColor: PropTypes.string,
|
|
34996
|
+
allowedWeekRange: PropTypes.shape({
|
|
34997
|
+
startWeek: PropTypes.number.isRequired,
|
|
34998
|
+
endWeek: PropTypes.number.isRequired
|
|
34999
|
+
}),
|
|
34939
35000
|
onApply: PropTypes.func.isRequired,
|
|
34940
35001
|
onCancel: PropTypes.func
|
|
34941
35002
|
};
|
|
@@ -35050,7 +35111,11 @@ const WeeksPicker = _ref => {
|
|
|
35050
35111
|
height,
|
|
35051
35112
|
withMarginBottom = true,
|
|
35052
35113
|
onChange,
|
|
35053
|
-
selectedValue
|
|
35114
|
+
selectedValue,
|
|
35115
|
+
// New props for range restriction
|
|
35116
|
+
allowedWeekRange = null,
|
|
35117
|
+
// { startWeek: number, endWeek: number } or null
|
|
35118
|
+
restrictToRange = false // boolean to enable/disable restriction
|
|
35054
35119
|
} = _ref;
|
|
35055
35120
|
const [value, setValue] = useState("");
|
|
35056
35121
|
const inputRef = useRef(null);
|
|
@@ -35093,6 +35158,18 @@ const WeeksPicker = _ref => {
|
|
|
35093
35158
|
};
|
|
35094
35159
|
};
|
|
35095
35160
|
|
|
35161
|
+
// Validate if selected weeks are within allowed range
|
|
35162
|
+
const validateWeekSelection = (startWeek, endWeek) => {
|
|
35163
|
+
if (!restrictToRange || !allowedWeekRange) {
|
|
35164
|
+
return true;
|
|
35165
|
+
}
|
|
35166
|
+
const {
|
|
35167
|
+
startWeek: allowedStart,
|
|
35168
|
+
endWeek: allowedEnd
|
|
35169
|
+
} = allowedWeekRange;
|
|
35170
|
+
return startWeek >= allowedStart && endWeek <= allowedEnd && startWeek <= endWeek;
|
|
35171
|
+
};
|
|
35172
|
+
|
|
35096
35173
|
// Get current parsed weeks from value
|
|
35097
35174
|
const {
|
|
35098
35175
|
startWeek: currentStartWeek,
|
|
@@ -35133,15 +35210,43 @@ const WeeksPicker = _ref => {
|
|
|
35133
35210
|
}
|
|
35134
35211
|
}
|
|
35135
35212
|
}, [isOpen]);
|
|
35213
|
+
|
|
35214
|
+
// Validate and clear invalid selections when allowedWeekRange changes
|
|
35215
|
+
useEffect(() => {
|
|
35216
|
+
if (restrictToRange && allowedWeekRange && value) {
|
|
35217
|
+
const {
|
|
35218
|
+
startWeek,
|
|
35219
|
+
endWeek
|
|
35220
|
+
} = parseValueToWeeks(value);
|
|
35221
|
+
if (startWeek && endWeek && !validateWeekSelection(startWeek, endWeek)) {
|
|
35222
|
+
// Clear invalid selection
|
|
35223
|
+
setValue("");
|
|
35224
|
+
onChange("");
|
|
35225
|
+
}
|
|
35226
|
+
}
|
|
35227
|
+
}, [allowedWeekRange, restrictToRange]);
|
|
35136
35228
|
const handleToggle = () => {
|
|
35137
35229
|
setIsOpen(!isOpen);
|
|
35138
35230
|
};
|
|
35139
35231
|
const onChangeEvent = e => {
|
|
35140
|
-
|
|
35141
|
-
|
|
35232
|
+
const newValue = e.target.value;
|
|
35233
|
+
|
|
35234
|
+
// If restriction is enabled, validate the manual input
|
|
35235
|
+
if (restrictToRange && allowedWeekRange && newValue) {
|
|
35236
|
+
const {
|
|
35237
|
+
startWeek,
|
|
35238
|
+
endWeek
|
|
35239
|
+
} = parseValueToWeeks(newValue);
|
|
35240
|
+
if (startWeek && endWeek && !validateWeekSelection(startWeek, endWeek)) {
|
|
35241
|
+
// Don't update if selection is outside allowed range
|
|
35242
|
+
return;
|
|
35243
|
+
}
|
|
35244
|
+
}
|
|
35245
|
+
onChange(newValue);
|
|
35246
|
+
setValue(newValue);
|
|
35142
35247
|
};
|
|
35143
35248
|
useEffect(() => {
|
|
35144
|
-
if (selectedValue) {
|
|
35249
|
+
if (selectedValue !== undefined) {
|
|
35145
35250
|
setValue(selectedValue);
|
|
35146
35251
|
}
|
|
35147
35252
|
}, [selectedValue]);
|
|
@@ -35216,8 +35321,17 @@ const WeeksPicker = _ref => {
|
|
|
35216
35321
|
defaultStartWeek: currentStartWeek,
|
|
35217
35322
|
defaultEndWeek: currentEndWeek,
|
|
35218
35323
|
backgroundColor: borderColorFocus,
|
|
35219
|
-
hoverBackgroundColor: hoverColor
|
|
35324
|
+
hoverBackgroundColor: hoverColor
|
|
35325
|
+
// Pass restriction parameters to WeeksCalendar
|
|
35326
|
+
,
|
|
35327
|
+
allowedWeekRange: restrictToRange ? allowedWeekRange : null,
|
|
35220
35328
|
onApply: (start, end) => {
|
|
35329
|
+
// Validate selection before applying
|
|
35330
|
+
if (restrictToRange && allowedWeekRange && !validateWeekSelection(start, end)) {
|
|
35331
|
+
// Show error or prevent selection
|
|
35332
|
+
console.warn('Selected weeks are outside the allowed range');
|
|
35333
|
+
return;
|
|
35334
|
+
}
|
|
35221
35335
|
const tempValue = end === start ? `Week ${start}` : `Weeks ${start} - ${end}`;
|
|
35222
35336
|
onChange(tempValue);
|
|
35223
35337
|
setValue(tempValue);
|