@hexure/ui 1.9.2 → 1.9.4

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/cjs/index.js CHANGED
@@ -4,7 +4,7 @@ var React = require('react');
4
4
  var Icon = require('@mdi/react');
5
5
  var js = require('@mdi/js');
6
6
  var Numeral = require('numeral');
7
- require('moment');
7
+ var Moment = require('moment');
8
8
 
9
9
  /******************************************************************************
10
10
  Copyright (c) Microsoft Corporation.
@@ -2085,6 +2085,9 @@ const StyledButton = styled.button `
2085
2085
  border-style: solid;
2086
2086
  border-color: ${props => props.$border_color || props.theme.PRIMARY_COLOR.Hex};
2087
2087
  box-sizing: border-box;
2088
+
2089
+ &:active,
2090
+ &:focus,
2088
2091
  &:hover {
2089
2092
  opacity: ${props => (props.$disabled ? 0.6 : 1)};
2090
2093
  }
@@ -2481,14 +2484,21 @@ const ButtonMenu = ({ disabled, label, maxHeight, menuItems, small, position = '
2481
2484
  };
2482
2485
 
2483
2486
  const Wrapper$d = styled.label `
2484
- padding: 4px 0;
2487
+ border-radius: 4px;
2488
+ padding: 4px 0px 4px 6px;
2489
+ margin-left: -6px;
2485
2490
  cursor: ${props => (props.$disabled ? 'default' : 'pointer')};
2486
2491
  display: flex;
2487
2492
  align-items: flex-start;
2488
2493
  font-size: ${FontSizes.DEFAULT};
2489
2494
  line-height: 1.6em;
2490
2495
  box-sizing: border-box;
2496
+
2497
+ &:focus-within {
2498
+ background: ${props => `rgba(${props.theme.PRIMARY_COLOR.Rgb}, 0.05)`};
2499
+ }
2491
2500
  `;
2501
+ Wrapper$d.defaultProps = { theme: EditableTheme };
2492
2502
  const Input$2 = styled.input `
2493
2503
  font-size: 20px;
2494
2504
  margin: 5px 0px 0px 0px;
@@ -2891,7 +2901,12 @@ const Wrapper$c = styled.div `
2891
2901
  display: flex;
2892
2902
  align-items: center;
2893
2903
  width: ${({ $style }) => ($style === null || $style === void 0 ? void 0 : $style.width) || 'auto'};
2904
+
2905
+ &:focus-within {
2906
+ border-color: ${props => (props.$readOnly ? '#cccccc' : props.theme.PRIMARY_COLOR.Hex)};
2907
+ }
2894
2908
  `;
2909
+ Wrapper$c.defaultProps = { theme: EditableTheme };
2895
2910
  const Trigger$1 = styled.select `
2896
2911
  appearance: none;
2897
2912
  box-shadow: none;
@@ -3415,6 +3430,53 @@ const FileUpload = ({ accept, onChange, onError, maxFiles = 10, maxSize = 2, mes
3415
3430
  message ? (React.createElement(Copy, { align: 'center', color: 'GRAY' }, message)) : null))) : null)));
3416
3431
  };
3417
3432
 
3433
+ const getAgesFromDob = (dob) => {
3434
+ let calculated_current_age = null;
3435
+ let calculated_nearest_age = null;
3436
+ if (dob) {
3437
+ // Note: Moment accounts for leap years automatically
3438
+ const birth_date_this_year = Moment(dob).year(Moment().year());
3439
+ const next_birth_date = Moment().isBefore(birth_date_this_year)
3440
+ ? birth_date_this_year
3441
+ : birth_date_this_year.add(1, 'years');
3442
+ calculated_current_age = Moment().diff(dob, 'years');
3443
+ calculated_nearest_age = next_birth_date.isBefore(Moment().add(6, 'months'))
3444
+ ? calculated_current_age + 1
3445
+ : calculated_current_age;
3446
+ }
3447
+ return { calculated_nearest_age, calculated_current_age };
3448
+ };
3449
+ const getDaysForMonth = (month) => {
3450
+ const days = [];
3451
+ let max_days = 31;
3452
+ let i = 1;
3453
+ if ([4, 6, 9, 11].includes(month)) {
3454
+ max_days = 30;
3455
+ }
3456
+ if (month === 2) {
3457
+ max_days = 29;
3458
+ }
3459
+ for (i; i <= max_days; i++) {
3460
+ days.push({ value: i });
3461
+ }
3462
+ return days;
3463
+ };
3464
+ const getYears = () => {
3465
+ const years = [];
3466
+ let i = 1916;
3467
+ for (i; i < 2021; i++) {
3468
+ years.push({ value: i });
3469
+ }
3470
+ return years;
3471
+ };
3472
+ const validateEmail = (email) => {
3473
+ const email_pattern = new RegExp(/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/);
3474
+ return email_pattern.test(email);
3475
+ };
3476
+ const validatePhone = (phone) => {
3477
+ const number_pattern = new RegExp(/^[2-9]\d{9}$/);
3478
+ return number_pattern.test(phone);
3479
+ };
3418
3480
  const formatAsPhone = (number) => {
3419
3481
  let formatted_value = `${number}`.replace(/[^0-9.]/g, '');
3420
3482
  const size = formatted_value.length;
@@ -4078,14 +4140,21 @@ const Pagination = (_a) => {
4078
4140
  };
4079
4141
 
4080
4142
  const Wrapper$2 = styled.label `
4081
- padding: 4px 0;
4143
+ border-radius: 4px;
4144
+ padding: 4px 0px 4px 6px;
4145
+ margin-left: -6px;
4082
4146
  cursor: ${props => (props.$disabled ? 'default' : 'pointer')};
4083
4147
  display: flex;
4084
4148
  align-items: center;
4085
4149
  font-size: ${FontSizes.DEFAULT};
4086
4150
  line-height: 1.6rm;
4087
4151
  box-sizing: border-box;
4152
+
4153
+ &:focus-within {
4154
+ background: ${props => `rgba(${props.theme.PRIMARY_COLOR.Rgb}, 0.05)`};
4155
+ }
4088
4156
  `;
4157
+ Wrapper$2.defaultProps = { theme: EditableTheme };
4089
4158
  const Input = styled.input `
4090
4159
  font-size: 20px;
4091
4160
  margin: 0px 0px 2px 0px;
@@ -4328,12 +4397,16 @@ exports.Button = Button;
4328
4397
  exports.ButtonMenu = ButtonMenu;
4329
4398
  exports.Checkbox = Checkbox;
4330
4399
  exports.Checklist = Checklist;
4400
+ exports.Colors = Colors;
4331
4401
  exports.Copy = Copy;
4332
4402
  exports.DatePicker = DatePicker;
4333
4403
  exports.Drawer = Drawer;
4404
+ exports.EditableTheme = EditableTheme;
4334
4405
  exports.Field = Field;
4335
4406
  exports.FieldGroup = FieldGroup;
4336
4407
  exports.FileUpload = FileUpload;
4408
+ exports.FontSizes = FontSizes;
4409
+ exports.FontStyles = FontStyles;
4337
4410
  exports.Heading = Heading;
4338
4411
  exports.Input = Input$1;
4339
4412
  exports.Link = Link;
@@ -4354,4 +4427,11 @@ exports.Tag = Tag;
4354
4427
  exports.Toggle = Toggle;
4355
4428
  exports.Tooltip = Tooltip;
4356
4429
  exports.ZeroState = ZeroState;
4430
+ exports.formatAsPhone = formatAsPhone;
4431
+ exports.formatAsSsn = formatAsSsn;
4432
+ exports.getAgesFromDob = getAgesFromDob;
4433
+ exports.getDaysForMonth = getDaysForMonth;
4434
+ exports.getYears = getYears;
4435
+ exports.validateEmail = validateEmail;
4436
+ exports.validatePhone = validatePhone;
4357
4437
  //# sourceMappingURL=index.js.map