sag_components 2.0.0-beta195 → 2.0.0-beta196
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 +168 -37
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +168 -37
- 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.js
CHANGED
|
@@ -12262,13 +12262,16 @@ const Td$1 = styled__default["default"].td`
|
|
|
12262
12262
|
`;
|
|
12263
12263
|
const Tr = styled__default["default"].tr`
|
|
12264
12264
|
border-bottom: 1px solid #f3f4f6;
|
|
12265
|
-
${
|
|
12266
|
-
|
|
12267
|
-
|
|
12268
|
-
|
|
12265
|
+
${_ref => {
|
|
12266
|
+
let {
|
|
12267
|
+
enableHover,
|
|
12268
|
+
selectHoverColor
|
|
12269
|
+
} = _ref;
|
|
12270
|
+
return enableHover && `&:hover {
|
|
12269
12271
|
background-color: ${selectHoverColor};
|
|
12270
12272
|
cursor: pointer;
|
|
12271
|
-
}
|
|
12273
|
+
}`;
|
|
12274
|
+
}}
|
|
12272
12275
|
`;
|
|
12273
12276
|
const InfoText = styled__default["default"].div`
|
|
12274
12277
|
font-weight: 400;
|
|
@@ -34729,6 +34732,8 @@ const ModalWithOverlay = props => {
|
|
|
34729
34732
|
}, children)));
|
|
34730
34733
|
};
|
|
34731
34734
|
|
|
34735
|
+
// src/components/WeeksPicker/WeeksCalendar.styles.js
|
|
34736
|
+
|
|
34732
34737
|
/* ──────────────────────────────────────────
|
|
34733
34738
|
COLORS – map to your design-system tokens
|
|
34734
34739
|
Change only here if the palette shifts
|
|
@@ -34740,7 +34745,9 @@ const c = {
|
|
|
34740
34745
|
primary: "#016672",
|
|
34741
34746
|
// apply / highlight
|
|
34742
34747
|
primaryLight: "#d1e7ea",
|
|
34743
|
-
border: "#e0e0e0"
|
|
34748
|
+
border: "#e0e0e0",
|
|
34749
|
+
disabled: "#f5f5f5",
|
|
34750
|
+
disabledText: "#bdbdbd"
|
|
34744
34751
|
};
|
|
34745
34752
|
|
|
34746
34753
|
/* ───────────────────────── wrapper */
|
|
@@ -34780,34 +34787,56 @@ const WeekCell = styled__default["default"].div`
|
|
|
34780
34787
|
text-align: center;
|
|
34781
34788
|
cursor: pointer;
|
|
34782
34789
|
color: ${c.textSecondary};
|
|
34783
|
-
transition: background 0.15s ease;
|
|
34784
|
-
|
|
34790
|
+
transition: background 0.15s ease, opacity 0.15s ease, color 0.15s ease;
|
|
34791
|
+
border-radius: 4px;
|
|
34785
34792
|
|
|
34793
|
+
/* Disabled state - highest priority */
|
|
34786
34794
|
${({
|
|
34787
|
-
$
|
|
34788
|
-
}) => $
|
|
34795
|
+
$disabled
|
|
34796
|
+
}) => $disabled && styled.css`
|
|
34797
|
+
opacity: 0.3;
|
|
34798
|
+
cursor: not-allowed;
|
|
34799
|
+
background: ${c.disabled} !important;
|
|
34800
|
+
color: ${c.disabledText} !important;
|
|
34801
|
+
|
|
34802
|
+
&:hover {
|
|
34803
|
+
background: ${c.disabled} !important;
|
|
34804
|
+
color: ${c.disabledText} !important;
|
|
34805
|
+
}
|
|
34806
|
+
`}
|
|
34789
34807
|
|
|
34808
|
+
/* Selected state - only if not disabled */
|
|
34809
|
+
${({
|
|
34810
|
+
$selected,
|
|
34811
|
+
$disabled
|
|
34812
|
+
}) => $selected && !$disabled && styled.css`
|
|
34790
34813
|
background: ${c.primary};
|
|
34791
34814
|
color: #FFFFFF;
|
|
34792
34815
|
`}
|
|
34793
34816
|
|
|
34794
|
-
/*
|
|
34817
|
+
/* Range middle highlighting - only if not disabled */
|
|
34795
34818
|
${({
|
|
34796
|
-
$isRangeMiddle
|
|
34797
|
-
|
|
34819
|
+
$isRangeMiddle,
|
|
34820
|
+
$disabled
|
|
34821
|
+
}) => $isRangeMiddle && !$disabled && styled.css`
|
|
34798
34822
|
background: ${c.primaryLight};
|
|
34799
34823
|
border-radius: 0px;
|
|
34800
34824
|
color: ${c.text};
|
|
34801
34825
|
`}
|
|
34802
34826
|
|
|
34803
|
-
|
|
34804
|
-
|
|
34805
|
-
|
|
34806
|
-
|
|
34827
|
+
/* Hover state - only if not disabled */
|
|
34828
|
+
${({
|
|
34829
|
+
$disabled
|
|
34830
|
+
}) => !$disabled && styled.css`
|
|
34831
|
+
&:hover {
|
|
34832
|
+
background: ${c.primaryLight};
|
|
34833
|
+
color: ${c.text};
|
|
34834
|
+
}
|
|
34835
|
+
`}
|
|
34836
|
+
|
|
34837
|
+
/* Typography */
|
|
34807
34838
|
text-align: center;
|
|
34808
34839
|
font-feature-settings: "liga" off;
|
|
34809
|
-
|
|
34810
|
-
/* Content/P3 Regular */
|
|
34811
34840
|
font-family: Poppins;
|
|
34812
34841
|
font-size: 12px;
|
|
34813
34842
|
font-style: normal;
|
|
@@ -34840,15 +34869,20 @@ styled.css`
|
|
|
34840
34869
|
}
|
|
34841
34870
|
`;
|
|
34842
34871
|
|
|
34872
|
+
// src/components/WeeksPicker/WeeksCalendar.jsx
|
|
34873
|
+
|
|
34843
34874
|
/**
|
|
34844
34875
|
* WeeksCalendar
|
|
34845
34876
|
* -------------
|
|
34846
34877
|
* Props
|
|
34847
|
-
* • year
|
|
34848
|
-
* • defaultStartWeek
|
|
34849
|
-
* • defaultEndWeek
|
|
34850
|
-
* •
|
|
34851
|
-
* •
|
|
34878
|
+
* • year — four-digit year (required)
|
|
34879
|
+
* • defaultStartWeek — number | null
|
|
34880
|
+
* • defaultEndWeek — number | null
|
|
34881
|
+
* • backgroundColor — string (default: "#066768")
|
|
34882
|
+
* • hoverBackgroundColor — string (default: "#E6F0F0")
|
|
34883
|
+
* • allowedWeekRange — { startWeek: number, endWeek: number } | null
|
|
34884
|
+
* • onApply(start,end) — callback, both numbers (inclusive)
|
|
34885
|
+
* • onCancel() — callback
|
|
34852
34886
|
*/
|
|
34853
34887
|
const WeeksCalendar = ({
|
|
34854
34888
|
year,
|
|
@@ -34856,6 +34890,8 @@ const WeeksCalendar = ({
|
|
|
34856
34890
|
defaultEndWeek = null,
|
|
34857
34891
|
backgroundColor = "#066768",
|
|
34858
34892
|
hoverBackgroundColor = "#E6F0F0",
|
|
34893
|
+
allowedWeekRange = null,
|
|
34894
|
+
// New prop for range restriction
|
|
34859
34895
|
onApply,
|
|
34860
34896
|
onCancel
|
|
34861
34897
|
}) => {
|
|
@@ -34873,14 +34909,29 @@ const WeeksCalendar = ({
|
|
|
34873
34909
|
const hasSelection = startWeek !== null;
|
|
34874
34910
|
const isRange = hasSelection && endWeek !== null && endWeek !== startWeek;
|
|
34875
34911
|
const weeks = React$1.useMemo(() => [...Array(53)].map((_, i) => i + 1), []);
|
|
34912
|
+
|
|
34913
|
+
// Check if a week is disabled based on allowed range
|
|
34914
|
+
const isWeekDisabled = week => {
|
|
34915
|
+
if (!allowedWeekRange) return false;
|
|
34916
|
+
const {
|
|
34917
|
+
startWeek: allowedStart,
|
|
34918
|
+
endWeek: allowedEnd
|
|
34919
|
+
} = allowedWeekRange;
|
|
34920
|
+
return week < allowedStart || week > allowedEnd;
|
|
34921
|
+
};
|
|
34876
34922
|
const handleCellClick = week => {
|
|
34877
|
-
//
|
|
34923
|
+
// Don't allow selection of disabled weeks
|
|
34924
|
+
if (isWeekDisabled(week)) {
|
|
34925
|
+
return;
|
|
34926
|
+
}
|
|
34878
34927
|
|
|
34928
|
+
// first click → start
|
|
34879
34929
|
if (!hasSelection) {
|
|
34880
34930
|
setStartWeek(week);
|
|
34881
34931
|
setEndWeek(null);
|
|
34882
34932
|
return;
|
|
34883
34933
|
}
|
|
34934
|
+
|
|
34884
34935
|
// second click → decide range or single
|
|
34885
34936
|
if (hasSelection && endWeek === null) {
|
|
34886
34937
|
// second click on same cell turns it to single selection
|
|
@@ -34893,6 +34944,7 @@ const WeeksCalendar = ({
|
|
|
34893
34944
|
setStartWeek(week < startWeek ? week : startWeek);
|
|
34894
34945
|
return;
|
|
34895
34946
|
}
|
|
34947
|
+
|
|
34896
34948
|
// any later click resets selection and starts over
|
|
34897
34949
|
setStartWeek(week);
|
|
34898
34950
|
setEndWeek(null);
|
|
@@ -34908,11 +34960,14 @@ const WeeksCalendar = ({
|
|
|
34908
34960
|
columns: 6
|
|
34909
34961
|
}, weeks.map(wk => {
|
|
34910
34962
|
const selected = wk === startWeek || isRange && wk >= startWeek && wk <= endWeek;
|
|
34963
|
+
const disabled = isWeekDisabled(wk);
|
|
34964
|
+
const isRangeMiddle = selected && wk !== startWeek && wk !== endWeek;
|
|
34911
34965
|
return /*#__PURE__*/React__default["default"].createElement(WeekCell, {
|
|
34912
34966
|
key: wk,
|
|
34913
34967
|
"data-week": wk,
|
|
34914
34968
|
$selected: selected,
|
|
34915
|
-
$isRangeMiddle:
|
|
34969
|
+
$isRangeMiddle: isRangeMiddle,
|
|
34970
|
+
$disabled: disabled,
|
|
34916
34971
|
onClick: () => handleCellClick(wk)
|
|
34917
34972
|
}, wk);
|
|
34918
34973
|
})), /*#__PURE__*/React__default["default"].createElement(Footer, null, /*#__PURE__*/React__default["default"].createElement(Button$1, {
|
|
@@ -34946,6 +35001,12 @@ WeeksCalendar.propTypes = {
|
|
|
34946
35001
|
year: PropTypes.number.isRequired,
|
|
34947
35002
|
defaultStartWeek: PropTypes.number,
|
|
34948
35003
|
defaultEndWeek: PropTypes.number,
|
|
35004
|
+
backgroundColor: PropTypes.string,
|
|
35005
|
+
hoverBackgroundColor: PropTypes.string,
|
|
35006
|
+
allowedWeekRange: PropTypes.shape({
|
|
35007
|
+
startWeek: PropTypes.number.isRequired,
|
|
35008
|
+
endWeek: PropTypes.number.isRequired
|
|
35009
|
+
}),
|
|
34949
35010
|
onApply: PropTypes.func.isRequired,
|
|
34950
35011
|
onCancel: PropTypes.func
|
|
34951
35012
|
};
|
|
@@ -34972,22 +35033,28 @@ const StyledInput$1 = styled__default["default"].input`
|
|
|
34972
35033
|
box-sizing: border-box;
|
|
34973
35034
|
color: ${props => props.disabled ? '#888' : (props.isFocused || props.value ? props.textColor : '#757575') || '#333'};
|
|
34974
35035
|
cursor: ${props => props.disabled ? 'not-allowed' : 'text'};
|
|
35036
|
+
|
|
35037
|
+
&:disabled {
|
|
35038
|
+
background-color: #f5f5f5;
|
|
35039
|
+
cursor: not-allowed;
|
|
35040
|
+
}
|
|
34975
35041
|
`;
|
|
34976
35042
|
const StyledLabel = styled__default["default"].label`
|
|
34977
35043
|
font-size: 14px;
|
|
34978
|
-
/* width: ${props => props.isFocused || props.hasValue ? 'auto' : '150px'}; */
|
|
34979
35044
|
color: ${props => props.disabled ? '#888' : (props.isFocused || props.hasValue ? props.borderColorFocus : '#757575') || '#333'};
|
|
34980
35045
|
position: absolute;
|
|
34981
35046
|
top: ${props => props.isFocused || props.hasValue ? '0px' : '50%'};
|
|
34982
35047
|
left: 15px;
|
|
34983
35048
|
background-color: ${props => props.isFocused || props.hasValue ? 'white' : 'transparent'};
|
|
34984
35049
|
transform: translateY(-50%);
|
|
34985
|
-
transition: top 0.3s ease, font-size 0.3s ease;
|
|
35050
|
+
transition: top 0.3s ease, font-size 0.3s ease, color 0.3s ease;
|
|
34986
35051
|
display: flex;
|
|
34987
35052
|
font-weight: 400;
|
|
34988
35053
|
align-items: center;
|
|
34989
35054
|
box-sizing: border-box;
|
|
34990
|
-
cursor: pointer;
|
|
35055
|
+
cursor: ${props => props.disabled ? 'not-allowed' : 'pointer'};
|
|
35056
|
+
padding: 0 4px;
|
|
35057
|
+
z-index: 1;
|
|
34991
35058
|
`;
|
|
34992
35059
|
const RequiredIndicator = styled__default["default"].span`
|
|
34993
35060
|
color: red;
|
|
@@ -35003,9 +35070,13 @@ const OptionsContainer = styled__default["default"].div`
|
|
|
35003
35070
|
z-index: 999;
|
|
35004
35071
|
${props => props.showAbove ? `
|
|
35005
35072
|
bottom: 100%;
|
|
35073
|
+
margin-bottom: 4px;
|
|
35006
35074
|
` : `
|
|
35007
35075
|
top: 100%;
|
|
35076
|
+
margin-top: 4px;
|
|
35008
35077
|
`}
|
|
35078
|
+
left: 0;
|
|
35079
|
+
right: 0;
|
|
35009
35080
|
`;
|
|
35010
35081
|
const InputContainer$1 = styled__default["default"].div`
|
|
35011
35082
|
display: flex;
|
|
@@ -35018,20 +35089,22 @@ const InputContainer$1 = styled__default["default"].div`
|
|
|
35018
35089
|
width: 100%;
|
|
35019
35090
|
height: 100%;
|
|
35020
35091
|
box-sizing: border-box;
|
|
35021
|
-
background-color: transparent;
|
|
35022
|
-
border:
|
|
35092
|
+
background-color: ${props => props.disabled ? '#f5f5f5' : 'transparent'};
|
|
35093
|
+
border: 1px solid ${props => props.disabled ? '#bdbdbd' : props.error ? 'red' : '#B1B1B1'};
|
|
35023
35094
|
font-weight: 400;
|
|
35024
35095
|
font-size: 14px;
|
|
35025
35096
|
border-radius: 12px;
|
|
35026
35097
|
outline: none;
|
|
35027
35098
|
color: ${props => props.disabled ? '#888' : '#212121'};
|
|
35099
|
+
position: relative;
|
|
35100
|
+
transition: border-color 0.3s ease, background-color 0.3s ease;
|
|
35028
35101
|
|
|
35029
35102
|
&:hover {
|
|
35030
35103
|
border: 1px solid ${props => props.disabled ? '#bdbdbd' : props.error ? 'red' : props.borderColorFocus || '#212121'};
|
|
35031
35104
|
cursor: ${props => props.disabled ? 'not-allowed' : 'pointer'};
|
|
35032
35105
|
}
|
|
35033
35106
|
|
|
35034
|
-
&:focus {
|
|
35107
|
+
&:focus-within {
|
|
35035
35108
|
border: 1px solid ${props => props.disabled ? '#bdbdbd' : props.error ? 'red' : props.borderColorFocus || '#212121'};
|
|
35036
35109
|
}
|
|
35037
35110
|
`;
|
|
@@ -35041,6 +35114,11 @@ const CalendarDiv = styled__default["default"].div`
|
|
|
35041
35114
|
right: 10px;
|
|
35042
35115
|
display: flex;
|
|
35043
35116
|
align-items: center;
|
|
35117
|
+
cursor: ${props => props.disabled ? 'not-allowed' : 'pointer'};
|
|
35118
|
+
|
|
35119
|
+
svg {
|
|
35120
|
+
transition: fill 0.3s ease;
|
|
35121
|
+
}
|
|
35044
35122
|
`;
|
|
35045
35123
|
|
|
35046
35124
|
// src/components/WeeksPicker/WeeksPicker.jsx
|
|
@@ -35060,7 +35138,11 @@ const WeeksPicker = _ref => {
|
|
|
35060
35138
|
height,
|
|
35061
35139
|
withMarginBottom = true,
|
|
35062
35140
|
onChange,
|
|
35063
|
-
selectedValue
|
|
35141
|
+
selectedValue,
|
|
35142
|
+
// New props for range restriction
|
|
35143
|
+
allowedWeekRange = null,
|
|
35144
|
+
// { startWeek: number, endWeek: number } or null
|
|
35145
|
+
restrictToRange = false // boolean to enable/disable restriction
|
|
35064
35146
|
} = _ref;
|
|
35065
35147
|
const [value, setValue] = React$1.useState("");
|
|
35066
35148
|
const inputRef = React$1.useRef(null);
|
|
@@ -35103,6 +35185,18 @@ const WeeksPicker = _ref => {
|
|
|
35103
35185
|
};
|
|
35104
35186
|
};
|
|
35105
35187
|
|
|
35188
|
+
// Validate if selected weeks are within allowed range
|
|
35189
|
+
const validateWeekSelection = (startWeek, endWeek) => {
|
|
35190
|
+
if (!restrictToRange || !allowedWeekRange) {
|
|
35191
|
+
return true;
|
|
35192
|
+
}
|
|
35193
|
+
const {
|
|
35194
|
+
startWeek: allowedStart,
|
|
35195
|
+
endWeek: allowedEnd
|
|
35196
|
+
} = allowedWeekRange;
|
|
35197
|
+
return startWeek >= allowedStart && endWeek <= allowedEnd && startWeek <= endWeek;
|
|
35198
|
+
};
|
|
35199
|
+
|
|
35106
35200
|
// Get current parsed weeks from value
|
|
35107
35201
|
const {
|
|
35108
35202
|
startWeek: currentStartWeek,
|
|
@@ -35143,15 +35237,43 @@ const WeeksPicker = _ref => {
|
|
|
35143
35237
|
}
|
|
35144
35238
|
}
|
|
35145
35239
|
}, [isOpen]);
|
|
35240
|
+
|
|
35241
|
+
// Validate and clear invalid selections when allowedWeekRange changes
|
|
35242
|
+
React$1.useEffect(() => {
|
|
35243
|
+
if (restrictToRange && allowedWeekRange && value) {
|
|
35244
|
+
const {
|
|
35245
|
+
startWeek,
|
|
35246
|
+
endWeek
|
|
35247
|
+
} = parseValueToWeeks(value);
|
|
35248
|
+
if (startWeek && endWeek && !validateWeekSelection(startWeek, endWeek)) {
|
|
35249
|
+
// Clear invalid selection
|
|
35250
|
+
setValue("");
|
|
35251
|
+
onChange("");
|
|
35252
|
+
}
|
|
35253
|
+
}
|
|
35254
|
+
}, [allowedWeekRange, restrictToRange]);
|
|
35146
35255
|
const handleToggle = () => {
|
|
35147
35256
|
setIsOpen(!isOpen);
|
|
35148
35257
|
};
|
|
35149
35258
|
const onChangeEvent = e => {
|
|
35150
|
-
|
|
35151
|
-
|
|
35259
|
+
const newValue = e.target.value;
|
|
35260
|
+
|
|
35261
|
+
// If restriction is enabled, validate the manual input
|
|
35262
|
+
if (restrictToRange && allowedWeekRange && newValue) {
|
|
35263
|
+
const {
|
|
35264
|
+
startWeek,
|
|
35265
|
+
endWeek
|
|
35266
|
+
} = parseValueToWeeks(newValue);
|
|
35267
|
+
if (startWeek && endWeek && !validateWeekSelection(startWeek, endWeek)) {
|
|
35268
|
+
// Don't update if selection is outside allowed range
|
|
35269
|
+
return;
|
|
35270
|
+
}
|
|
35271
|
+
}
|
|
35272
|
+
onChange(newValue);
|
|
35273
|
+
setValue(newValue);
|
|
35152
35274
|
};
|
|
35153
35275
|
React$1.useEffect(() => {
|
|
35154
|
-
if (selectedValue) {
|
|
35276
|
+
if (selectedValue !== undefined) {
|
|
35155
35277
|
setValue(selectedValue);
|
|
35156
35278
|
}
|
|
35157
35279
|
}, [selectedValue]);
|
|
@@ -35226,8 +35348,17 @@ const WeeksPicker = _ref => {
|
|
|
35226
35348
|
defaultStartWeek: currentStartWeek,
|
|
35227
35349
|
defaultEndWeek: currentEndWeek,
|
|
35228
35350
|
backgroundColor: borderColorFocus,
|
|
35229
|
-
hoverBackgroundColor: hoverColor
|
|
35351
|
+
hoverBackgroundColor: hoverColor
|
|
35352
|
+
// Pass restriction parameters to WeeksCalendar
|
|
35353
|
+
,
|
|
35354
|
+
allowedWeekRange: restrictToRange ? allowedWeekRange : null,
|
|
35230
35355
|
onApply: (start, end) => {
|
|
35356
|
+
// Validate selection before applying
|
|
35357
|
+
if (restrictToRange && allowedWeekRange && !validateWeekSelection(start, end)) {
|
|
35358
|
+
// Show error or prevent selection
|
|
35359
|
+
console.warn('Selected weeks are outside the allowed range');
|
|
35360
|
+
return;
|
|
35361
|
+
}
|
|
35231
35362
|
const tempValue = end === start ? `Week ${start}` : `Weeks ${start} - ${end}`;
|
|
35232
35363
|
onChange(tempValue);
|
|
35233
35364
|
setValue(tempValue);
|