@hexure/ui 1.9.1 → 1.9.3

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.
@@ -3100,7 +3100,7 @@ const Wrapper$b = styled.div `
3100
3100
  const StyledIcon$4 = styled(Icon) `
3101
3101
  width: 16px;
3102
3102
  height: 16px;
3103
- padding: 0px 6px;
3103
+ margin: 0px 6px;
3104
3104
  color: ${props => props.theme.PRIMARY_COLOR.Hex};
3105
3105
  cursor: pointer;
3106
3106
  `;
@@ -3415,6 +3415,53 @@ const FileUpload = ({ accept, onChange, onError, maxFiles = 10, maxSize = 2, mes
3415
3415
  message ? (React.createElement(Copy, { align: 'center', color: 'GRAY' }, message)) : null))) : null)));
3416
3416
  };
3417
3417
 
3418
+ const getAgesFromDob = (dob) => {
3419
+ let calculated_current_age = null;
3420
+ let calculated_nearest_age = null;
3421
+ if (dob) {
3422
+ // Note: Moment accounts for leap years automatically
3423
+ const birth_date_this_year = Moment(dob).year(Moment().year());
3424
+ const next_birth_date = Moment().isBefore(birth_date_this_year)
3425
+ ? birth_date_this_year
3426
+ : birth_date_this_year.add(1, 'years');
3427
+ calculated_current_age = Moment().diff(dob, 'years');
3428
+ calculated_nearest_age = next_birth_date.isBefore(Moment().add(6, 'months'))
3429
+ ? calculated_current_age + 1
3430
+ : calculated_current_age;
3431
+ }
3432
+ return { calculated_nearest_age, calculated_current_age };
3433
+ };
3434
+ const getDaysForMonth = (month) => {
3435
+ const days = [];
3436
+ let max_days = 31;
3437
+ let i = 1;
3438
+ if ([4, 6, 9, 11].includes(month)) {
3439
+ max_days = 30;
3440
+ }
3441
+ if (month === 2) {
3442
+ max_days = 29;
3443
+ }
3444
+ for (i; i <= max_days; i++) {
3445
+ days.push({ value: i });
3446
+ }
3447
+ return days;
3448
+ };
3449
+ const getYears = () => {
3450
+ const years = [];
3451
+ let i = 1916;
3452
+ for (i; i < 2021; i++) {
3453
+ years.push({ value: i });
3454
+ }
3455
+ return years;
3456
+ };
3457
+ const validateEmail = (email) => {
3458
+ const email_pattern = new RegExp(/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/);
3459
+ return email_pattern.test(email);
3460
+ };
3461
+ const validatePhone = (phone) => {
3462
+ const number_pattern = new RegExp(/^[2-9]\d{9}$/);
3463
+ return number_pattern.test(phone);
3464
+ };
3418
3465
  const formatAsPhone = (number) => {
3419
3466
  let formatted_value = `${number}`.replace(/[^0-9.]/g, '');
3420
3467
  const size = formatted_value.length;
@@ -4328,12 +4375,16 @@ exports.Button = Button;
4328
4375
  exports.ButtonMenu = ButtonMenu;
4329
4376
  exports.Checkbox = Checkbox;
4330
4377
  exports.Checklist = Checklist;
4378
+ exports.Colors = Colors;
4331
4379
  exports.Copy = Copy;
4332
4380
  exports.DatePicker = DatePicker;
4333
4381
  exports.Drawer = Drawer;
4382
+ exports.EditableTheme = EditableTheme;
4334
4383
  exports.Field = Field;
4335
4384
  exports.FieldGroup = FieldGroup;
4336
4385
  exports.FileUpload = FileUpload;
4386
+ exports.FontSizes = FontSizes;
4387
+ exports.FontStyles = FontStyles;
4337
4388
  exports.Heading = Heading;
4338
4389
  exports.Input = Input$1;
4339
4390
  exports.Link = Link;
@@ -4354,4 +4405,11 @@ exports.Tag = Tag;
4354
4405
  exports.Toggle = Toggle;
4355
4406
  exports.Tooltip = Tooltip;
4356
4407
  exports.ZeroState = ZeroState;
4408
+ exports.formatAsPhone = formatAsPhone;
4409
+ exports.formatAsSsn = formatAsSsn;
4410
+ exports.getAgesFromDob = getAgesFromDob;
4411
+ exports.getDaysForMonth = getDaysForMonth;
4412
+ exports.getYears = getYears;
4413
+ exports.validateEmail = validateEmail;
4414
+ exports.validatePhone = validatePhone;
4357
4415
  //# sourceMappingURL=index.js.map