@openmrs/esm-styleguide 9.0.3-pre.4633 → 9.0.3-pre.4643

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.
@@ -1,3 +1,3 @@
1
- [0] Successfully compiled: 123 files, copied 164 files with swc (284.05ms)
1
+ [0] Successfully compiled: 123 files, copied 164 files with swc (253.91ms)
2
2
  [0] swc --strip-leading-paths --copy-files src -d dist && svgo -rf dist --quiet exited with code 0
3
3
  [1] tsc --project tsconfig.build.json exited with code 0
@@ -114,6 +114,14 @@
114
114
  block-size: layout.$spacing-08;
115
115
  }
116
116
 
117
+ .inputWrapperSm {
118
+ block-size: layout.$spacing-07;
119
+ }
120
+
121
+ .inputWrapperLg {
122
+ block-size: layout.$spacing-09;
123
+ }
124
+
117
125
  // Range date picker inputs
118
126
  .inputsWrapper {
119
127
  display: flex;
@@ -123,6 +131,18 @@
123
131
  inline-size: 15rem;
124
132
  }
125
133
 
134
+ .inputsWrapperSm {
135
+ block-size: layout.$spacing-07;
136
+ }
137
+
138
+ .inputsWrapperMd {
139
+ block-size: layout.$spacing-08;
140
+ }
141
+
142
+ .inputsWrapperLg {
143
+ block-size: layout.$spacing-09;
144
+ }
145
+
126
146
  .dateInputWrapper {
127
147
  @extend .inputWrapper;
128
148
  min-width: unset;
@@ -154,20 +174,31 @@
154
174
  }
155
175
 
156
176
  // Used for calendar pop-over
157
- @keyframes fade-in-down {
177
+ @keyframes expand-in {
158
178
  from {
159
179
  opacity: 0;
160
- transform: translate3d(0, -20px, 0);
180
+ transform: scale(0.93);
161
181
  }
162
182
 
163
183
  to {
164
184
  opacity: 1;
165
- transform: translate3d(0, 0, 0);
185
+ transform: scale(1);
166
186
  }
167
187
  }
168
188
 
189
+ .popover {
190
+ transform-origin: top center;
191
+ }
192
+
193
+ // When the popover flips above the trigger (near bottom of viewport), anchor from the bottom
194
+ .popover[data-placement='top'],
195
+ .popover[data-placement='top-start'],
196
+ .popover[data-placement='top-end'] {
197
+ transform-origin: bottom center;
198
+ }
199
+
169
200
  .popover[data-entering] {
170
- animation: fade-in-down motion.$duration-fast-02 motion.motion(entrance, productive);
201
+ animation: expand-in motion.$duration-fast-02 motion.motion(entrance, productive);
171
202
 
172
203
  @media screen and (prefers-reduced-motion: reduce) {
173
204
  animation: none;
@@ -223,6 +254,16 @@
223
254
  width: layout.$spacing-08;
224
255
  }
225
256
 
257
+ .flatButtonSm {
258
+ height: layout.$spacing-07;
259
+ width: layout.$spacing-07;
260
+ }
261
+
262
+ .flatButtonLg {
263
+ height: layout.$spacing-09;
264
+ width: layout.$spacing-09;
265
+ }
266
+
226
267
  .monthYear {
227
268
  @include component-reset.reset;
228
269
  @include type.type-style('heading-compact-01');
@@ -1 +1 @@
1
- {"version":3,"file":"openmrs-date-picker.component.d.ts","sourceRoot":"","sources":["../../src/datepicker/openmrs-date-picker.component.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqC,MAAM,OAAO,CAAC;AAE1D,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAsB,KAAK,eAAe,EAAsC,MAAM,uBAAuB,CAAC;AACrH,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAWxE;;GAEG;AACH,MAAM,WAAW,sBACf,SAAQ,IAAI,CAAC,eAAe,CAAC,YAAY,CAAC,EAAE,WAAW,GAAG,UAAU,GAAG,cAAc,GAAG,OAAO,CAAC,EAC9F,mBAAmB;IACrB,uCAAuC;IACvC,YAAY,CAAC,EAAE,cAAc,CAAC;IAC9B,qDAAqD;IACrD,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,IAAI,GAAG,IAAI,GAAG,SAAS,KAAK,IAAI,CAAC;IACpD,iHAAiH;IACjH,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,KAAK,IAAI,CAAC;IAChD,kGAAkG;IAClG,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IAC1B,uCAAuC;IACvC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,6BAA6B;IAC7B,KAAK,CAAC,EAAE,cAAc,CAAC;CACxB;AAOD;;GAEG;AACH,eAAO,MAAM,iBAAiB,+FA+G7B,CAAC"}
1
+ {"version":3,"file":"openmrs-date-picker.component.d.ts","sourceRoot":"","sources":["../../src/datepicker/openmrs-date-picker.component.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqC,MAAM,OAAO,CAAC;AAE1D,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAsB,KAAK,eAAe,EAAsC,MAAM,uBAAuB,CAAC;AACrH,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAWxE;;GAEG;AACH,MAAM,WAAW,sBACf,SAAQ,IAAI,CAAC,eAAe,CAAC,YAAY,CAAC,EAAE,WAAW,GAAG,UAAU,GAAG,cAAc,GAAG,OAAO,CAAC,EAC9F,mBAAmB;IACrB,uCAAuC;IACvC,YAAY,CAAC,EAAE,cAAc,CAAC;IAC9B,qDAAqD;IACrD,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,IAAI,GAAG,IAAI,GAAG,SAAS,KAAK,IAAI,CAAC;IACpD,iHAAiH;IACjH,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,KAAK,IAAI,CAAC;IAChD,kGAAkG;IAClG,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IAC1B,uCAAuC;IACvC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,6BAA6B;IAC7B,KAAK,CAAC,EAAE,cAAc,CAAC;CACxB;AAOD;;GAEG;AACH,eAAO,MAAM,iBAAiB,+FAuH7B,CAAC"}
@@ -103,7 +103,9 @@ const defaultProps = {
103
103
  id: hasVisibleLabel ? id : undefined,
104
104
  ref: ref,
105
105
  className: classNames('cds--date-picker-input__wrapper', styles.inputWrapper, {
106
- [styles.inputWrapperMd]: size === 'md' || !size || size.length === 0
106
+ [styles.inputWrapperSm]: size === 'sm',
107
+ [styles.inputWrapperMd]: size === 'md' || !size || size.length === 0,
108
+ [styles.inputWrapperLg]: size === 'lg'
107
109
  }),
108
110
  children: (segment)=>{
109
111
  return segment.type !== 'era' ? /*#__PURE__*/ _jsx(DateSegment, {
@@ -113,7 +115,11 @@ const defaultProps = {
113
115
  }
114
116
  }),
115
117
  /*#__PURE__*/ _jsx(Button, {
116
- className: classNames(styles.flatButton, styles.flatButtonMd),
118
+ className: classNames(styles.flatButton, {
119
+ [styles.flatButtonSm]: size === 'sm',
120
+ [styles.flatButtonMd]: size === 'md' || !size || size.length === 0,
121
+ [styles.flatButtonLg]: size === 'lg'
122
+ }),
117
123
  children: /*#__PURE__*/ _jsx(DatePickerIcon, {})
118
124
  })
119
125
  ]
@@ -10,6 +10,8 @@ export interface OpenmrsDateRangePickerProps extends Omit<DateRangePickerProps<C
10
10
  onChange?: (value: [Date | null | undefined, Date | null | undefined]) => void;
11
11
  /** Handler that is called when the value changes. Note that this provides types from @internationalized/date. */
12
12
  onChangeRaw?: (value: DateRange | null) => void;
13
+ /** Specifies the size of the input. Currently supports either `sm`, `md`, or `lg` as an option */
14
+ size?: 'sm' | 'md' | 'lg';
13
15
  /** The value (controlled) */
14
16
  value?: [DateInputValue, DateInputValue];
15
17
  }
@@ -1 +1 @@
1
- {"version":3,"file":"openmrs-date-range-picker.component.d.ts","sourceRoot":"","sources":["../../src/datepicker/openmrs-date-range-picker.component.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqC,MAAM,OAAO,CAAC;AAE1D,OAAO,EAIL,KAAK,oBAAoB,EAIzB,KAAK,SAAS,EAEf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAI5D,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAOxE,gDAAgD;AAChD,MAAM,WAAW,2BACf,SAAQ,IAAI,CAAC,oBAAoB,CAAC,YAAY,CAAC,EAAE,WAAW,GAAG,UAAU,GAAG,cAAc,GAAG,OAAO,CAAC,EACnG,mBAAmB;IACrB,uCAAuC;IACvC,YAAY,CAAC,EAAE,CAAC,cAAc,EAAE,cAAc,CAAC,CAAC;IAChD,qDAAqD;IACrD,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,IAAI,GAAG,IAAI,GAAG,SAAS,EAAE,IAAI,GAAG,IAAI,GAAG,SAAS,CAAC,KAAK,IAAI,CAAC;IAC/E,iHAAiH;IACjH,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,KAAK,IAAI,CAAC;IAChD,6BAA6B;IAC7B,KAAK,CAAC,EAAE,CAAC,cAAc,EAAE,cAAc,CAAC,CAAC;CAC1C;AAED;;GAEG;AACH,eAAO,MAAM,sBAAsB,oGAiJlC,CAAC"}
1
+ {"version":3,"file":"openmrs-date-range-picker.component.d.ts","sourceRoot":"","sources":["../../src/datepicker/openmrs-date-range-picker.component.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqC,MAAM,OAAO,CAAC;AAE1D,OAAO,EAIL,KAAK,oBAAoB,EAIzB,KAAK,SAAS,EAEf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAI5D,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAOxE,gDAAgD;AAChD,MAAM,WAAW,2BACf,SAAQ,IAAI,CAAC,oBAAoB,CAAC,YAAY,CAAC,EAAE,WAAW,GAAG,UAAU,GAAG,cAAc,GAAG,OAAO,CAAC,EACnG,mBAAmB;IACrB,uCAAuC;IACvC,YAAY,CAAC,EAAE,CAAC,cAAc,EAAE,cAAc,CAAC,CAAC;IAChD,qDAAqD;IACrD,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,IAAI,GAAG,IAAI,GAAG,SAAS,EAAE,IAAI,GAAG,IAAI,GAAG,SAAS,CAAC,KAAK,IAAI,CAAC;IAC/E,iHAAiH;IACjH,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,KAAK,IAAI,CAAC;IAChD,kGAAkG;IAClG,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IAC1B,6BAA6B;IAC7B,KAAK,CAAC,EAAE,CAAC,cAAc,EAAE,cAAc,CAAC,CAAC;CAC1C;AAED;;GAEG;AACH,eAAO,MAAM,sBAAsB,oGA8JlC,CAAC"}
@@ -12,7 +12,7 @@ import { dateToInternationalizedDate, internationalizedDateToDate } from "./util
12
12
  import { DEFAULT_MIN_DATE_FLOOR } from "./defaults.js";
13
13
  /**
14
14
  * A date range picker to enter or select a date and time range. Based on React Aria, but styled to look like Carbon.
15
- */ export const OpenmrsDateRangePicker = /*#__PURE__*/ forwardRef(function OpenmrsDateRangePicker({ className, defaultValue: rawDefaultValue, invalid, invalidText, isDisabled, isInvalid: isInvalidRaw, label, labelText, light, maxDate: rawMaxDate, minDate: rawMinDate, onChange, onChangeRaw, value: rawValue, ...dateRangePickerProps }, ref) {
15
+ */ export const OpenmrsDateRangePicker = /*#__PURE__*/ forwardRef(function OpenmrsDateRangePicker({ className, defaultValue: rawDefaultValue, invalid, invalidText, isDisabled, isInvalid: isInvalidRaw, label, labelText, light, maxDate: rawMaxDate, minDate: rawMinDate, onChange, onChangeRaw, size = 'md', value: rawValue, ...dateRangePickerProps }, ref) {
16
16
  const { calendar, intlLocale, today_ } = useDatepickerContext();
17
17
  const id = useId();
18
18
  const hasVisibleLabel = !!(labelText ?? label);
@@ -111,7 +111,11 @@ import { DEFAULT_MIN_DATE_FLOOR } from "./defaults.js";
111
111
  className: styles.inputGroup,
112
112
  children: [
113
113
  /*#__PURE__*/ _jsxs("div", {
114
- className: styles.inputsWrapper,
114
+ className: classNames(styles.inputsWrapper, {
115
+ [styles.inputsWrapperSm]: size === 'sm',
116
+ [styles.inputsWrapperMd]: size === 'md' || !size || size.length === 0,
117
+ [styles.inputsWrapperLg]: size === 'lg'
118
+ }),
115
119
  children: [
116
120
  /*#__PURE__*/ _jsx(DateInput, {
117
121
  className: classNames('cds--date-picker-input__wrapper', styles.startInput, styles.dateInputWrapper),
@@ -140,7 +144,11 @@ import { DEFAULT_MIN_DATE_FLOOR } from "./defaults.js";
140
144
  ]
141
145
  }),
142
146
  /*#__PURE__*/ _jsx(Button, {
143
- className: classNames(styles.flatButton, styles.flatButtonMd),
147
+ className: classNames(styles.flatButton, {
148
+ [styles.flatButtonSm]: size === 'sm',
149
+ [styles.flatButtonMd]: size === 'md' || !size || size.length === 0,
150
+ [styles.flatButtonLg]: size === 'lg'
151
+ }),
144
152
  children: /*#__PURE__*/ _jsx(DatePickerIcon, {})
145
153
  })
146
154
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openmrs/esm-styleguide",
3
- "version": "9.0.3-pre.4633",
3
+ "version": "9.0.3-pre.4643",
4
4
  "license": "MPL-2.0",
5
5
  "description": "The styleguide for OpenMRS SPA",
6
6
  "module": "dist/internal.js",
@@ -98,18 +98,18 @@
98
98
  "swr": "2.x"
99
99
  },
100
100
  "devDependencies": {
101
- "@openmrs/esm-api": "9.0.3-pre.4633",
102
- "@openmrs/esm-config": "9.0.3-pre.4633",
103
- "@openmrs/esm-emr-api": "9.0.3-pre.4633",
104
- "@openmrs/esm-error-handling": "9.0.3-pre.4633",
105
- "@openmrs/esm-extensions": "9.0.3-pre.4633",
106
- "@openmrs/esm-globals": "9.0.3-pre.4633",
107
- "@openmrs/esm-navigation": "9.0.3-pre.4633",
108
- "@openmrs/esm-react-utils": "9.0.3-pre.4633",
109
- "@openmrs/esm-routes": "9.0.3-pre.4633",
110
- "@openmrs/esm-state": "9.0.3-pre.4633",
111
- "@openmrs/esm-translations": "9.0.3-pre.4633",
112
- "@openmrs/esm-utils": "9.0.3-pre.4633",
101
+ "@openmrs/esm-api": "9.0.3-pre.4643",
102
+ "@openmrs/esm-config": "9.0.3-pre.4643",
103
+ "@openmrs/esm-emr-api": "9.0.3-pre.4643",
104
+ "@openmrs/esm-error-handling": "9.0.3-pre.4643",
105
+ "@openmrs/esm-extensions": "9.0.3-pre.4643",
106
+ "@openmrs/esm-globals": "9.0.3-pre.4643",
107
+ "@openmrs/esm-navigation": "9.0.3-pre.4643",
108
+ "@openmrs/esm-react-utils": "9.0.3-pre.4643",
109
+ "@openmrs/esm-routes": "9.0.3-pre.4643",
110
+ "@openmrs/esm-state": "9.0.3-pre.4643",
111
+ "@openmrs/esm-translations": "9.0.3-pre.4643",
112
+ "@openmrs/esm-utils": "9.0.3-pre.4643",
113
113
  "@swc/cli": "0.8.1",
114
114
  "@swc/core": "1.15.21",
115
115
  "@types/geopattern": "^1.2.9",
@@ -7,6 +7,7 @@ import userEvent from '@testing-library/user-event';
7
7
  import { useConfig } from '@openmrs/esm-react-utils/mock';
8
8
  import { OpenmrsDateRangePicker } from './index';
9
9
  import { DEFAULT_MIN_DATE_FLOOR } from './defaults';
10
+ import styles from './datepicker.module.scss';
10
11
 
11
12
  describe('OpenmrsDateRangePicker', () => {
12
13
  beforeEach(() => {
@@ -152,6 +153,41 @@ describe('OpenmrsDateRangePicker', () => {
152
153
  });
153
154
  });
154
155
 
156
+ describe('size prop', () => {
157
+ /* eslint-disable testing-library/no-container, testing-library/no-node-access */
158
+ const getInputsWrapper = (container: HTMLElement) =>
159
+ Array.from(container.querySelectorAll('div')).find((el) => el.className.includes('inputsWrapper')) ?? null;
160
+
161
+ it('should apply md size classes by default', () => {
162
+ const { container } = render(<OpenmrsDateRangePicker aria-label="datepicker" />);
163
+ const wrapper = getInputsWrapper(container)!;
164
+ expect(wrapper).toHaveClass(styles.inputsWrapperMd);
165
+ expect(screen.getByRole('button')).toHaveClass(styles.flatButtonMd);
166
+ });
167
+
168
+ it('should apply sm size classes when size="sm"', () => {
169
+ const { container } = render(<OpenmrsDateRangePicker aria-label="datepicker" size="sm" />);
170
+ const wrapper = getInputsWrapper(container)!;
171
+ expect(wrapper).toHaveClass(styles.inputsWrapperSm);
172
+ expect(screen.getByRole('button')).toHaveClass(styles.flatButtonSm);
173
+ });
174
+
175
+ it('should apply md size classes when size="md"', () => {
176
+ const { container } = render(<OpenmrsDateRangePicker aria-label="datepicker" size="md" />);
177
+ const wrapper = getInputsWrapper(container)!;
178
+ expect(wrapper).toHaveClass(styles.inputsWrapperMd);
179
+ expect(screen.getByRole('button')).toHaveClass(styles.flatButtonMd);
180
+ });
181
+
182
+ it('should apply lg size classes when size="lg"', () => {
183
+ const { container } = render(<OpenmrsDateRangePicker aria-label="datepicker" size="lg" />);
184
+ const wrapper = getInputsWrapper(container)!;
185
+ expect(wrapper).toHaveClass(styles.inputsWrapperLg);
186
+ expect(screen.getByRole('button')).toHaveClass(styles.flatButtonLg);
187
+ });
188
+ /* eslint-enable testing-library/no-container, testing-library/no-node-access */
189
+ });
190
+
155
191
  describe('calendar popover', () => {
156
192
  it('should open the calendar popover when the calendar button is clicked', async () => {
157
193
  const user = userEvent.setup();
@@ -114,6 +114,14 @@
114
114
  block-size: layout.$spacing-08;
115
115
  }
116
116
 
117
+ .inputWrapperSm {
118
+ block-size: layout.$spacing-07;
119
+ }
120
+
121
+ .inputWrapperLg {
122
+ block-size: layout.$spacing-09;
123
+ }
124
+
117
125
  // Range date picker inputs
118
126
  .inputsWrapper {
119
127
  display: flex;
@@ -123,6 +131,18 @@
123
131
  inline-size: 15rem;
124
132
  }
125
133
 
134
+ .inputsWrapperSm {
135
+ block-size: layout.$spacing-07;
136
+ }
137
+
138
+ .inputsWrapperMd {
139
+ block-size: layout.$spacing-08;
140
+ }
141
+
142
+ .inputsWrapperLg {
143
+ block-size: layout.$spacing-09;
144
+ }
145
+
126
146
  .dateInputWrapper {
127
147
  @extend .inputWrapper;
128
148
  min-width: unset;
@@ -154,20 +174,31 @@
154
174
  }
155
175
 
156
176
  // Used for calendar pop-over
157
- @keyframes fade-in-down {
177
+ @keyframes expand-in {
158
178
  from {
159
179
  opacity: 0;
160
- transform: translate3d(0, -20px, 0);
180
+ transform: scale(0.93);
161
181
  }
162
182
 
163
183
  to {
164
184
  opacity: 1;
165
- transform: translate3d(0, 0, 0);
185
+ transform: scale(1);
166
186
  }
167
187
  }
168
188
 
189
+ .popover {
190
+ transform-origin: top center;
191
+ }
192
+
193
+ // When the popover flips above the trigger (near bottom of viewport), anchor from the bottom
194
+ .popover[data-placement='top'],
195
+ .popover[data-placement='top-start'],
196
+ .popover[data-placement='top-end'] {
197
+ transform-origin: bottom center;
198
+ }
199
+
169
200
  .popover[data-entering] {
170
- animation: fade-in-down motion.$duration-fast-02 motion.motion(entrance, productive);
201
+ animation: expand-in motion.$duration-fast-02 motion.motion(entrance, productive);
171
202
 
172
203
  @media screen and (prefers-reduced-motion: reduce) {
173
204
  animation: none;
@@ -223,6 +254,16 @@
223
254
  width: layout.$spacing-08;
224
255
  }
225
256
 
257
+ .flatButtonSm {
258
+ height: layout.$spacing-07;
259
+ width: layout.$spacing-07;
260
+ }
261
+
262
+ .flatButtonLg {
263
+ height: layout.$spacing-09;
264
+ width: layout.$spacing-09;
265
+ }
266
+
226
267
  .monthYear {
227
268
  @include component-reset.reset;
228
269
  @include type.type-style('heading-compact-01');
@@ -7,6 +7,7 @@ import userEvent from '@testing-library/user-event';
7
7
  import { useConfig } from '@openmrs/esm-react-utils/mock';
8
8
  import { OpenmrsDatePicker } from './index';
9
9
  import { DEFAULT_MIN_DATE_FLOOR } from './defaults';
10
+ import styles from './datepicker.module.scss';
10
11
 
11
12
  window.i18next = { language: 'en' } as i18n;
12
13
 
@@ -145,6 +146,38 @@ describe('OpenmrsDatePicker', () => {
145
146
  });
146
147
  });
147
148
 
149
+ describe('size prop', () => {
150
+ /* eslint-disable testing-library/no-container, testing-library/no-node-access */
151
+ it('should apply md size classes by default', () => {
152
+ const { container } = render(<OpenmrsDatePicker aria-label="datepicker" />);
153
+ const wrapper = container.querySelector('.cds--date-picker-input__wrapper')!;
154
+ expect(wrapper).toHaveClass(styles.inputWrapperMd);
155
+ expect(screen.getByRole('button')).toHaveClass(styles.flatButtonMd);
156
+ });
157
+
158
+ it('should apply sm size classes when size="sm"', () => {
159
+ const { container } = render(<OpenmrsDatePicker aria-label="datepicker" size="sm" />);
160
+ const wrapper = container.querySelector('.cds--date-picker-input__wrapper')!;
161
+ expect(wrapper).toHaveClass(styles.inputWrapperSm);
162
+ expect(screen.getByRole('button')).toHaveClass(styles.flatButtonSm);
163
+ });
164
+
165
+ it('should apply md size classes when size="md"', () => {
166
+ const { container } = render(<OpenmrsDatePicker aria-label="datepicker" size="md" />);
167
+ const wrapper = container.querySelector('.cds--date-picker-input__wrapper')!;
168
+ expect(wrapper).toHaveClass(styles.inputWrapperMd);
169
+ expect(screen.getByRole('button')).toHaveClass(styles.flatButtonMd);
170
+ });
171
+
172
+ it('should apply lg size classes when size="lg"', () => {
173
+ const { container } = render(<OpenmrsDatePicker aria-label="datepicker" size="lg" />);
174
+ const wrapper = container.querySelector('.cds--date-picker-input__wrapper')!;
175
+ expect(wrapper).toHaveClass(styles.inputWrapperLg);
176
+ expect(screen.getByRole('button')).toHaveClass(styles.flatButtonLg);
177
+ });
178
+ /* eslint-enable testing-library/no-container, testing-library/no-node-access */
179
+ });
180
+
148
181
  describe('calendar popover', () => {
149
182
  it('should open the calendar popover when the calendar button is clicked', async () => {
150
183
  const user = userEvent.setup();
@@ -129,7 +129,9 @@ export const OpenmrsDatePicker = /*#__PURE__*/ forwardRef<HTMLDivElement, Openmr
129
129
  id={hasVisibleLabel ? id : undefined}
130
130
  ref={ref}
131
131
  className={classNames('cds--date-picker-input__wrapper', styles.inputWrapper, {
132
+ [styles.inputWrapperSm]: size === 'sm',
132
133
  [styles.inputWrapperMd]: size === 'md' || !size || size.length === 0,
134
+ [styles.inputWrapperLg]: size === 'lg',
133
135
  })}
134
136
  >
135
137
  {(segment) => {
@@ -140,7 +142,13 @@ export const OpenmrsDatePicker = /*#__PURE__*/ forwardRef<HTMLDivElement, Openmr
140
142
  );
141
143
  }}
142
144
  </DatePickerInput>
143
- <Button className={classNames(styles.flatButton, styles.flatButtonMd)}>
145
+ <Button
146
+ className={classNames(styles.flatButton, {
147
+ [styles.flatButtonSm]: size === 'sm',
148
+ [styles.flatButtonMd]: size === 'md' || !size || size.length === 0,
149
+ [styles.flatButtonLg]: size === 'lg',
150
+ })}
151
+ >
144
152
  <DatePickerIcon />
145
153
  </Button>
146
154
  </Group>
@@ -32,6 +32,8 @@ export interface OpenmrsDateRangePickerProps
32
32
  onChange?: (value: [Date | null | undefined, Date | null | undefined]) => void;
33
33
  /** Handler that is called when the value changes. Note that this provides types from @internationalized/date. */
34
34
  onChangeRaw?: (value: DateRange | null) => void;
35
+ /** Specifies the size of the input. Currently supports either `sm`, `md`, or `lg` as an option */
36
+ size?: 'sm' | 'md' | 'lg';
35
37
  /** The value (controlled) */
36
38
  value?: [DateInputValue, DateInputValue];
37
39
  }
@@ -55,6 +57,7 @@ export const OpenmrsDateRangePicker = /*#__PURE__*/ forwardRef<HTMLDivElement, O
55
57
  minDate: rawMinDate,
56
58
  onChange,
57
59
  onChangeRaw,
60
+ size = 'md',
58
61
  value: rawValue,
59
62
  ...dateRangePickerProps
60
63
  },
@@ -144,7 +147,13 @@ export const OpenmrsDateRangePicker = /*#__PURE__*/ forwardRef<HTMLDivElement, O
144
147
  )}
145
148
 
146
149
  <Group className={styles.inputGroup}>
147
- <div className={styles.inputsWrapper}>
150
+ <div
151
+ className={classNames(styles.inputsWrapper, {
152
+ [styles.inputsWrapperSm]: size === 'sm',
153
+ [styles.inputsWrapperMd]: size === 'md' || !size || size.length === 0,
154
+ [styles.inputsWrapperLg]: size === 'lg',
155
+ })}
156
+ >
148
157
  <DateInput
149
158
  className={classNames(
150
159
  'cds--date-picker-input__wrapper',
@@ -171,7 +180,13 @@ export const OpenmrsDateRangePicker = /*#__PURE__*/ forwardRef<HTMLDivElement, O
171
180
  {(segment) => <DateSegment className={styles.inputSegment} segment={segment} />}
172
181
  </DateInput>
173
182
  </div>
174
- <Button className={classNames(styles.flatButton, styles.flatButtonMd)}>
183
+ <Button
184
+ className={classNames(styles.flatButton, {
185
+ [styles.flatButtonSm]: size === 'sm',
186
+ [styles.flatButtonMd]: size === 'md' || !size || size.length === 0,
187
+ [styles.flatButtonLg]: size === 'lg',
188
+ })}
189
+ >
175
190
  <DatePickerIcon />
176
191
  </Button>
177
192
  </Group>