pcm-shared-components 2.1.407 → 2.1.409
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.
|
@@ -18,10 +18,11 @@ export const openNativeDatePicker = e => {
|
|
|
18
18
|
}
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
// Collapsed height for a notice's rich-text content before it needs a "
|
|
22
|
-
//
|
|
23
|
-
//
|
|
24
|
-
|
|
21
|
+
// Collapsed height for a notice's rich-text content before it needs a "Show More" link -- kept
|
|
22
|
+
// deliberately small (~3 text lines) so a long admin-entered notice doesn't dominate the panel's
|
|
23
|
+
// vertical space; anything longer gets clipped here and offered in full through the dialog below.
|
|
24
|
+
// Short content still renders in full with no link at all (overflow-measured, not char-counted).
|
|
25
|
+
const NOTICE_COLLAPSED_MAX_HEIGHT = 66;
|
|
25
26
|
|
|
26
27
|
/**
|
|
27
28
|
* The control for a `notice` field: the admin's sanitized rich text inside a bounded-height
|
|
@@ -85,21 +86,32 @@ const NoticeFieldControl = ({
|
|
|
85
86
|
dangerouslySetInnerHTML: {
|
|
86
87
|
__html: contentHtml
|
|
87
88
|
}
|
|
88
|
-
})), overflowing &&
|
|
89
|
+
})), overflowing &&
|
|
90
|
+
/*#__PURE__*/
|
|
91
|
+
// Bottom-right, per the requested layout. NOT disabled in read-only mode -- reading the
|
|
92
|
+
// full notice is always legitimate, only the checkbox below is a mutation. stopPropagation:
|
|
93
|
+
// some hosts render this control inside a click-to-edit card (e.g. the admin reservation
|
|
94
|
+
// review's occupant card) whose background clicks deliberately bubble up to open the
|
|
95
|
+
// editor -- opening the read-more dialog must not also trigger that.
|
|
96
|
+
React.createElement(Button, {
|
|
89
97
|
size: "small",
|
|
90
|
-
|
|
91
|
-
|
|
98
|
+
onClick: e => {
|
|
99
|
+
e.stopPropagation();
|
|
100
|
+
setDialogOpen(true);
|
|
101
|
+
},
|
|
92
102
|
sx: {
|
|
93
|
-
alignSelf: 'flex-
|
|
103
|
+
alignSelf: 'flex-end',
|
|
94
104
|
textTransform: 'none',
|
|
95
105
|
minWidth: 0,
|
|
96
106
|
p: 0
|
|
97
107
|
}
|
|
98
|
-
}, i18next.t('
|
|
99
|
-
label: field.label
|
|
100
|
-
})), /*#__PURE__*/React.createElement(Dialog, {
|
|
108
|
+
}, i18next.t('common.app.show_more')), /*#__PURE__*/React.createElement(Dialog, {
|
|
101
109
|
open: dialogOpen,
|
|
102
|
-
onClose:
|
|
110
|
+
onClose: e => {
|
|
111
|
+
if (e && e.stopPropagation) e.stopPropagation();
|
|
112
|
+
setDialogOpen(false);
|
|
113
|
+
},
|
|
114
|
+
onClick: e => e.stopPropagation(),
|
|
103
115
|
maxWidth: "sm",
|
|
104
116
|
fullWidth: true,
|
|
105
117
|
scroll: "paper"
|
|
@@ -110,7 +122,10 @@ const NoticeFieldControl = ({
|
|
|
110
122
|
__html: contentHtml
|
|
111
123
|
}
|
|
112
124
|
})), /*#__PURE__*/React.createElement(DialogActions, null, /*#__PURE__*/React.createElement(Button, {
|
|
113
|
-
onClick:
|
|
125
|
+
onClick: e => {
|
|
126
|
+
e.stopPropagation();
|
|
127
|
+
setDialogOpen(false);
|
|
128
|
+
}
|
|
114
129
|
}, i18next.t('common.app.close')))), /*#__PURE__*/React.createElement(FormControlLabel, {
|
|
115
130
|
control: /*#__PURE__*/React.createElement(Checkbox, {
|
|
116
131
|
checked: value === true,
|
|
@@ -119,6 +134,17 @@ const NoticeFieldControl = ({
|
|
|
119
134
|
color: error ? 'error' : 'primary'
|
|
120
135
|
}),
|
|
121
136
|
label: i18next.t('animal.read_notice_confirmation')
|
|
137
|
+
// The checkbox icon already goes red via `color` above when unchecked-and-required, but
|
|
138
|
+
// the label text next to it (the actual "I have read this" wording someone needs to read
|
|
139
|
+
// and act on) stayed the default color regardless -- targeting FormControlLabel's own
|
|
140
|
+
// label class is the supported way to color just that text, matching every other field's
|
|
141
|
+
// red label treatment above the control.
|
|
142
|
+
,
|
|
143
|
+
sx: {
|
|
144
|
+
'& .MuiFormControlLabel-label': {
|
|
145
|
+
color: error ? 'error.main' : 'text.primary'
|
|
146
|
+
}
|
|
147
|
+
}
|
|
122
148
|
}), helperText && /*#__PURE__*/React.createElement(FormHelperText, {
|
|
123
149
|
error: error
|
|
124
150
|
}, helperText));
|
|
@@ -92,12 +92,29 @@ export const AnimalVehicleDetailsEditor = props => {
|
|
|
92
92
|
canAddMore,
|
|
93
93
|
maxItems,
|
|
94
94
|
showHistoricalAnswers,
|
|
95
|
+
bare,
|
|
95
96
|
className,
|
|
96
97
|
theme,
|
|
97
98
|
i18next
|
|
98
99
|
} = props;
|
|
99
100
|
const compTheme = theme || useTheme();
|
|
100
101
|
const defaultTheme = createTheme(compTheme);
|
|
102
|
+
|
|
103
|
+
// `bare`: skip this component's own outer card (background/border/rounding) and render its
|
|
104
|
+
// content as a plain fragment instead -- for a caller that wants to place this editor and
|
|
105
|
+
// AnimalFieldsOnceBlock's once-per-reservation fields inside ONE shared outer card (a Divider
|
|
106
|
+
// between them, not two separate adjacent cards), rather than this component supplying its own
|
|
107
|
+
// competing card around just the per-item half. Off by default so every existing usage keeps
|
|
108
|
+
// its current self-contained card look unchanged.
|
|
109
|
+
const OuterWrapper = bare ? React.Fragment : Paper;
|
|
110
|
+
const outerWrapperProps = bare ? {} : {
|
|
111
|
+
variant: 'outlined',
|
|
112
|
+
sx: {
|
|
113
|
+
p: 1.5,
|
|
114
|
+
borderRadius: 2,
|
|
115
|
+
bgcolor: 'action.hover'
|
|
116
|
+
}
|
|
117
|
+
};
|
|
101
118
|
const keys = KEYS[itemType] || KEYS.animal;
|
|
102
119
|
const requiredErrorText = fieldType => i18next.t(REQUIRED_ERROR_KEY_BY_TYPE[fieldType] || 'animal.required_error');
|
|
103
120
|
const missingRequiredFields = item => fieldConfig.filter(f => f.required).filter(f => !isFieldAnswered(f.type, item.values?.[f.key] ?? (f.type === 'select_multiple' ? [] : '')));
|
|
@@ -234,14 +251,7 @@ export const AnimalVehicleDetailsEditor = props => {
|
|
|
234
251
|
theme: defaultTheme
|
|
235
252
|
}, /*#__PURE__*/React.createElement("div", {
|
|
236
253
|
className: className
|
|
237
|
-
}, /*#__PURE__*/React.createElement(
|
|
238
|
-
variant: "outlined",
|
|
239
|
-
sx: {
|
|
240
|
-
p: 1.5,
|
|
241
|
-
borderRadius: 2,
|
|
242
|
-
bgcolor: 'action.hover'
|
|
243
|
-
}
|
|
244
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
254
|
+
}, /*#__PURE__*/React.createElement(OuterWrapper, outerWrapperProps, /*#__PURE__*/React.createElement("div", {
|
|
245
255
|
className: "flex items-center justify-between mb-8"
|
|
246
256
|
}, /*#__PURE__*/React.createElement("div", {
|
|
247
257
|
className: "flex items-center",
|
|
@@ -605,6 +615,7 @@ AnimalVehicleDetailsEditor.defaultProps = {
|
|
|
605
615
|
canAddMore: true,
|
|
606
616
|
maxItems: 0,
|
|
607
617
|
showHistoricalAnswers: true,
|
|
618
|
+
bare: false,
|
|
608
619
|
className: 'w-full',
|
|
609
620
|
theme: undefined,
|
|
610
621
|
i18next: i18nextLocal
|
|
@@ -654,6 +665,10 @@ AnimalVehicleDetailsEditor.propTypes = {
|
|
|
654
665
|
* since-retired answer on an EXISTING reservation is legitimate. A guest-facing booking widget
|
|
655
666
|
* creating a brand-new reservation has no history to show and should pass false. */
|
|
656
667
|
showHistoricalAnswers: PropTypes.bool,
|
|
668
|
+
/** Skip this component's own outer card (background/border/rounding) and render a plain
|
|
669
|
+
* fragment instead -- for a caller placing this editor and AnimalFieldsOnceBlock's fields inside
|
|
670
|
+
* one shared outer card. Defaults to false so every existing usage keeps its current look. */
|
|
671
|
+
bare: PropTypes.bool,
|
|
657
672
|
/** Classes applied to the component's own wrapper div. */
|
|
658
673
|
className: PropTypes.string,
|
|
659
674
|
/** Theme object to use on this component, if none provided then the MUI5 theme provider theme is used. */
|