@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.
@@ -32,3 +32,6 @@ export { default as Tag } from './components/Tag';
32
32
  export { default as Toggle } from './components/Toggle';
33
33
  export { default as Tooltip } from './components/Tooltip';
34
34
  export { default as ZeroState } from './components/ZeroState';
35
+ export * from './utils/Accessibility';
36
+ export * from './utils/Form';
37
+ export * from './Theme';
package/dist/esm/index.js CHANGED
@@ -2,7 +2,7 @@ import React, { useRef, useDebugValue, useContext, createElement, useState, useE
2
2
  import Icon, { Icon as Icon$1 } from '@mdi/react';
3
3
  import { mdiChevronUp, mdiChevronDown, mdiLoading, mdiInformationOutline, mdiAlertOctagonOutline, mdiAlertOutline, mdiCheckboxMarkedCircleOutline, mdiDotsHorizontal, mdiClose, mdiMinusCircle, mdiFolderPlusOutline, mdiChevronRight, mdiChevronLeft, mdiCheck } from '@mdi/js';
4
4
  import Numeral from 'numeral';
5
- import 'moment';
5
+ import Moment from 'moment';
6
6
 
7
7
  /******************************************************************************
8
8
  Copyright (c) Microsoft Corporation.
@@ -2083,6 +2083,9 @@ const StyledButton = styled.button `
2083
2083
  border-style: solid;
2084
2084
  border-color: ${props => props.$border_color || props.theme.PRIMARY_COLOR.Hex};
2085
2085
  box-sizing: border-box;
2086
+
2087
+ &:active,
2088
+ &:focus,
2086
2089
  &:hover {
2087
2090
  opacity: ${props => (props.$disabled ? 0.6 : 1)};
2088
2091
  }
@@ -2479,14 +2482,21 @@ const ButtonMenu = ({ disabled, label, maxHeight, menuItems, small, position = '
2479
2482
  };
2480
2483
 
2481
2484
  const Wrapper$d = styled.label `
2482
- padding: 4px 0;
2485
+ border-radius: 4px;
2486
+ padding: 4px 0px 4px 6px;
2487
+ margin-left: -6px;
2483
2488
  cursor: ${props => (props.$disabled ? 'default' : 'pointer')};
2484
2489
  display: flex;
2485
2490
  align-items: flex-start;
2486
2491
  font-size: ${FontSizes.DEFAULT};
2487
2492
  line-height: 1.6em;
2488
2493
  box-sizing: border-box;
2494
+
2495
+ &:focus-within {
2496
+ background: ${props => `rgba(${props.theme.PRIMARY_COLOR.Rgb}, 0.05)`};
2497
+ }
2489
2498
  `;
2499
+ Wrapper$d.defaultProps = { theme: EditableTheme };
2490
2500
  const Input$2 = styled.input `
2491
2501
  font-size: 20px;
2492
2502
  margin: 5px 0px 0px 0px;
@@ -2889,7 +2899,12 @@ const Wrapper$c = styled.div `
2889
2899
  display: flex;
2890
2900
  align-items: center;
2891
2901
  width: ${({ $style }) => ($style === null || $style === void 0 ? void 0 : $style.width) || 'auto'};
2902
+
2903
+ &:focus-within {
2904
+ border-color: ${props => (props.$readOnly ? '#cccccc' : props.theme.PRIMARY_COLOR.Hex)};
2905
+ }
2892
2906
  `;
2907
+ Wrapper$c.defaultProps = { theme: EditableTheme };
2893
2908
  const Trigger$1 = styled.select `
2894
2909
  appearance: none;
2895
2910
  box-shadow: none;
@@ -3413,6 +3428,53 @@ const FileUpload = ({ accept, onChange, onError, maxFiles = 10, maxSize = 2, mes
3413
3428
  message ? (React.createElement(Copy, { align: 'center', color: 'GRAY' }, message)) : null))) : null)));
3414
3429
  };
3415
3430
 
3431
+ const getAgesFromDob = (dob) => {
3432
+ let calculated_current_age = null;
3433
+ let calculated_nearest_age = null;
3434
+ if (dob) {
3435
+ // Note: Moment accounts for leap years automatically
3436
+ const birth_date_this_year = Moment(dob).year(Moment().year());
3437
+ const next_birth_date = Moment().isBefore(birth_date_this_year)
3438
+ ? birth_date_this_year
3439
+ : birth_date_this_year.add(1, 'years');
3440
+ calculated_current_age = Moment().diff(dob, 'years');
3441
+ calculated_nearest_age = next_birth_date.isBefore(Moment().add(6, 'months'))
3442
+ ? calculated_current_age + 1
3443
+ : calculated_current_age;
3444
+ }
3445
+ return { calculated_nearest_age, calculated_current_age };
3446
+ };
3447
+ const getDaysForMonth = (month) => {
3448
+ const days = [];
3449
+ let max_days = 31;
3450
+ let i = 1;
3451
+ if ([4, 6, 9, 11].includes(month)) {
3452
+ max_days = 30;
3453
+ }
3454
+ if (month === 2) {
3455
+ max_days = 29;
3456
+ }
3457
+ for (i; i <= max_days; i++) {
3458
+ days.push({ value: i });
3459
+ }
3460
+ return days;
3461
+ };
3462
+ const getYears = () => {
3463
+ const years = [];
3464
+ let i = 1916;
3465
+ for (i; i < 2021; i++) {
3466
+ years.push({ value: i });
3467
+ }
3468
+ return years;
3469
+ };
3470
+ const validateEmail = (email) => {
3471
+ const email_pattern = new RegExp(/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/);
3472
+ return email_pattern.test(email);
3473
+ };
3474
+ const validatePhone = (phone) => {
3475
+ const number_pattern = new RegExp(/^[2-9]\d{9}$/);
3476
+ return number_pattern.test(phone);
3477
+ };
3416
3478
  const formatAsPhone = (number) => {
3417
3479
  let formatted_value = `${number}`.replace(/[^0-9.]/g, '');
3418
3480
  const size = formatted_value.length;
@@ -4076,14 +4138,21 @@ const Pagination = (_a) => {
4076
4138
  };
4077
4139
 
4078
4140
  const Wrapper$2 = styled.label `
4079
- padding: 4px 0;
4141
+ border-radius: 4px;
4142
+ padding: 4px 0px 4px 6px;
4143
+ margin-left: -6px;
4080
4144
  cursor: ${props => (props.$disabled ? 'default' : 'pointer')};
4081
4145
  display: flex;
4082
4146
  align-items: center;
4083
4147
  font-size: ${FontSizes.DEFAULT};
4084
4148
  line-height: 1.6rm;
4085
4149
  box-sizing: border-box;
4150
+
4151
+ &:focus-within {
4152
+ background: ${props => `rgba(${props.theme.PRIMARY_COLOR.Rgb}, 0.05)`};
4153
+ }
4086
4154
  `;
4155
+ Wrapper$2.defaultProps = { theme: EditableTheme };
4087
4156
  const Input = styled.input `
4088
4157
  font-size: 20px;
4089
4158
  margin: 0px 0px 2px 0px;
@@ -4318,5 +4387,5 @@ const ZeroState = (_a) => {
4318
4387
  action && (React.createElement(Button, { children: action === null || action === void 0 ? void 0 : action.children, icon: action === null || action === void 0 ? void 0 : action.icon, onClick: action === null || action === void 0 ? void 0 : action.onClick }))));
4319
4388
  };
4320
4389
 
4321
- export { Accordion, ActionDialog, Alert, BulkActionBar, Button, ButtonMenu, Checkbox, Checklist, Copy, DatePicker, Drawer, Field, FieldGroup, FileUpload, Heading, Input$1 as Input, Link, Loader, Logo, Modal, MoreMenu, MultiSelect, PageHeader, Pagination, ProgressBar, Radio, RadioList, Select, Table, Tabs, Tag, Toggle, Tooltip, ZeroState };
4390
+ export { Accordion, ActionDialog, Alert, BulkActionBar, Button, ButtonMenu, Checkbox, Checklist, Colors, Copy, DatePicker, Drawer, EditableTheme, Field, FieldGroup, FileUpload, FontSizes, FontStyles, Heading, Input$1 as Input, Link, Loader, Logo, Modal, MoreMenu, MultiSelect, PageHeader, Pagination, ProgressBar, Radio, RadioList, Select, Table, Tabs, Tag, Toggle, Tooltip, ZeroState, formatAsPhone, formatAsSsn, getAgesFromDob, getDaysForMonth, getYears, validateEmail, validatePhone };
4322
4391
  //# sourceMappingURL=index.js.map