@per-diem-calculator/vanilla 1.0.0

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/.prettierrc +17 -0
  2. package/LICENSE +21 -0
  3. package/README.md +1 -0
  4. package/eslint.config.js +29 -0
  5. package/index.html +11 -0
  6. package/package.json +49 -0
  7. package/public/output.css +2503 -0
  8. package/src/css/_styles.css +8 -0
  9. package/src/css/colors.css +45 -0
  10. package/src/css/fonts.css +9 -0
  11. package/src/css/rows/_heights.css +6 -0
  12. package/src/css/rows/_index.css +15 -0
  13. package/src/css/rows/add.css +18 -0
  14. package/src/css/rows/animate-btns.css +18 -0
  15. package/src/css/rows/animate-row-close.css +18 -0
  16. package/src/css/rows/animate-row-open.css +14 -0
  17. package/src/css/rows/animate-row-other.css +5 -0
  18. package/src/css/rows/btn-add-row.css +41 -0
  19. package/src/css/rows/btn-delete.css +22 -0
  20. package/src/css/rows/btn-expenses-calculate.css +22 -0
  21. package/src/css/rows/btn-expenses-category.css +22 -0
  22. package/src/css/rows/delete.css +10 -0
  23. package/src/css/rows/details.css +22 -0
  24. package/src/css/rows/expense.css +18 -0
  25. package/src/css/rows/location.css +34 -0
  26. package/src/css/rows/summary.css +22 -0
  27. package/src/css/tom-select/defaults.css +530 -0
  28. package/src/css/tom-select/overrides.css +55 -0
  29. package/src/css/tw-shadow-props.css +50 -0
  30. package/src/index.ts +1 -0
  31. package/src/ts/components/Button/Button.ts +50 -0
  32. package/src/ts/components/Button/template.html +34 -0
  33. package/src/ts/components/ExpenseRow/ExpenseRow.ts +397 -0
  34. package/src/ts/components/ExpenseRow/template.html +260 -0
  35. package/src/ts/components/Label/Label.ts +45 -0
  36. package/src/ts/components/Label/template.html +1 -0
  37. package/src/ts/components/LocationCategory/LocationCategory.ts +226 -0
  38. package/src/ts/components/LocationCategory/template.html +520 -0
  39. package/src/ts/components/LocationDate/LocationDate.ts +366 -0
  40. package/src/ts/components/LocationDate/template.html +27 -0
  41. package/src/ts/components/LocationSelect/LocationSelect.ts +299 -0
  42. package/src/ts/components/LocationSelect/template.html +45 -0
  43. package/src/ts/components/index.ts +6 -0
  44. package/src/ts/controller.ts +193 -0
  45. package/src/ts/model.ts +163 -0
  46. package/src/ts/types/config.ts +22 -0
  47. package/src/ts/types/dates.ts +82 -0
  48. package/src/ts/types/expenses.ts +73 -0
  49. package/src/ts/types/locations.ts +25 -0
  50. package/src/ts/utils/config/configDefault.ts +13 -0
  51. package/src/ts/utils/config/index.ts +12 -0
  52. package/src/ts/utils/config/numbers.ts +24 -0
  53. package/src/ts/utils/config/sanitizeConfig.ts +39 -0
  54. package/src/ts/utils/dates/INPUT_DATE_MINMAX.ts +5 -0
  55. package/src/ts/utils/dates/YEAR_REGEX.ts +4 -0
  56. package/src/ts/utils/dates/getDateSlice.ts +54 -0
  57. package/src/ts/utils/dates/getValidAPIYear.ts +17 -0
  58. package/src/ts/utils/dates/index.ts +19 -0
  59. package/src/ts/utils/dates/isDateRaw.ts +90 -0
  60. package/src/ts/utils/dates/isShortMonth.ts +24 -0
  61. package/src/ts/utils/dates/isYYYY.ts +10 -0
  62. package/src/ts/utils/dates/offsetDateString.ts +17 -0
  63. package/src/ts/utils/expenses/INTL_MIE_RATES.ts +2125 -0
  64. package/src/ts/utils/expenses/createExpenseObjs.ts +35 -0
  65. package/src/ts/utils/expenses/getLodgingRateDomestic.ts +73 -0
  66. package/src/ts/utils/expenses/getLodgingRateIntl.ts +119 -0
  67. package/src/ts/utils/expenses/getMieRates.ts +84 -0
  68. package/src/ts/utils/expenses/index.ts +5 -0
  69. package/src/ts/utils/expenses/parseIntlLodgingRates.ts +124 -0
  70. package/src/ts/utils/expenses/returnValidStateExpense.ts +46 -0
  71. package/src/ts/utils/fetch/fetchJsonGSA.ts +29 -0
  72. package/src/ts/utils/fetch/fetchXmlDOD.ts +38 -0
  73. package/src/ts/utils/fetch/index.ts +3 -0
  74. package/src/ts/utils/fetch/memoize.ts +46 -0
  75. package/src/ts/utils/fetch/parseXml.ts +19 -0
  76. package/src/ts/utils/locations/getCitiesDomestic.ts +48 -0
  77. package/src/ts/utils/locations/getCitiesIntl.ts +63 -0
  78. package/src/ts/utils/locations/getCountriesDomestic.ts +237 -0
  79. package/src/ts/utils/locations/getCountriesIntl.ts +34 -0
  80. package/src/ts/utils/locations/index.ts +6 -0
  81. package/src/ts/utils/locations/keepUniqueLocations.ts +12 -0
  82. package/src/ts/utils/locations/locationKeys.ts +10 -0
  83. package/src/ts/utils/locations/returnValidStateLocation.ts +13 -0
  84. package/src/ts/utils/locations/sortLocations.ts +19 -0
  85. package/src/ts/utils/misc/USD.ts +4 -0
  86. package/src/ts/utils/misc/debounce.ts +22 -0
  87. package/src/ts/utils/misc/handlePointerDown.ts +3 -0
  88. package/src/ts/utils/misc/handlePointerUp.ts +22 -0
  89. package/src/ts/utils/misc/inPrimitiveType.ts +4 -0
  90. package/src/ts/utils/misc/index.ts +6 -0
  91. package/src/ts/utils/misc/wait.ts +4 -0
  92. package/src/ts/utils/styles/applyStyles.ts +19 -0
  93. package/src/ts/utils/styles/highlightInput.ts +15 -0
  94. package/src/ts/utils/styles/index.ts +3 -0
  95. package/src/ts/utils/styles/removeStyles.ts +14 -0
  96. package/src/ts/views/Expense/Expense.ts +465 -0
  97. package/src/ts/views/Expense/template.html +176 -0
  98. package/src/ts/views/Location/Location.ts +763 -0
  99. package/src/ts/views/Location/template-row.html +146 -0
  100. package/src/ts/views/Location/template.html +130 -0
  101. package/src/ts/views/index.ts +2 -0
  102. package/tsconfig.json +27 -0
  103. package/vite.config.ts +12 -0
@@ -0,0 +1,146 @@
1
+ <li
2
+ data-pdc="location-row"
3
+ class="group [.pdc-row-open]:animate-row-location-open
4
+ sm:[.pdc-row-open]:animate-row-location-open-sm
5
+ [.pdc-row-close]:animate-row-location-close
6
+ sm:[.pdc-row-close]:animate-row-location-close-sm
7
+ [.pdc-row-delete]:animate-row-delete [.pdc-row-add]:animate-row-add
8
+ sm:[.pdc-row-add]:animate-row-add-sm relative flex h-0 items-start
9
+ overflow-hidden bg-white ring-2 ring-transparent transition-shadow
10
+ duration-500 [.pdc-row-initial]:h-[var(--row-location-open)]
11
+ sm:[.pdc-row-initial]:h-[var(--row-location-open-sm)]"
12
+ >
13
+ <!-- Row sidebar: number, toggle -->
14
+ <div
15
+ data-pdc="location-row-sidebar"
16
+ class="relative z-10 mr-4 ml-2 h-[var(--row-location-open)] sm:mr-6
17
+ sm:ml-4 sm:h-[var(--row-location-open-sm)]"
18
+ >
19
+ <div
20
+ data-pdc="location-row-toggle"
21
+ class="my-6 flex h-12 w-full items-center text-neutral-800
22
+ transition-colors hover:cursor-pointer *:hover:cursor-pointer
23
+ group-not-[.pdc-row-close]:hover:[&_button_svg]:!-rotate-0
24
+ group-[.pdc-row-close]:hover:[&_button_svg]:!-rotate-180"
25
+ >
26
+ <button
27
+ title="Toggle row"
28
+ tabindex="0"
29
+ type="button"
30
+ class="focus-visible:border-primary-800 rounded-full border-3
31
+ border-transparent transition-colors focus:outline-none"
32
+ >
33
+ <svg
34
+ inert
35
+ class="size-5 shrink-0 fill-none stroke-current
36
+ transition-transform duration-500
37
+ group-[.pdc-row-add]:-rotate-180
38
+ group-[.pdc-row-close]:rotate-0
39
+ group-[.pdc-row-initial]:-rotate-180
40
+ group-[.pdc-row-open]:-rotate-180 sm:size-6"
41
+ xmlns="http://www.w3.org/2000/svg"
42
+ viewBox="0 0 24 24"
43
+ >
44
+ <path
45
+ stroke-linecap="round"
46
+ stroke-linejoin="round"
47
+ stroke-width="2"
48
+ d="M19 9l-7 7-7-7"
49
+ />
50
+ </svg>
51
+ </button>
52
+ <h3
53
+ data-pdc="location-row-number"
54
+ class="ml-2 text-2xl font-semibold select-none"
55
+ ></h3>
56
+ </div>
57
+ </div>
58
+
59
+ <!-- Row contents: summary, details -->
60
+ <div
61
+ class="relative z-10 flex h-[var(--row-location-open)] w-full
62
+ items-start overflow-hidden sm:h-[var(--row-location-open-sm)]"
63
+ >
64
+ <!-- Summary -->
65
+ <div
66
+ data-pdc="location-row-toggle"
67
+ class="ml-1 flex h-24 w-full items-center justify-between
68
+ hover:cursor-pointer"
69
+ >
70
+ <div
71
+ data-pdc="location-row-summary"
72
+ inert
73
+ class="group-[.pdc-row-open]:animate-row-open-summary
74
+ group-[.pdc-row-close]:animate-row-close-summary
75
+ group-[.pdc-row-initial]:opacity-y-0 w-[77.5%]
76
+ overflow-hidden text-sm
77
+ group-[.pdc-row-add]:translate-y-[-200%]
78
+ group-[.pdc-row-add]:opacity-0
79
+ group-[.pdc-row-initial]:translate-y-[-200%] sm:text-base"
80
+ >
81
+ <p data-pdc="location-row-summary-dates" class="truncate">
82
+ &nbsp;
83
+ </p>
84
+ <p data-pdc="location-row-summary-countrycity" class="truncate">
85
+ &nbsp;
86
+ </p>
87
+ </div>
88
+
89
+ <!-- Delete row button -->
90
+ <button
91
+ tabindex="-1"
92
+ type="button"
93
+ data-pdc="delete-row"
94
+ title="Delete location"
95
+ class="hover:text-error-600 focus-visible:text-error-600
96
+ focus-visible:border-b-primary-800
97
+ group-[.pdc-row-open]:animate-row-open-deletebtn
98
+ group-[.pdc-row-close]:animate-row-close-deletebtn mr-3
99
+ border-b-4 border-b-transparent px-4 py-3 text-neutral-200
100
+ **:transition-colors **:duration-300 **:ease-out
101
+ group-[.pdc-row-add]:translate-x-[200%]
102
+ group-[.pdc-row-initial]:translate-x-[200%]
103
+ hover:cursor-pointer focus:outline-none"
104
+ >
105
+ <svg
106
+ inert
107
+ class="size-7 fill-current sm:size-8"
108
+ data-pdc-unstyled="Delete Location"
109
+ xmlns="http://www.w3.org/2000/svg"
110
+ viewBox="0 0 16 16"
111
+ >
112
+ <path
113
+ d="M5.5 5.5A.5.5 0 0 1 6 6v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5m2.5 0a.5.5 0 0 1 .5.5v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5m3 .5a.5.5 0 0 0-1 0v6a.5.5 0 0 0 1 0z"
114
+ />
115
+ <path
116
+ d="M14.5 3a1 1 0 0 1-1 1H13v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V4h-.5a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1H6a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1h3.5a1 1 0 0 1 1 1zM4.118 4 4 4.059V13a1 1 0 0 0 1 1h6a1 1 0 0 0 1-1V4.059L11.882 4zM2.5 3h11V2h-11z"
117
+ />
118
+ </svg>
119
+ </button>
120
+ </div>
121
+
122
+ <!-- Details -->
123
+ <div
124
+ data-pdc="location-row-details"
125
+ class="group-[.pdc-row-open]:animate-row-open-details
126
+ group-[.pdc-row-add]:animate-row-open-details
127
+ group-[.pdc-row-close]:animate-row-close-details absolute top-0
128
+ left-[-100%] w-full overflow-hidden border-l-2
129
+ border-l-neutral-200 transition-colors
130
+ group-[.pdc-row-initial]:[transform:translateX(100%)]
131
+ group-[.pdc-row-initial]:opacity-100"
132
+ >
133
+ <pdc-location-date pdc="start" styled="true"></pdc-location-date>
134
+ <pdc-location-date pdc="end" styled="true"></pdc-location-date>
135
+ <pdc-location-category
136
+ pdc="category"
137
+ styled="true"
138
+ ></pdc-location-category>
139
+ <pdc-location-select
140
+ pdc="country"
141
+ styled="true"
142
+ ></pdc-location-select>
143
+ <pdc-location-select pdc="city" styled="true"></pdc-location-select>
144
+ </div>
145
+ </div>
146
+ </li>
@@ -0,0 +1,130 @@
1
+ <div
2
+ id="view-container"
3
+ class="group relative mx-auto max-w-xl overflow-hidden p-3
4
+ [transition:height_0.7s_ease] print:hidden"
5
+ >
6
+ <!-- Heading, rows, error container -->
7
+ <div
8
+ id="locations-container"
9
+ class="relative z-10 overflow-hidden rounded-lg ring-2 ring-neutral-300
10
+ [transition:height_0.7s_eas]"
11
+ >
12
+ <div
13
+ class="border-b-2 border-b-neutral-200 bg-white p-4
14
+ text-neutral-900"
15
+ >
16
+ <h3 id="heading" class="text-xl font-semibold"></h3>
17
+ <p id="body" class="mt-2"></p>
18
+ </div>
19
+ <ul
20
+ id="rows"
21
+ class="z-10 overflow-hidden [transition:height_0.7s_ease]"
22
+ ></ul>
23
+ <!-- Error msg -->
24
+ <div
25
+ id="error"
26
+ class="bg-error-50 text-error-700 border-b-error-400 absolute
27
+ -top-16 z-20 flex h-16 w-full translate-y-0 border-b-3 p-4
28
+ font-medium transition-transform [.active]:translate-y-16"
29
+ ></div>
30
+ </div>
31
+
32
+ <!-- Add location button-->
33
+ <div
34
+ class="[.rows-open]:animate-rows-open-addRowBtn
35
+ [.rows-closed]:animate-rows-closed-addRowBtn relative z-0 -mt-5
36
+ w-full [transform:translateY(-100%)] text-center opacity-0"
37
+ >
38
+ <button
39
+ tabindex="-1"
40
+ type="button"
41
+ id="add-row"
42
+ title="Add additional location"
43
+ class="focus-visible:bg-primary-50 focus-visible:text-primary-800
44
+ focus-visible:ring-primary-800 hover:ring-primary-800
45
+ hover:text-primary-800 hover:bg-primary-50 translate-y-0
46
+ cursor-pointer rounded-full bg-neutral-50 p-1 text-neutral-300
47
+ ring-2 ring-neutral-300
48
+ transition-[box-shadow_background-color_transform] duration-500
49
+ hover:-translate-y-1 focus:outline-none focus-visible:ring-6"
50
+ >
51
+ <svg
52
+ xmlns="http://www.w3.org/2000/svg"
53
+ class="size-8 fill-current transition-colors"
54
+ viewBox="0 0 16 16"
55
+ >
56
+ <path
57
+ d="M8 4a.5.5 0 0 1 .5.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3A.5.5 0 0 1 8 4"
58
+ />
59
+ </svg>
60
+ </button>
61
+ </div>
62
+
63
+ <!-- Input for type of per diem (mie vs lodging vs both)-->
64
+ <fieldset
65
+ id="expense-category"
66
+ class="[.rows-open]:animate-rows-open-expenseCategoryBtn
67
+ [.rows-closed]:animate-rows-closed-expenseCategoryBtn relative mt-8
68
+ [transform:translateY(400%)] space-y-6 text-center print:hidden"
69
+ >
70
+ <div
71
+ class="*:hover:bg-primary-900 *:hover:text-primary-50
72
+ *:has-checked:bg-primary-900 *:has-checked:text-primary-50
73
+ bg-primary-50 text-primary-800 *:focus-visible:ring-primary-800
74
+ divide-primary-800 *:focus-visible:!bg-primary-50
75
+ *:focus-visible:!text-primary-800 border-primary-200 mx-auto
76
+ grid max-w-3xs grid-cols-3 divide-x overflow-hidden rounded-lg
77
+ border-2 text-center text-sm font-medium *:cursor-pointer
78
+ *:p-2.5 *:ring-2 *:ring-transparent
79
+ *:transition-[box-shadow_background-color_color] *:duration-500
80
+ *:select-none *:ring-inset *:focus:outline-none
81
+ *:focus-visible:ring-6 sm:max-w-2xs md:max-w-xs"
82
+ >
83
+ <label tabindex="-1" class="" for="mie">
84
+ <input
85
+ type="radio"
86
+ name="expenses-category"
87
+ value="mie"
88
+ id="mie"
89
+ class="hidden"
90
+ />
91
+ M&IE
92
+ </label>
93
+ <label tabindex="-1" class="" for="lodging">
94
+ <input
95
+ type="radio"
96
+ name="expenses-category"
97
+ value="lodging"
98
+ id="lodging"
99
+ class="hidden"
100
+ />
101
+ Lodging
102
+ </label>
103
+ <label tabindex="-1" class="" for="both">
104
+ <input
105
+ type="radio"
106
+ name="expenses-category"
107
+ value="both"
108
+ id="both"
109
+ class="hidden"
110
+ checked="true"
111
+ />
112
+ Both
113
+ </label>
114
+ </div>
115
+ </fieldset>
116
+
117
+ <!-- Button to trigger Expense view -->
118
+ <div
119
+ class="[.rows-open]:animate-rows-open-expensesCalculateBtn
120
+ [.rows-closed]:animate-rows-closed-expensesCalculateBtn mt-6 mb-8
121
+ w-full [transform:translateY(200%)] text-center print:hidden"
122
+ >
123
+ <pdc-button
124
+ styled="true"
125
+ id="calculate-expenses"
126
+ text="Calculate Expenses"
127
+ title="Calculate expenses"
128
+ ></pdc-button>
129
+ </div>
130
+ </div>
@@ -0,0 +1,2 @@
1
+ export { PdcExpenseView } from './Expense/Expense';
2
+ export { PdcLocationView } from './Location/Location';
package/tsconfig.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "compilerOptions": {
3
+ "resolveJsonModule": true,
4
+ "types": ["vite/client"],
5
+
6
+ "target": "ES2022",
7
+ "useDefineForClassFields": true,
8
+ "module": "ESNext",
9
+ "lib": ["ES2022", "DOM", "DOM.Iterable"],
10
+ "skipLibCheck": true,
11
+
12
+ /* Bundler mode */
13
+ "moduleResolution": "bundler",
14
+ "allowImportingTsExtensions": true,
15
+ "isolatedModules": true,
16
+ "moduleDetection": "force",
17
+ "noEmit": true,
18
+
19
+ /* Linting */
20
+ "strict": true,
21
+ "noUnusedLocals": true,
22
+ "noUnusedParameters": true,
23
+ "noFallthroughCasesInSwitch": true,
24
+ "noUncheckedSideEffectImports": true
25
+ },
26
+ "include": ["src"]
27
+ }
package/vite.config.ts ADDED
@@ -0,0 +1,12 @@
1
+ import { defineConfig } from 'vite';
2
+ import legacy from '@vitejs/plugin-legacy';
3
+ import tailwindcss from '@tailwindcss/vite';
4
+
5
+ export default defineConfig({
6
+ plugins: [
7
+ legacy({
8
+ targets: ['defaults', 'not IE 11'],
9
+ }),
10
+ tailwindcss(),
11
+ ],
12
+ });