@per-diem-calculator/vanilla 1.0.0 → 1.0.2

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.
Files changed (103) hide show
  1. package/dist/index.js +11034 -0
  2. package/dist/index.umd.cjs +1384 -0
  3. package/package.json +12 -2
  4. package/.prettierrc +0 -17
  5. package/eslint.config.js +0 -29
  6. package/index.html +0 -11
  7. package/public/output.css +0 -2503
  8. package/src/css/_styles.css +0 -8
  9. package/src/css/colors.css +0 -45
  10. package/src/css/fonts.css +0 -9
  11. package/src/css/rows/_heights.css +0 -6
  12. package/src/css/rows/_index.css +0 -15
  13. package/src/css/rows/add.css +0 -18
  14. package/src/css/rows/animate-btns.css +0 -18
  15. package/src/css/rows/animate-row-close.css +0 -18
  16. package/src/css/rows/animate-row-open.css +0 -14
  17. package/src/css/rows/animate-row-other.css +0 -5
  18. package/src/css/rows/btn-add-row.css +0 -41
  19. package/src/css/rows/btn-delete.css +0 -22
  20. package/src/css/rows/btn-expenses-calculate.css +0 -22
  21. package/src/css/rows/btn-expenses-category.css +0 -22
  22. package/src/css/rows/delete.css +0 -10
  23. package/src/css/rows/details.css +0 -22
  24. package/src/css/rows/expense.css +0 -18
  25. package/src/css/rows/location.css +0 -34
  26. package/src/css/rows/summary.css +0 -22
  27. package/src/css/tom-select/defaults.css +0 -530
  28. package/src/css/tom-select/overrides.css +0 -55
  29. package/src/css/tw-shadow-props.css +0 -50
  30. package/src/index.ts +0 -1
  31. package/src/ts/components/Button/Button.ts +0 -50
  32. package/src/ts/components/Button/template.html +0 -34
  33. package/src/ts/components/ExpenseRow/ExpenseRow.ts +0 -397
  34. package/src/ts/components/ExpenseRow/template.html +0 -260
  35. package/src/ts/components/Label/Label.ts +0 -45
  36. package/src/ts/components/Label/template.html +0 -1
  37. package/src/ts/components/LocationCategory/LocationCategory.ts +0 -226
  38. package/src/ts/components/LocationCategory/template.html +0 -520
  39. package/src/ts/components/LocationDate/LocationDate.ts +0 -366
  40. package/src/ts/components/LocationDate/template.html +0 -27
  41. package/src/ts/components/LocationSelect/LocationSelect.ts +0 -299
  42. package/src/ts/components/LocationSelect/template.html +0 -45
  43. package/src/ts/components/index.ts +0 -6
  44. package/src/ts/controller.ts +0 -193
  45. package/src/ts/model.ts +0 -163
  46. package/src/ts/types/config.ts +0 -22
  47. package/src/ts/types/dates.ts +0 -82
  48. package/src/ts/types/expenses.ts +0 -73
  49. package/src/ts/types/locations.ts +0 -25
  50. package/src/ts/utils/config/configDefault.ts +0 -13
  51. package/src/ts/utils/config/index.ts +0 -12
  52. package/src/ts/utils/config/numbers.ts +0 -24
  53. package/src/ts/utils/config/sanitizeConfig.ts +0 -39
  54. package/src/ts/utils/dates/INPUT_DATE_MINMAX.ts +0 -5
  55. package/src/ts/utils/dates/YEAR_REGEX.ts +0 -4
  56. package/src/ts/utils/dates/getDateSlice.ts +0 -54
  57. package/src/ts/utils/dates/getValidAPIYear.ts +0 -17
  58. package/src/ts/utils/dates/index.ts +0 -19
  59. package/src/ts/utils/dates/isDateRaw.ts +0 -90
  60. package/src/ts/utils/dates/isShortMonth.ts +0 -24
  61. package/src/ts/utils/dates/isYYYY.ts +0 -10
  62. package/src/ts/utils/dates/offsetDateString.ts +0 -17
  63. package/src/ts/utils/expenses/INTL_MIE_RATES.ts +0 -2125
  64. package/src/ts/utils/expenses/createExpenseObjs.ts +0 -35
  65. package/src/ts/utils/expenses/getLodgingRateDomestic.ts +0 -73
  66. package/src/ts/utils/expenses/getLodgingRateIntl.ts +0 -119
  67. package/src/ts/utils/expenses/getMieRates.ts +0 -84
  68. package/src/ts/utils/expenses/index.ts +0 -5
  69. package/src/ts/utils/expenses/parseIntlLodgingRates.ts +0 -124
  70. package/src/ts/utils/expenses/returnValidStateExpense.ts +0 -46
  71. package/src/ts/utils/fetch/fetchJsonGSA.ts +0 -29
  72. package/src/ts/utils/fetch/fetchXmlDOD.ts +0 -38
  73. package/src/ts/utils/fetch/index.ts +0 -3
  74. package/src/ts/utils/fetch/memoize.ts +0 -46
  75. package/src/ts/utils/fetch/parseXml.ts +0 -19
  76. package/src/ts/utils/locations/getCitiesDomestic.ts +0 -48
  77. package/src/ts/utils/locations/getCitiesIntl.ts +0 -63
  78. package/src/ts/utils/locations/getCountriesDomestic.ts +0 -237
  79. package/src/ts/utils/locations/getCountriesIntl.ts +0 -34
  80. package/src/ts/utils/locations/index.ts +0 -6
  81. package/src/ts/utils/locations/keepUniqueLocations.ts +0 -12
  82. package/src/ts/utils/locations/locationKeys.ts +0 -10
  83. package/src/ts/utils/locations/returnValidStateLocation.ts +0 -13
  84. package/src/ts/utils/locations/sortLocations.ts +0 -19
  85. package/src/ts/utils/misc/USD.ts +0 -4
  86. package/src/ts/utils/misc/debounce.ts +0 -22
  87. package/src/ts/utils/misc/handlePointerDown.ts +0 -3
  88. package/src/ts/utils/misc/handlePointerUp.ts +0 -22
  89. package/src/ts/utils/misc/inPrimitiveType.ts +0 -4
  90. package/src/ts/utils/misc/index.ts +0 -6
  91. package/src/ts/utils/misc/wait.ts +0 -4
  92. package/src/ts/utils/styles/applyStyles.ts +0 -19
  93. package/src/ts/utils/styles/highlightInput.ts +0 -15
  94. package/src/ts/utils/styles/index.ts +0 -3
  95. package/src/ts/utils/styles/removeStyles.ts +0 -14
  96. package/src/ts/views/Expense/Expense.ts +0 -465
  97. package/src/ts/views/Expense/template.html +0 -176
  98. package/src/ts/views/Location/Location.ts +0 -763
  99. package/src/ts/views/Location/template-row.html +0 -146
  100. package/src/ts/views/Location/template.html +0 -130
  101. package/src/ts/views/index.ts +0 -2
  102. package/tsconfig.json +0 -27
  103. package/vite.config.ts +0 -12
@@ -1,39 +0,0 @@
1
- // Types
2
- import { Config } from '../../types/config';
3
-
4
- // Utils
5
- import { configDefault } from './configDefault';
6
- import DOMPurify from 'dompurify';
7
-
8
- export const sanitizeConfig = (configUser: Partial<Config> | null): Config => {
9
- const sanitizedConfig = { ...configDefault }; // Start with defaults
10
- if (!configUser) return sanitizedConfig;
11
-
12
- // Sanitize 'styled'
13
- if (configUser.styled !== undefined) {
14
- sanitizedConfig.styled = !!configUser.styled; // Ensure it's a boolean
15
- }
16
-
17
- // Sanitize 'location'
18
- if (configUser.location) {
19
- const { heading, body } = configUser.location;
20
- if (heading)
21
- sanitizedConfig.location.heading = DOMPurify.sanitize(heading);
22
- if (body) sanitizedConfig.location.body = DOMPurify.sanitize(body);
23
- }
24
-
25
- // Sanitize 'expense'
26
- if (configUser.expense) {
27
- const { heading, headingPrint, body, bodyPrint } = configUser.expense;
28
- if (heading)
29
- sanitizedConfig.expense.heading = DOMPurify.sanitize(heading);
30
- if (headingPrint)
31
- sanitizedConfig.expense.headingPrint =
32
- DOMPurify.sanitize(headingPrint);
33
- if (body) sanitizedConfig.expense.body = DOMPurify.sanitize(body);
34
- if (bodyPrint)
35
- sanitizedConfig.expense.bodyPrint = DOMPurify.sanitize(bodyPrint);
36
- }
37
-
38
- return sanitizedConfig;
39
- };
@@ -1,5 +0,0 @@
1
- // Utils
2
- import { years } from './isDateRaw';
3
-
4
- export const INPUT_DATE_MAX = `${years[years.length - 1]}-12-31`;
5
- export const INPUT_DATE_MIN = `${years[0]}-01-01`;
@@ -1,4 +0,0 @@
1
- export const YEAR_MIN_REGEX = /^((?:1\d{3})|(?:20(?:0\d|1\d|20)))/; // 1000 to 2020
2
- export const YEAR_MAX_REGEX =
3
- /^(?:[3-9]\d{3,}|[2-9]\d{4,}|20(?:4[1-9]|5\d|6\d|7\d|8\d|9\d))/; // 2041+
4
- export const YEAR_INCOMPLETE_REGEX = /^0\d{3}/; // 0000 to 0999
@@ -1,54 +0,0 @@
1
- // Utils
2
- const DATE_ISO_STRING = 'YYYY-MM-DD';
3
-
4
- const YYYY_START_POSITION = DATE_ISO_STRING.indexOf('Y');
5
- const YYYY_END_POSITION = YYYY_START_POSITION + 'YYYY'.length;
6
-
7
- const YY_START_POSITION = DATE_ISO_STRING.lastIndexOf('YY');
8
- const YY_END_POSITION = YY_START_POSITION + 'YY'.length;
9
-
10
- const MM_START_POSITION = DATE_ISO_STRING.indexOf('M');
11
- const MM_END_POSITION = MM_START_POSITION + 'MM'.length;
12
-
13
- const DD_START_POSITION = DATE_ISO_STRING.indexOf('D');
14
- const DD_END_POSITION = DD_START_POSITION + 'DD'.length;
15
-
16
- const DATE_UTC_STRING = 'Wed, 14 Jun 2017 07:00:00 GMT';
17
- const SHORT_MONTH_START_POSITION = DATE_UTC_STRING.indexOf('Jun');
18
- const SHORT_MONTH_END_POSITION = SHORT_MONTH_START_POSITION + 'Jun'.length;
19
-
20
- const checkIfDateISO = (date: string) => {
21
- if (!(date.length >= DATE_ISO_STRING.length))
22
- throw new Error('Invalid date string format.');
23
- };
24
-
25
- const checkIfDateUTCString = (date: string) => {
26
- if (date.length !== DATE_UTC_STRING.length)
27
- throw new Error('Invalid date string format.');
28
- };
29
-
30
- // 2024-01-30
31
- export const getDateRaw = (date: string) => {
32
- checkIfDateISO(date);
33
- return date.slice(YYYY_START_POSITION, DATE_ISO_STRING.length);
34
- };
35
- export const getYYYY = (date: string) => {
36
- checkIfDateISO(date);
37
- return date.slice(YYYY_START_POSITION, YYYY_END_POSITION); // 2024
38
- };
39
- export const getYY = (date: string, category: 'ISO' | 'YYYY' = 'ISO') => {
40
- if (category === 'ISO') checkIfDateISO(date);
41
- return date.slice(YY_START_POSITION, YY_END_POSITION); // 24
42
- };
43
- export const getMM = (date: string) => {
44
- checkIfDateISO(date);
45
- return date.slice(MM_START_POSITION, MM_END_POSITION); // 01
46
- };
47
- export const getDD = (date: string) => {
48
- checkIfDateISO(date);
49
- return date.slice(DD_START_POSITION, DD_END_POSITION); // 30
50
- };
51
- export const getShortMonth = (date: string) => {
52
- checkIfDateUTCString(date);
53
- return date.slice(SHORT_MONTH_START_POSITION, SHORT_MONTH_END_POSITION);
54
- };
@@ -1,17 +0,0 @@
1
- // Types
2
- import type { DateRaw, YYYY } from '../../types/dates';
3
-
4
- // Utils
5
- import { isYYYY } from './isYYYY';
6
- import { getYYYY } from './getDateSlice';
7
-
8
- export const getValidAPIYear = (dateRaw: DateRaw): YYYY => {
9
- const dateYYYY = getYYYY(dateRaw);
10
- const today = new Date();
11
- const todayYYYY = getYYYY(today.toISOString());
12
-
13
- if (!isYYYY(dateYYYY) || !isYYYY(todayYYYY))
14
- throw new Error('Failed to create valid year for API call.');
15
-
16
- return +dateYYYY > +todayYYYY ? todayYYYY : dateYYYY;
17
- };
@@ -1,19 +0,0 @@
1
- export { isDateRawType } from './isDateRaw';
2
- export { offsetDateString } from './offsetDateString';
3
- export { isYYYY } from './isYYYY';
4
- export { INPUT_DATE_MIN, INPUT_DATE_MAX } from './INPUT_DATE_MINMAX';
5
- export {
6
- YEAR_MIN_REGEX,
7
- YEAR_MAX_REGEX,
8
- YEAR_INCOMPLETE_REGEX,
9
- } from './YEAR_REGEX';
10
- export { getValidAPIYear } from './getValidAPIYear';
11
- export {
12
- getYYYY,
13
- getYY,
14
- getMM,
15
- getDD,
16
- getShortMonth,
17
- getDateRaw,
18
- } from './getDateSlice';
19
- export { isShortMonth } from './isShortMonth';
@@ -1,90 +0,0 @@
1
- // Types
2
- import type { DateRaw } from '../../types/dates';
3
-
4
- // Utils
5
- import { inPrimitiveType } from '../misc';
6
- import { getYYYY, getMM, getDD } from './getDateSlice';
7
-
8
- export const isDateRawType = (s: string): s is DateRaw => {
9
- if (!s) return false;
10
- const year = getYYYY(s);
11
- const month = getMM(s);
12
- const day = getDD(s);
13
- return (
14
- inPrimitiveType(years, year) &&
15
- inPrimitiveType(months, month) &&
16
- inPrimitiveType(days, day)
17
- );
18
- };
19
-
20
- export const years = [
21
- '2021',
22
- '2022',
23
- '2023',
24
- '2024',
25
- '2025',
26
- '2026',
27
- '2027',
28
- '2028',
29
- '2029',
30
- '2030',
31
- '2031',
32
- '2032',
33
- '2033',
34
- '2034',
35
- '2035',
36
- '2036',
37
- '2037',
38
- '2038',
39
- '2039',
40
- '2040',
41
- ] as const;
42
-
43
- const months: string[] = [
44
- '01',
45
- '02',
46
- '03',
47
- '04',
48
- '05',
49
- '06',
50
- '07',
51
- '08',
52
- '09',
53
- '10',
54
- '11',
55
- '12',
56
- ] as const;
57
-
58
- const days: string[] = [
59
- '01',
60
- '02',
61
- '03',
62
- '04',
63
- '05',
64
- '06',
65
- '07',
66
- '08',
67
- '09',
68
- '10',
69
- '11',
70
- '12',
71
- '13',
72
- '14',
73
- '15',
74
- '16',
75
- '17',
76
- '18',
77
- '19',
78
- '20',
79
- '21',
80
- '22',
81
- '23',
82
- '24',
83
- '25',
84
- '26',
85
- '27',
86
- '28',
87
- '29',
88
- '30',
89
- '31',
90
- ] as const;
@@ -1,24 +0,0 @@
1
- // Types
2
- import type { ShortMonth } from '../../types/dates';
3
-
4
- // Utils
5
- import { inPrimitiveType } from '../misc';
6
-
7
- export const isShortMonth = (s: string): s is ShortMonth => {
8
- return inPrimitiveType(shortMonths, s);
9
- };
10
-
11
- const shortMonths = [
12
- 'Jan',
13
- 'Feb',
14
- 'Mar',
15
- 'Apr',
16
- 'May',
17
- 'Jun',
18
- 'Jul',
19
- 'Aug',
20
- 'Sep',
21
- 'Oct',
22
- 'Nov',
23
- 'Dec',
24
- ] as const;
@@ -1,10 +0,0 @@
1
- // Types
2
- import type { YYYY } from '../../types/dates';
3
-
4
- // Utils
5
- import { years } from './isDateRaw';
6
- import { inPrimitiveType } from '../misc';
7
-
8
- export const isYYYY = (s: string): s is YYYY => {
9
- return inPrimitiveType(years, s);
10
- };
@@ -1,17 +0,0 @@
1
- // Types
2
- import { DateRaw } from '../../types/dates';
3
-
4
- // Utils
5
- import { isDateRawType } from './isDateRaw';
6
- import { getDateRaw } from './getDateSlice';
7
-
8
- export const offsetDateString = (
9
- dateRaw: DateRaw,
10
- offset: number | null = null,
11
- ): DateRaw => {
12
- const date = new Date(dateRaw);
13
- if (offset) date.setUTCDate(date.getUTCDate() + offset);
14
- const result = getDateRaw(date.toISOString());
15
- if (!isDateRawType(result)) throw new Error('Failed to create valid date');
16
- return result;
17
- };