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 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
- enableHover,
12257
- selectHoverColor
12258
- }) => enableHover && `&:hover {
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
- border-radius: 4px;
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
- $selected
34778
- }) => $selected && css`
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
- /* highlight range interior lighter */
34807
+ /* Range middle highlighting - only if not disabled */
34785
34808
  ${({
34786
- $isRangeMiddle
34787
- }) => $isRangeMiddle && css`
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
- &:hover {
34794
- background: ${c.primaryLight};
34795
- color: ${c.text};
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 four-digit year (required)
34838
- * • defaultStartWeek number | null
34839
- * • defaultEndWeek number | null
34840
- * • onApply(start,end) callback, both numbers (inclusive)
34841
- * • onCancel() – callback
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
- // first click start
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: selected && wk !== startWeek && wk !== endWeek,
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
  };
@@ -34962,22 +35023,28 @@ const StyledInput$1 = styled.input`
34962
35023
  box-sizing: border-box;
34963
35024
  color: ${props => props.disabled ? '#888' : (props.isFocused || props.value ? props.textColor : '#757575') || '#333'};
34964
35025
  cursor: ${props => props.disabled ? 'not-allowed' : 'text'};
35026
+
35027
+ &:disabled {
35028
+ background-color: #f5f5f5;
35029
+ cursor: not-allowed;
35030
+ }
34965
35031
  `;
34966
35032
  const StyledLabel = styled.label`
34967
35033
  font-size: 14px;
34968
- /* width: ${props => props.isFocused || props.hasValue ? 'auto' : '150px'}; */
34969
35034
  color: ${props => props.disabled ? '#888' : (props.isFocused || props.hasValue ? props.borderColorFocus : '#757575') || '#333'};
34970
35035
  position: absolute;
34971
35036
  top: ${props => props.isFocused || props.hasValue ? '0px' : '50%'};
34972
35037
  left: 15px;
34973
35038
  background-color: ${props => props.isFocused || props.hasValue ? 'white' : 'transparent'};
34974
35039
  transform: translateY(-50%);
34975
- transition: top 0.3s ease, font-size 0.3s ease;
35040
+ transition: top 0.3s ease, font-size 0.3s ease, color 0.3s ease;
34976
35041
  display: flex;
34977
35042
  font-weight: 400;
34978
35043
  align-items: center;
34979
35044
  box-sizing: border-box;
34980
- cursor: pointer;
35045
+ cursor: ${props => props.disabled ? 'not-allowed' : 'pointer'};
35046
+ padding: 0 4px;
35047
+ z-index: 1;
34981
35048
  `;
34982
35049
  const RequiredIndicator = styled.span`
34983
35050
  color: red;
@@ -34993,9 +35060,13 @@ const OptionsContainer = styled.div`
34993
35060
  z-index: 999;
34994
35061
  ${props => props.showAbove ? `
34995
35062
  bottom: 100%;
35063
+ margin-bottom: 4px;
34996
35064
  ` : `
34997
35065
  top: 100%;
35066
+ margin-top: 4px;
34998
35067
  `}
35068
+ left: 0;
35069
+ right: 0;
34999
35070
  `;
35000
35071
  const InputContainer$1 = styled.div`
35001
35072
  display: flex;
@@ -35008,20 +35079,22 @@ const InputContainer$1 = styled.div`
35008
35079
  width: 100%;
35009
35080
  height: 100%;
35010
35081
  box-sizing: border-box;
35011
- background-color: transparent;
35012
- border: 1px solid ${props => props.disabled ? '#bdbdbd' : props.error ? 'red' : '#B1B1B1'};
35082
+ background-color: ${props => props.disabled ? '#f5f5f5' : 'transparent'};
35083
+ border: 1px solid ${props => props.disabled ? '#bdbdbd' : props.error ? 'red' : '#B1B1B1'};
35013
35084
  font-weight: 400;
35014
35085
  font-size: 14px;
35015
35086
  border-radius: 12px;
35016
35087
  outline: none;
35017
35088
  color: ${props => props.disabled ? '#888' : '#212121'};
35089
+ position: relative;
35090
+ transition: border-color 0.3s ease, background-color 0.3s ease;
35018
35091
 
35019
35092
  &:hover {
35020
35093
  border: 1px solid ${props => props.disabled ? '#bdbdbd' : props.error ? 'red' : props.borderColorFocus || '#212121'};
35021
35094
  cursor: ${props => props.disabled ? 'not-allowed' : 'pointer'};
35022
35095
  }
35023
35096
 
35024
- &:focus {
35097
+ &:focus-within {
35025
35098
  border: 1px solid ${props => props.disabled ? '#bdbdbd' : props.error ? 'red' : props.borderColorFocus || '#212121'};
35026
35099
  }
35027
35100
  `;
@@ -35031,6 +35104,11 @@ const CalendarDiv = styled.div`
35031
35104
  right: 10px;
35032
35105
  display: flex;
35033
35106
  align-items: center;
35107
+ cursor: ${props => props.disabled ? 'not-allowed' : 'pointer'};
35108
+
35109
+ svg {
35110
+ transition: fill 0.3s ease;
35111
+ }
35034
35112
  `;
35035
35113
 
35036
35114
  // src/components/WeeksPicker/WeeksPicker.jsx
@@ -35050,7 +35128,11 @@ const WeeksPicker = _ref => {
35050
35128
  height,
35051
35129
  withMarginBottom = true,
35052
35130
  onChange,
35053
- selectedValue
35131
+ selectedValue,
35132
+ // New props for range restriction
35133
+ allowedWeekRange = null,
35134
+ // { startWeek: number, endWeek: number } or null
35135
+ restrictToRange = false // boolean to enable/disable restriction
35054
35136
  } = _ref;
35055
35137
  const [value, setValue] = useState("");
35056
35138
  const inputRef = useRef(null);
@@ -35093,6 +35175,18 @@ const WeeksPicker = _ref => {
35093
35175
  };
35094
35176
  };
35095
35177
 
35178
+ // Validate if selected weeks are within allowed range
35179
+ const validateWeekSelection = (startWeek, endWeek) => {
35180
+ if (!restrictToRange || !allowedWeekRange) {
35181
+ return true;
35182
+ }
35183
+ const {
35184
+ startWeek: allowedStart,
35185
+ endWeek: allowedEnd
35186
+ } = allowedWeekRange;
35187
+ return startWeek >= allowedStart && endWeek <= allowedEnd && startWeek <= endWeek;
35188
+ };
35189
+
35096
35190
  // Get current parsed weeks from value
35097
35191
  const {
35098
35192
  startWeek: currentStartWeek,
@@ -35133,15 +35227,43 @@ const WeeksPicker = _ref => {
35133
35227
  }
35134
35228
  }
35135
35229
  }, [isOpen]);
35230
+
35231
+ // Validate and clear invalid selections when allowedWeekRange changes
35232
+ useEffect(() => {
35233
+ if (restrictToRange && allowedWeekRange && value) {
35234
+ const {
35235
+ startWeek,
35236
+ endWeek
35237
+ } = parseValueToWeeks(value);
35238
+ if (startWeek && endWeek && !validateWeekSelection(startWeek, endWeek)) {
35239
+ // Clear invalid selection
35240
+ setValue("");
35241
+ onChange("");
35242
+ }
35243
+ }
35244
+ }, [allowedWeekRange, restrictToRange]);
35136
35245
  const handleToggle = () => {
35137
35246
  setIsOpen(!isOpen);
35138
35247
  };
35139
35248
  const onChangeEvent = e => {
35140
- onChange(e.target.value);
35141
- setValue(e.target.value);
35249
+ const newValue = e.target.value;
35250
+
35251
+ // If restriction is enabled, validate the manual input
35252
+ if (restrictToRange && allowedWeekRange && newValue) {
35253
+ const {
35254
+ startWeek,
35255
+ endWeek
35256
+ } = parseValueToWeeks(newValue);
35257
+ if (startWeek && endWeek && !validateWeekSelection(startWeek, endWeek)) {
35258
+ // Don't update if selection is outside allowed range
35259
+ return;
35260
+ }
35261
+ }
35262
+ onChange(newValue);
35263
+ setValue(newValue);
35142
35264
  };
35143
35265
  useEffect(() => {
35144
- if (selectedValue) {
35266
+ if (selectedValue !== undefined) {
35145
35267
  setValue(selectedValue);
35146
35268
  }
35147
35269
  }, [selectedValue]);
@@ -35216,8 +35338,17 @@ const WeeksPicker = _ref => {
35216
35338
  defaultStartWeek: currentStartWeek,
35217
35339
  defaultEndWeek: currentEndWeek,
35218
35340
  backgroundColor: borderColorFocus,
35219
- hoverBackgroundColor: hoverColor,
35341
+ hoverBackgroundColor: hoverColor
35342
+ // Pass restriction parameters to WeeksCalendar
35343
+ ,
35344
+ allowedWeekRange: restrictToRange ? allowedWeekRange : null,
35220
35345
  onApply: (start, end) => {
35346
+ // Validate selection before applying
35347
+ if (restrictToRange && allowedWeekRange && !validateWeekSelection(start, end)) {
35348
+ // Show error or prevent selection
35349
+ console.warn('Selected weeks are outside the allowed range');
35350
+ return;
35351
+ }
35221
35352
  const tempValue = end === start ? `Week ${start}` : `Weeks ${start} - ${end}`;
35222
35353
  onChange(tempValue);
35223
35354
  setValue(tempValue);