@ubnt/store.core 9.11.0-alpha.0 → 9.11.1

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 (200) hide show
  1. package/CHANGELOG.md +7 -48
  2. package/lib/assets/attention.svg +5 -5
  3. package/lib/assets/attention2.svg +5 -5
  4. package/lib/assets/close2.svg +2 -3
  5. package/lib/assets/close3.svg +3 -2
  6. package/lib/assets/minus4.svg +8 -8
  7. package/lib/assets/minus5.svg +8 -8
  8. package/lib/assets/pause.svg +3 -3
  9. package/lib/assets/pause2.svg +3 -3
  10. package/lib/assets/udmPro.jpg +0 -0
  11. package/lib/assets/udmPro2.jpg +0 -0
  12. package/lib/assets/udmProMax.jpg +0 -0
  13. package/lib/assets/udmProMax2.jpg +0 -0
  14. package/lib/assets/udmProSpecial.jpg +0 -0
  15. package/lib/assets/udmProSpecial2.jpg +0 -0
  16. package/lib/components/FeaturesSection_deprecated/FeaturesSection.js +1 -1
  17. package/lib/components/FeaturesSection_deprecated/FeaturesSection.mjs +1 -1
  18. package/lib/components/FeaturesSection_deprecated/assets/close.svg.js +1 -1
  19. package/lib/components/FeaturesSection_deprecated/assets/close.svg.mjs +2 -2
  20. package/lib/components/Header/ProHeader/ProHeader.js +2 -19
  21. package/lib/components/Header/ProHeader/ProHeader.js.map +1 -1
  22. package/lib/components/Header/ProHeader/ProHeader.mjs +2 -19
  23. package/lib/components/Header/ProHeader/ProHeader.mjs.map +1 -1
  24. package/lib/components/Header/ProHeader/ProHeader.styles.d.ts +0 -1
  25. package/lib/components/Header/ProHeader/ProHeader.styles.js +0 -6
  26. package/lib/components/Header/ProHeader/ProHeader.styles.js.map +1 -1
  27. package/lib/components/Header/ProHeader/ProHeader.styles.mjs +0 -6
  28. package/lib/components/Header/ProHeader/ProHeader.styles.mjs.map +1 -1
  29. package/lib/components/LandingPagePro/LandingPagePro.d.ts +0 -3
  30. package/lib/components/LandingPagePro/LandingPagePro.js +3 -3
  31. package/lib/components/LandingPagePro/LandingPagePro.js.map +1 -1
  32. package/lib/components/LandingPagePro/LandingPagePro.mjs +2 -2
  33. package/lib/components/LandingPagePro/LandingPagePro.mjs.map +1 -1
  34. package/lib/components/MicrositeVideoSlideshow/MicrositeVideoSlideshow.js +1 -1
  35. package/lib/components/MicrositeVideoSlideshow/MicrositeVideoSlideshow.mjs +1 -1
  36. package/lib/components/MicrositeVideoSlideshow/assets/pause.svg.js +1 -1
  37. package/lib/components/MicrositeVideoSlideshow/assets/pause.svg.mjs +2 -2
  38. package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/udmPro.jpg.js +5 -5
  39. package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/udmPro.jpg.mjs +2 -2
  40. package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/udmProMax.jpg.js +5 -5
  41. package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/udmProMax.jpg.mjs +2 -2
  42. package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/udmProSpecial.jpg.js +5 -5
  43. package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/udmProSpecial.jpg.mjs +2 -2
  44. package/lib/components/ModelCompareV3/assets/Consoles/udmPro.jpg.js +1 -1
  45. package/lib/components/ModelCompareV3/assets/Consoles/udmPro.jpg.mjs +2 -2
  46. package/lib/components/ModelCompareV3/assets/Consoles/udmProMax.jpg.js +1 -1
  47. package/lib/components/ModelCompareV3/assets/Consoles/udmProMax.jpg.mjs +2 -2
  48. package/lib/components/ModelCompareV3/assets/Consoles/udmProSpecial.jpg.js +1 -1
  49. package/lib/components/ModelCompareV3/assets/Consoles/udmProSpecial.jpg.mjs +2 -2
  50. package/lib/components/ModelCompareV3/data/CloudGateways.js +9 -9
  51. package/lib/components/ModelCompareV3/data/CloudGateways.mjs +6 -6
  52. package/lib/components/ModelCompareV3/data/products/udmPro.js +1 -1
  53. package/lib/components/ModelCompareV3/data/products/udmPro.mjs +1 -1
  54. package/lib/components/ModelCompareV3/data/products/udmProMax.js +1 -1
  55. package/lib/components/ModelCompareV3/data/products/udmProMax.mjs +1 -1
  56. package/lib/components/ModelCompareV3/data/products/udmProSpecial.js +1 -1
  57. package/lib/components/ModelCompareV3/data/products/udmProSpecial.mjs +1 -1
  58. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.constants.js +1 -6
  59. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.constants.js.map +1 -1
  60. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.constants.mjs +1 -6
  61. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.constants.mjs.map +1 -1
  62. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.js +2 -2
  63. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.js.map +1 -1
  64. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.mjs +2 -2
  65. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.mjs.map +1 -1
  66. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.styles.js +0 -2
  67. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.styles.js.map +1 -1
  68. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.styles.mjs +0 -2
  69. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.styles.mjs.map +1 -1
  70. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputSections/CounterSection.js +1 -1
  71. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputSections/CounterSection.mjs +1 -1
  72. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/assets/attention.svg.js +1 -1
  73. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/assets/attention.svg.mjs +2 -2
  74. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/assets/minus.svg.js +1 -1
  75. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/assets/minus.svg.mjs +2 -2
  76. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/ProgressBarChart/ProgressBarChart.js +1 -1
  77. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/ProgressBarChart/ProgressBarChart.mjs +1 -1
  78. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/ProgressBarChart/assets/attention.svg.js +1 -1
  79. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/ProgressBarChart/assets/attention.svg.mjs +2 -2
  80. package/lib/components/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/PoeConsumerSelectModal/PoeConsumerSelectModal.js +1 -1
  81. package/lib/components/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/PoeConsumerSelectModal/PoeConsumerSelectModal.mjs +1 -1
  82. package/lib/components/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/assets/minus.svg.js +1 -1
  83. package/lib/components/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/assets/minus.svg.mjs +2 -2
  84. package/lib/components/VideoPlayerNew/VideoPlayer.js +2 -2
  85. package/lib/components/VideoPlayerNew/VideoPlayer.mjs +2 -2
  86. package/lib/components/VideoPlayerNew/assets/close.svg.js +1 -1
  87. package/lib/components/VideoPlayerNew/assets/close.svg.mjs +2 -2
  88. package/lib/components/VideoPlayerNew/assets/pause.svg.js +1 -1
  89. package/lib/components/VideoPlayerNew/assets/pause.svg.mjs +2 -2
  90. package/lib/constants/proStoreCategories/mapping/index.d.ts +0 -1
  91. package/lib/constants/proStoreCategories/mapping/index.js +8 -13
  92. package/lib/constants/proStoreCategories/mapping/index.js.map +1 -1
  93. package/lib/constants/proStoreCategories/mapping/index.mjs +8 -13
  94. package/lib/constants/proStoreCategories/mapping/index.mjs.map +1 -1
  95. package/lib/constants/proStoreCategories/mapping/unifi.d.ts +1 -2
  96. package/lib/constants/proStoreCategories/mapping/unifi.js +0 -1
  97. package/lib/constants/proStoreCategories/mapping/unifi.js.map +1 -1
  98. package/lib/constants/proStoreCategories/mapping/unifi.mjs +0 -1
  99. package/lib/constants/proStoreCategories/mapping/unifi.mjs.map +1 -1
  100. package/lib/constants/proStoreCategories/translations/en.json.js +0 -3
  101. package/lib/constants/proStoreCategories/translations/en.json.js.map +1 -1
  102. package/lib/constants/proStoreCategories/translations/en.json.mjs +1 -3
  103. package/lib/constants/proStoreCategories/translations/en.json.mjs.map +1 -1
  104. package/lib/constants/proStoreCategories/translations/fr.json.js +1 -1
  105. package/lib/constants/proStoreCategories/translations/fr.json.mjs +1 -1
  106. package/lib/constants/proStoreCategories/translations/zh-Hans.json.js +1 -1
  107. package/lib/constants/proStoreCategories/translations/zh-Hans.json.mjs +1 -1
  108. package/lib/constants/proStoreCategories/translations/zh-Hant-TW.json.js +1 -1
  109. package/lib/constants/proStoreCategories/translations/zh-Hant-TW.json.mjs +1 -1
  110. package/lib/contexts/MenuContext/mapping.js +7 -1
  111. package/lib/contexts/MenuContext/mapping.js.map +1 -1
  112. package/lib/contexts/MenuContext/mapping.mjs +7 -1
  113. package/lib/contexts/MenuContext/mapping.mjs.map +1 -1
  114. package/lib/utils/money/constants.d.ts +25 -56
  115. package/lib/utils/money/constants.js +7 -72
  116. package/lib/utils/money/constants.js.map +1 -1
  117. package/lib/utils/money/constants.mjs +7 -70
  118. package/lib/utils/money/constants.mjs.map +1 -1
  119. package/lib/utils/money/format.d.ts +5 -10
  120. package/lib/utils/money/format.js +14 -22
  121. package/lib/utils/money/format.js.map +1 -1
  122. package/lib/utils/money/format.mjs +16 -23
  123. package/lib/utils/money/format.mjs.map +1 -1
  124. package/lib/utils/money/index.d.ts +1 -4
  125. package/lib/utils/money/index.js +8 -26
  126. package/lib/utils/money/index.js.map +1 -1
  127. package/lib/utils/money/index.mjs +4 -8
  128. package/lib/utils/money/index.mjs.map +1 -1
  129. package/lib/utils/money/misc.d.ts +28 -68
  130. package/lib/utils/money/misc.js +64 -35
  131. package/lib/utils/money/misc.js.map +1 -1
  132. package/lib/utils/money/misc.mjs +43 -32
  133. package/lib/utils/money/misc.mjs.map +1 -1
  134. package/lib/utils/money/tax.d.ts +2 -38
  135. package/lib/utils/money/tax.js +10 -46
  136. package/lib/utils/money/tax.js.map +1 -1
  137. package/lib/utils/money/tax.mjs +11 -42
  138. package/lib/utils/money/tax.mjs.map +1 -1
  139. package/lib/utils/money/types.d.ts +3 -78
  140. package/lib/utils/number.d.ts +1 -1
  141. package/lib/utils/number.js +1 -1
  142. package/lib/utils/number.js.map +1 -1
  143. package/lib/utils/number.mjs +1 -1
  144. package/lib/utils/number.mjs.map +1 -1
  145. package/lib/utils/validations.d.ts +15 -0
  146. package/lib/utils/validations.js +23 -0
  147. package/lib/utils/validations.js.map +1 -0
  148. package/lib/utils/validations.mjs +21 -0
  149. package/lib/utils/validations.mjs.map +1 -0
  150. package/package.json +2 -2
  151. package/lib/components/Tooltip/Tooltip.d.ts +0 -2
  152. package/lib/components/Tooltip/Tooltip.js +0 -45
  153. package/lib/components/Tooltip/Tooltip.js.map +0 -1
  154. package/lib/components/Tooltip/Tooltip.mjs +0 -43
  155. package/lib/components/Tooltip/Tooltip.mjs.map +0 -1
  156. package/lib/components/Tooltip/Tooltip.styles.d.ts +0 -32
  157. package/lib/components/Tooltip/Tooltip.styles.js +0 -44
  158. package/lib/components/Tooltip/Tooltip.styles.js.map +0 -1
  159. package/lib/components/Tooltip/Tooltip.styles.mjs +0 -34
  160. package/lib/components/Tooltip/Tooltip.styles.mjs.map +0 -1
  161. package/lib/components/Tooltip/index.d.ts +0 -1
  162. package/lib/components/Tooltip/index.js +0 -6
  163. package/lib/components/Tooltip/index.js.map +0 -1
  164. package/lib/components/Tooltip/index.mjs +0 -3
  165. package/lib/components/Tooltip/index.mjs.map +0 -1
  166. package/lib/utils/money/allocators/fixedAmount.d.ts +0 -26
  167. package/lib/utils/money/allocators/fixedAmount.js +0 -55
  168. package/lib/utils/money/allocators/fixedAmount.js.map +0 -1
  169. package/lib/utils/money/allocators/fixedAmount.mjs +0 -53
  170. package/lib/utils/money/allocators/fixedAmount.mjs.map +0 -1
  171. package/lib/utils/money/allocators/index.d.ts +0 -2
  172. package/lib/utils/money/allocators/index.js +0 -8
  173. package/lib/utils/money/allocators/index.js.map +0 -1
  174. package/lib/utils/money/allocators/index.mjs +0 -4
  175. package/lib/utils/money/allocators/index.mjs.map +0 -1
  176. package/lib/utils/money/allocators/productAmount.d.ts +0 -13
  177. package/lib/utils/money/allocators/productAmount.js +0 -110
  178. package/lib/utils/money/allocators/productAmount.js.map +0 -1
  179. package/lib/utils/money/allocators/productAmount.mjs +0 -108
  180. package/lib/utils/money/allocators/productAmount.mjs.map +0 -1
  181. package/lib/utils/money/exchangeRate.d.ts +0 -31
  182. package/lib/utils/money/exchangeRate.js +0 -27
  183. package/lib/utils/money/exchangeRate.js.map +0 -1
  184. package/lib/utils/money/exchangeRate.mjs +0 -23
  185. package/lib/utils/money/exchangeRate.mjs.map +0 -1
  186. package/lib/utils/money/misc.private.d.ts +0 -23
  187. package/lib/utils/money/misc.private.js +0 -46
  188. package/lib/utils/money/misc.private.js.map +0 -1
  189. package/lib/utils/money/misc.private.mjs +0 -21
  190. package/lib/utils/money/misc.private.mjs.map +0 -1
  191. package/lib/utils/money/shipping.d.ts +0 -5
  192. package/lib/utils/money/shipping.js +0 -8
  193. package/lib/utils/money/shipping.js.map +0 -1
  194. package/lib/utils/money/shipping.mjs +0 -6
  195. package/lib/utils/money/shipping.mjs.map +0 -1
  196. package/lib/utils/money/tax.private.d.ts +0 -17
  197. package/lib/utils/money/tax.private.js +0 -65
  198. package/lib/utils/money/tax.private.js.map +0 -1
  199. package/lib/utils/money/tax.private.mjs +0 -60
  200. package/lib/utils/money/tax.private.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"number.mjs","sources":["../../src/utils/number.ts"],"sourcesContent":["/**\n * Util to easily parse that any given input is a finite number (not NaN, Infinity, -Infinity, etc.)\n * @throws If given input is not a finite number\n */\nexport function isFiniteNumber(\n value: unknown,\n entity = \"Value\",\n ErrorClass: new (message: string) => void = TypeError,\n): asserts value is number {\n if (typeof value !== \"number\" || Number.isNaN(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not a number: ${value}`);\n }\n\n if (!Number.isFinite(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not a finite number: ${value}`);\n }\n}\n\n/**\n * Custom isInt validation function that returns a more fine-grained error message otherwise for type safety alone a\n * Number.isSafeInteger would be sufficient.\n *\n * Code inspired from graphql-scalars library.\n * @see\n * https://github.com/Urigo/graphql-scalars/blob/c4fa3d27b965e39ceda6c33fc18041f112ecce49/src/scalars/utilities.ts#L20-L32\n * @throws If given input is not a valid integer\n */\nexport function isInt(\n value: unknown,\n entity = \"Value\",\n ErrorClass: new (message: string) => void = TypeError,\n): asserts value is number {\n isFiniteNumber(value, entity, ErrorClass);\n\n if (!Number.isInteger(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not an integer: ${value}`);\n }\n\n if (!Number.isSafeInteger(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not a safe integer: ${value}`);\n }\n}\n\n/**\n * Custom isFloat validation function that returns a more fine-grained error message otherwise for type safety alone a\n * Number.parseFloat would be sufficient.\n *\n * Code inspired from graphql-scalars library.\n * @see\n * https://github.com/Urigo/graphql-scalars/blob/c4fa3d27b965e39ceda6c33fc18041f112ecce49/src/scalars/utilities.ts#L34-L38\n * @throws If given input is not a valid float\n */\nexport function isFloat(\n value: unknown,\n entity = \"Value\",\n ErrorClass: new (message: string) => void = TypeError,\n): asserts value is number {\n isFiniteNumber(value, entity, ErrorClass);\n}\n\n/**\n * Returns a string representing a number in fixed-point notation.\n * Overload: Returns the rate parsed as a number\n * @example\n * toFixed(1.2345, 2) // => \"1.23\"\n * toFixed(1.2345, 0) // => \"1\"\n * toFixed(1.23, 4) // => \"1.2300\"\n */\nexport function toFixedRate(\n rate: number,\n scale: number,\n asNumber?: boolean,\n): string;\nexport function toFixedRate(\n rate: number,\n scale: number,\n asNumber: true,\n): number;\nexport function toFixedRate(rate: number, scale: number, asNumber?: boolean) {\n // Verify rate\n isFloat(rate, \"Rate\");\n\n const fixedRate = rate.toFixed(scale);\n\n return asNumber ? +fixedRate : fixedRate;\n}\n\n/**\n * Util to convert a float number to a string. Using this rather than simple template string to have a consistent way of\n * doing it. Removes any redundant trailing zeros.\n * @example\n * numberToString(1.23) // => \"1.23\"\n * numberToString(10.00) // => \"10\"\n * @throws If given input is not a valid number\n */\nexport const numberToString = (num: number): string => {\n isFloat(num);\n return num.toString(10);\n};\n\n/**\n * @see https://stackoverflow.com/a/35000557\n */\nexport const findClosestNumber = <T extends number>(\n haystack: T[],\n needle: number,\n): T => {\n return haystack.reduce((prev, curr) =>\n Math.abs(curr - needle) < Math.abs(prev - needle) ? curr : prev,\n );\n};\n\n/**\n * Splits number into array by max value provided.\n * E.g. splitNumberBy(100, 30) => [30, 30, 30, 10]\n */\nexport const splitNumberBy = (value: number, by: number) => {\n const chunks = new Array(Math.floor(value / by)).fill(by);\n const remainder = value % by;\n\n if (remainder > 0) {\n chunks.push(remainder);\n }\n\n return chunks;\n};\n\n/**\n * Clamp value to a given range\n */\nexport const clamp = (val: number, min: number, max: number) => {\n const trueMin = Math.min(min, max);\n const trueMax = Math.max(min, max);\n\n return Math.min(trueMax, Math.max(trueMin, val));\n};\n\n/**\n * Interpolate a number to a new range\n *\n * @example\n * linearInterpolate(5, [0, 10], [0, 100]); // 50\n */\nexport const linearInterpolate = (\n inputY: number,\n [fromMin, fromMax]: [number, number],\n [toMin, toMax]: [number, number],\n clampResult = true,\n) => {\n const percent = (inputY - fromMin) / (fromMax - fromMin);\n const outputX = percent * (toMax - toMin) + toMin;\n\n return clampResult ? clamp(outputX, toMin, toMax) : outputX;\n};\n\n/**\n * Increase value and start over once the range is overflown\n */\nexport const incrementLoopValue = (\n value: number,\n [min, max]: [number, number],\n) => {\n if (value === max) {\n return min;\n }\n return value + 1;\n};\n"],"names":["isFiniteNumber","value","entity","ErrorClass","TypeError","Number","isNaN","isFinite","isInt","isInteger","isSafeInteger","isFloat","toFixedRate","rate","scale","asNumber","fixedRate","toFixed","numberToString","num","toString","findClosestNumber","haystack","needle","reduce","prev","curr","Math","abs","splitNumberBy","by","chunks","Array","floor","fill","remainder","push","clamp","val","min","max","trueMin","trueMax","linearInterpolate","inputY","fromMin","fromMax","toMin","toMax","clampResult","percent","outputX","incrementLoopValue"],"mappings":"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"}
1
+ {"version":3,"file":"number.mjs","sources":["../../src/utils/number.ts"],"sourcesContent":["/**\n * Util to easily parse that any given input is a finite number (not NaN, Infinity, -Infinity, etc.)\n * @throws If given input is not a finite number\n */\nexport function isFiniteNumber(\n value: unknown,\n entity = \"Value\",\n ErrorClass: new (message: string) => void = TypeError,\n): asserts value is number {\n if (typeof value !== \"number\" || Number.isNaN(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not a number: ${value}`);\n }\n\n if (!Number.isFinite(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not a finite number: ${value}`);\n }\n}\n\n/**\n * Custom isInt validation function that returns a more fine-grained error message otherwise for type safety alone a\n * Number.isSafeInteger would be sufficient.\n *\n * Code inspired from graphql-scalars library.\n * @see\n * https://github.com/Urigo/graphql-scalars/blob/c4fa3d27b965e39ceda6c33fc18041f112ecce49/src/scalars/utilities.ts#L20-L32\n * @throws If given input is not a valid integer\n */\nexport function isInt(\n value: unknown,\n entity = \"Value\",\n ErrorClass: new (message: string) => void = TypeError,\n): asserts value is number {\n isFiniteNumber(value, entity, ErrorClass);\n\n if (!Number.isInteger(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not an integer: ${value}`);\n }\n\n if (!Number.isSafeInteger(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not a safe integer: ${value}`);\n }\n}\n\n/**\n * Custom isFloat validation function that returns a more fine-grained error message otherwise for type safety alone a\n * Number.parseFloat would be sufficient.\n *\n * Code inspired from graphql-scalars library.\n * @see\n * https://github.com/Urigo/graphql-scalars/blob/c4fa3d27b965e39ceda6c33fc18041f112ecce49/src/scalars/utilities.ts#L34-L38\n * @throws If given input is not a valid float\n */\nexport function isFloat(\n value: unknown,\n entity = \"Value\",\n ErrorClass: new (message: string) => void = TypeError,\n): asserts value is number {\n isFiniteNumber(value, entity, ErrorClass);\n}\n\n/**\n * Returns a string representing a number in fixed-point notation.\n * Overload: Returns the rate parsed as a number\n * @example\n * toFixed(1.2345, 2) // => \"1.23\"\n * toFixed(1.2345, 0) // => \"1\"\n * toFixed(1.23, 4) // => \"1.2300\"\n */\nexport function toFixedRate(rate: number, scale: number): string;\nexport function toFixedRate(\n rate: number,\n scale: number,\n asNumber: true,\n): number;\nexport function toFixedRate(rate: number, scale = 0, asNumber = false) {\n // Verify rate\n isFloat(rate, \"Rate\");\n\n const fixedRate = rate.toFixed(scale);\n\n return asNumber ? +fixedRate : fixedRate;\n}\n\n/**\n * Util to convert a float number to a string. Using this rather than simple template string to have a consistent way of\n * doing it. Removes any redundant trailing zeros.\n * @example\n * numberToString(1.23) // => \"1.23\"\n * numberToString(10.00) // => \"10\"\n * @throws If given input is not a valid number\n */\nexport const numberToString = (num: number): string => {\n isFloat(num);\n return num.toString(10);\n};\n\n/**\n * @see https://stackoverflow.com/a/35000557\n */\nexport const findClosestNumber = <T extends number>(\n haystack: T[],\n needle: number,\n): T => {\n return haystack.reduce((prev, curr) =>\n Math.abs(curr - needle) < Math.abs(prev - needle) ? curr : prev,\n );\n};\n\n/**\n * Splits number into array by max value provided.\n * E.g. splitNumberBy(100, 30) => [30, 30, 30, 10]\n */\nexport const splitNumberBy = (value: number, by: number) => {\n const chunks = new Array(Math.floor(value / by)).fill(by);\n const remainder = value % by;\n\n if (remainder > 0) {\n chunks.push(remainder);\n }\n\n return chunks;\n};\n\n/**\n * Clamp value to a given range\n */\nexport const clamp = (val: number, min: number, max: number) => {\n const trueMin = Math.min(min, max);\n const trueMax = Math.max(min, max);\n\n return Math.min(trueMax, Math.max(trueMin, val));\n};\n\n/**\n * Interpolate a number to a new range\n *\n * @example\n * linearInterpolate(5, [0, 10], [0, 100]); // 50\n */\nexport const linearInterpolate = (\n inputY: number,\n [fromMin, fromMax]: [number, number],\n [toMin, toMax]: [number, number],\n clampResult = true,\n) => {\n const percent = (inputY - fromMin) / (fromMax - fromMin);\n const outputX = percent * (toMax - toMin) + toMin;\n\n return clampResult ? clamp(outputX, toMin, toMax) : outputX;\n};\n\n/**\n * Increase value and start over once the range is overflown\n */\nexport const incrementLoopValue = (\n value: number,\n [min, max]: [number, number],\n) => {\n if (value === max) {\n return min;\n }\n return value + 1;\n};\n"],"names":["isFiniteNumber","value","entity","ErrorClass","TypeError","Number","isNaN","isFinite","isInt","isInteger","isSafeInteger","isFloat","toFixedRate","rate","scale","asNumber","fixedRate","toFixed","numberToString","num","toString","findClosestNumber","haystack","needle","reduce","prev","curr","Math","abs","splitNumberBy","by","chunks","Array","floor","fill","remainder","push","clamp","val","min","max","trueMin","trueMax","linearInterpolate","inputY","fromMin","fromMax","toMin","toMax","clampResult","percent","outputX","incrementLoopValue"],"mappings":"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"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Util to easily parse that any given input is a finite number (not NaN, Infinity, -Infinity, etc.)
3
+ * @throws If given input is not a finite number
4
+ */
5
+ export declare function isFiniteNumber(value: unknown, entity?: string, ErrorClass?: new (message: string) => void): asserts value is number;
6
+ /**
7
+ * Custom isInt validation function that returns a more fine-grained error message otherwise for type safety alone a
8
+ * Number.isSafeInteger would be sufficient.
9
+ *
10
+ * Code inspired from graphql-scalars library.
11
+ * @see
12
+ * https://github.com/Urigo/graphql-scalars/blob/c4fa3d27b965e39ceda6c33fc18041f112ecce49/src/scalars/utilities.ts#L20-L32
13
+ * @throws If given input is not a valid integer
14
+ */
15
+ export declare function isInt(value: unknown, entity?: string, ErrorClass?: new (message: string) => void): asserts value is number;
@@ -0,0 +1,23 @@
1
+ 'use strict';
2
+ "use strict";
3
+
4
+ function isFiniteNumber(value, entity = "Value", ErrorClass = TypeError) {
5
+ if (typeof value !== "number" || Number.isNaN(value)) {
6
+ throw new ErrorClass(`${entity} is not a number: ${value}`);
7
+ }
8
+ if (!Number.isFinite(value)) {
9
+ throw new ErrorClass(`${entity} is not a finite number: ${value}`);
10
+ }
11
+ }
12
+ function isInt(value, entity = "Value", ErrorClass = TypeError) {
13
+ isFiniteNumber(value, entity, ErrorClass);
14
+ if (!Number.isInteger(value)) {
15
+ throw new ErrorClass(`${entity} is not an integer: ${value}`);
16
+ }
17
+ if (!Number.isSafeInteger(value)) {
18
+ throw new ErrorClass(`${entity} is not a safe integer: ${value}`);
19
+ }
20
+ }
21
+ exports.isFiniteNumber = isFiniteNumber;
22
+ exports.isInt = isInt;
23
+ //# sourceMappingURL=validations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validations.js","sources":["../../src/utils/validations.ts"],"sourcesContent":["/**\n * Util to easily parse that any given input is a finite number (not NaN, Infinity, -Infinity, etc.)\n * @throws If given input is not a finite number\n */\nexport function isFiniteNumber(\n value: unknown,\n entity = \"Value\",\n ErrorClass: new (message: string) => void = TypeError,\n): asserts value is number {\n if (typeof value !== \"number\" || Number.isNaN(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not a number: ${value}`);\n }\n\n if (!Number.isFinite(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not a finite number: ${value}`);\n }\n}\n\n/**\n * Custom isInt validation function that returns a more fine-grained error message otherwise for type safety alone a\n * Number.isSafeInteger would be sufficient.\n *\n * Code inspired from graphql-scalars library.\n * @see\n * https://github.com/Urigo/graphql-scalars/blob/c4fa3d27b965e39ceda6c33fc18041f112ecce49/src/scalars/utilities.ts#L20-L32\n * @throws If given input is not a valid integer\n */\nexport function isInt(\n value: unknown,\n entity = \"Value\",\n ErrorClass: new (message: string) => void = TypeError,\n): asserts value is number {\n isFiniteNumber(value, entity, ErrorClass);\n\n if (!Number.isInteger(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not an integer: ${value}`);\n }\n\n if (!Number.isSafeInteger(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not a safe integer: ${value}`);\n }\n}\n"],"names":["isFiniteNumber","value","entity","ErrorClass","TypeError","Number","isNaN","isFinite","isInt","isInteger","isSafeInteger"],"mappings":";;;AAIO,SAASA,cACdA,CAAAC,KAAA,EACAC,MAAS,GAAA,OAAA,EACTC,aAA4CC,SACnB,EAAA;EACzB,IAAI,OAAOH,KAAU,KAAA,QAAA,IAAYI,MAAO,CAAAC,KAAA,CAAML,KAAK,CAAG,EAAA;IAEpD,MAAM,IAAIE,UAAW,CAAA,GAAGD,MAAM,qBAAqBD,KAAO,EAAA,CAAA;EAC5D;EAEA,IAAI,CAACI,MAAA,CAAOE,QAAS,CAAAN,KAAK,CAAG,EAAA;IAE3B,MAAM,IAAIE,UAAW,CAAA,GAAGD,MAAM,4BAA4BD,KAAO,EAAA,CAAA;EACnE;AACF;AAWO,SAASO,KACdA,CAAAP,KAAA,EACAC,MAAS,GAAA,OAAA,EACTC,aAA4CC,SACnB,EAAA;EACVJ,cAAA,CAAAC,KAAA,EAAOC,QAAQC,UAAU,CAAA;EAExC,IAAI,CAACE,MAAA,CAAOI,SAAU,CAAAR,KAAK,CAAG,EAAA;IAE5B,MAAM,IAAIE,UAAW,CAAA,GAAGD,MAAM,uBAAuBD,KAAO,EAAA,CAAA;EAC9D;EAEA,IAAI,CAACI,MAAA,CAAOK,aAAc,CAAAT,KAAK,CAAG,EAAA;IAEhC,MAAM,IAAIE,UAAW,CAAA,GAAGD,MAAM,2BAA2BD,KAAO,EAAA,CAAA;EAClE;AACF;;"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ function isFiniteNumber(value, entity = "Value", ErrorClass = TypeError) {
4
+ if (typeof value !== "number" || Number.isNaN(value)) {
5
+ throw new ErrorClass(`${entity} is not a number: ${value}`);
6
+ }
7
+ if (!Number.isFinite(value)) {
8
+ throw new ErrorClass(`${entity} is not a finite number: ${value}`);
9
+ }
10
+ }
11
+ function isInt(value, entity = "Value", ErrorClass = TypeError) {
12
+ isFiniteNumber(value, entity, ErrorClass);
13
+ if (!Number.isInteger(value)) {
14
+ throw new ErrorClass(`${entity} is not an integer: ${value}`);
15
+ }
16
+ if (!Number.isSafeInteger(value)) {
17
+ throw new ErrorClass(`${entity} is not a safe integer: ${value}`);
18
+ }
19
+ }
20
+ export { isFiniteNumber, isInt };
21
+ //# sourceMappingURL=validations.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validations.mjs","sources":["../../src/utils/validations.ts"],"sourcesContent":["/**\n * Util to easily parse that any given input is a finite number (not NaN, Infinity, -Infinity, etc.)\n * @throws If given input is not a finite number\n */\nexport function isFiniteNumber(\n value: unknown,\n entity = \"Value\",\n ErrorClass: new (message: string) => void = TypeError,\n): asserts value is number {\n if (typeof value !== \"number\" || Number.isNaN(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not a number: ${value}`);\n }\n\n if (!Number.isFinite(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not a finite number: ${value}`);\n }\n}\n\n/**\n * Custom isInt validation function that returns a more fine-grained error message otherwise for type safety alone a\n * Number.isSafeInteger would be sufficient.\n *\n * Code inspired from graphql-scalars library.\n * @see\n * https://github.com/Urigo/graphql-scalars/blob/c4fa3d27b965e39ceda6c33fc18041f112ecce49/src/scalars/utilities.ts#L20-L32\n * @throws If given input is not a valid integer\n */\nexport function isInt(\n value: unknown,\n entity = \"Value\",\n ErrorClass: new (message: string) => void = TypeError,\n): asserts value is number {\n isFiniteNumber(value, entity, ErrorClass);\n\n if (!Number.isInteger(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not an integer: ${value}`);\n }\n\n if (!Number.isSafeInteger(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not a safe integer: ${value}`);\n }\n}\n"],"names":["isFiniteNumber","value","entity","ErrorClass","TypeError","Number","isNaN","isFinite","isInt","isInteger","isSafeInteger"],"mappings":";;AAIO,SAASA,cACdA,CAAAC,KAAA,EACAC,MAAS,GAAA,OAAA,EACTC,aAA4CC,SACnB,EAAA;EACzB,IAAI,OAAOH,KAAU,KAAA,QAAA,IAAYI,MAAO,CAAAC,KAAA,CAAML,KAAK,CAAG,EAAA;IAEpD,MAAM,IAAIE,UAAW,CAAA,GAAGD,MAAM,qBAAqBD,KAAO,EAAA,CAAA;EAC5D;EAEA,IAAI,CAACI,MAAA,CAAOE,QAAS,CAAAN,KAAK,CAAG,EAAA;IAE3B,MAAM,IAAIE,UAAW,CAAA,GAAGD,MAAM,4BAA4BD,KAAO,EAAA,CAAA;EACnE;AACF;AAWO,SAASO,KACdA,CAAAP,KAAA,EACAC,MAAS,GAAA,OAAA,EACTC,aAA4CC,SACnB,EAAA;EACVJ,cAAA,CAAAC,KAAA,EAAOC,QAAQC,UAAU,CAAA;EAExC,IAAI,CAACE,MAAA,CAAOI,SAAU,CAAAR,KAAK,CAAG,EAAA;IAE5B,MAAM,IAAIE,UAAW,CAAA,GAAGD,MAAM,uBAAuBD,KAAO,EAAA,CAAA;EAC9D;EAEA,IAAI,CAACI,MAAA,CAAOK,aAAc,CAAAT,KAAK,CAAG,EAAA;IAEhC,MAAM,IAAIE,UAAW,CAAA,GAAGD,MAAM,2BAA2BD,KAAO,EAAA,CAAA;EAClE;AACF;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ubnt/store.core",
3
- "version": "9.11.0-alpha.0",
3
+ "version": "9.11.1",
4
4
  "description": "",
5
5
  "sideEffects": false,
6
6
  "scripts": {
@@ -19,7 +19,7 @@
19
19
  ],
20
20
  "dependencies": {
21
21
  "adm-zip": "0.5.14",
22
- "axios": "1.7.2",
22
+ "axios": "1.7.4",
23
23
  "json-stable-stringify": "1.1.1",
24
24
  "terser": "5.31.1",
25
25
  "tldts": "6.1.31"
@@ -1,2 +0,0 @@
1
- import type { TooltipProps } from "@ubnt/ui-components/Tooltip";
2
- export declare const Tooltip: ({ children, tooltipClassName, ...rest }: TooltipProps) => JSX.Element;
@@ -1,45 +0,0 @@
1
- 'use strict';
2
-
3
- var jsxRuntime = require('react/jsx-runtime');
4
- var react = require('react');
5
- var reactUse = require('react-use');
6
- var Tooltip_styles = require('./Tooltip.styles.js');
7
- "use strict";
8
- const Tooltip = ({
9
- children,
10
- tooltipClassName,
11
- ...rest
12
- }) => {
13
- const target = react.useRef(null);
14
- const tooltipRef = react.useRef(null);
15
- const {
16
- y: scrollY
17
- } = reactUse.useWindowScroll();
18
- const [isOpen, setIsOpen] = react.useState();
19
- react.useEffect(() => {
20
- setIsOpen(false);
21
- scrollY;
22
- }, [scrollY]);
23
- reactUse.useClickAway(tooltipRef, () => {
24
- if (isOpen) {
25
- setIsOpen(false);
26
- }
27
- });
28
- const classNameList = [Tooltip_styles.TOOLTIP_CLASS_NAME, tooltipClassName];
29
- const tooltipClassNames = classNameList.join(" ");
30
- return /* @__PURE__ */jsxRuntime.jsx(Tooltip_styles.Tooltip, {
31
- ref: tooltipRef,
32
- isOpen,
33
- ...rest,
34
- tooltipClassName: tooltipClassNames,
35
- children: /* @__PURE__ */jsxRuntime.jsxs("div", {
36
- ref: target,
37
- onMouseLeave: () => setIsOpen(false),
38
- onMouseEnter: () => setIsOpen(true),
39
- onTouchStart: () => setIsOpen(!isOpen),
40
- children: [/* @__PURE__ */jsxRuntime.jsx(Tooltip_styles.TooltipStyles, {}), children]
41
- })
42
- });
43
- };
44
- exports.Tooltip = Tooltip;
45
- //# sourceMappingURL=Tooltip.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Tooltip.js","sources":["../../../src/components/Tooltip/Tooltip.tsx"],"sourcesContent":["import type { TooltipProps } from \"@ubnt/ui-components/Tooltip\";\nimport { useEffect, useRef, useState } from \"react\";\nimport { useClickAway, useWindowScroll } from \"react-use\";\n\nimport * as S from \"./Tooltip.styles\";\nimport { TOOLTIP_CLASS_NAME } from \"./Tooltip.styles\";\n\nexport const Tooltip = ({\n children,\n tooltipClassName,\n ...rest\n}: TooltipProps) => {\n const target = useRef<HTMLDivElement>(null);\n const tooltipRef = useRef<HTMLDivElement>(null);\n const { y: scrollY } = useWindowScroll();\n\n const [isOpen, setIsOpen] = useState<boolean>();\n\n // Hide tooltip when scrolling\n useEffect(() => {\n setIsOpen(false);\n scrollY;\n }, [scrollY]);\n\n useClickAway(tooltipRef, () => {\n if (isOpen) {\n setIsOpen(false);\n }\n });\n\n const classNameList = [TOOLTIP_CLASS_NAME, tooltipClassName];\n const tooltipClassNames = classNameList.join(\" \");\n\n return (\n <S.Tooltip\n ref={tooltipRef}\n isOpen={isOpen}\n {...rest}\n tooltipClassName={tooltipClassNames}\n >\n <div\n ref={target}\n onMouseLeave={() => setIsOpen(false)}\n onMouseEnter={() => setIsOpen(true)}\n onTouchStart={() => setIsOpen(!isOpen)}\n >\n <S.TooltipStyles />\n {children}\n </div>\n </S.Tooltip>\n );\n};\n"],"names":["Tooltip","children","tooltipClassName","rest","target","useRef","tooltipRef","y","scrollY","useWindowScroll","isOpen","setIsOpen","useState","useEffect","useClickAway","classNameList","TOOLTIP_CLASS_NAME","tooltipClassNames","join","jsx","S.Tooltip","ref","jsxs","onMouseLeave","onMouseEnter","onTouchStart","S.TooltipStyles"],"mappings":";;;;;;;AAOO,MAAMA,UAAUA,CAAC;EACtBC,QAAA;EACAC,gBAAA;EACA,GAAGC;AACL,CAAoB,KAAA;EACZ,MAAAC,MAAA,GAASC,aAAuB,IAAI,CAAA;EACpC,MAAAC,UAAA,GAAaD,aAAuB,IAAI,CAAA;EAC9C,MAAM;IAAEE,CAAA,EAAGC;EAAQ,CAAA,GAAIC,QAAgB,CAAAA,eAAA,CAAA,CAAA;EAEvC,MAAM,CAACC,MAAA,EAAQC,SAAS,CAAA,GAAIC,KAAkB,CAAAA,QAAA,CAAA,CAAA;EAG9CC,KAAAA,CAAAA,SAAA,CAAU,MAAM;IACdF,SAAA,CAAU,KAAK,CAAA;IACfH,OAAA;EAAA,CACF,EAAG,CAACA,OAAO,CAAC,CAAA;EAEZM,QAAA,CAAAA,YAAA,CAAaR,YAAY,MAAM;IAC7B,IAAII,MAAQ,EAAA;MACVC,SAAA,CAAU,KAAK,CAAA;IACjB;EAAA,CACD,CAAA;EAEK,MAAAI,aAAA,GAAgB,CAACC,iCAAA,EAAoBd,gBAAgB,CAAA;EACrD,MAAAe,iBAAA,GAAoBF,aAAc,CAAAG,IAAA,CAAK,GAAG,CAAA;EAG9C,sBAAAC,UAAA,CAAAA,GAAA,CAACC,cAAE,CAAApB,OAAA,EAAF;IACCqB,GAAK,EAAAf,UAAA;IACLI,MAAA;IACC,GAAGP,IAAA;IACJD,gBAAkB,EAAAe,iBAAA;IAElBhB,QAAA,iBAAAqB,UAAA,CAAAA,IAAA,CAAC,KAAA,EAAA;MACCD,GAAK,EAAAjB,MAAA;MACLmB,YAAA,EAAcA,CAAA,KAAMZ,SAAA,CAAU,KAAK,CAAA;MACnCa,YAAA,EAAcA,CAAA,KAAMb,SAAA,CAAU,IAAI,CAAA;MAClCc,YAAc,EAAAA,CAAA,KAAMd,SAAU,CAAA,CAACD,MAAM,CAAA;MAErCT,QAAA,EAAA,CAAA,eAACkB,UAAA,CAAAA,GAAA,CAAAO,8BAAA,EAAgB,CAAA,EAChBzB,QAAA;IAAA,CACH;EAAA,CAAA,CACF;AAEJ,CAAA;"}
@@ -1,43 +0,0 @@
1
- import { jsx, jsxs } from 'react/jsx-runtime';
2
- import { useRef, useState, useEffect } from 'react';
3
- import { useWindowScroll, useClickAway } from 'react-use';
4
- import { TOOLTIP_CLASS_NAME, Tooltip as Tooltip$1, TooltipStyles } from './Tooltip.styles.mjs';
5
- "use strict";
6
- const Tooltip = ({
7
- children,
8
- tooltipClassName,
9
- ...rest
10
- }) => {
11
- const target = useRef(null);
12
- const tooltipRef = useRef(null);
13
- const {
14
- y: scrollY
15
- } = useWindowScroll();
16
- const [isOpen, setIsOpen] = useState();
17
- useEffect(() => {
18
- setIsOpen(false);
19
- scrollY;
20
- }, [scrollY]);
21
- useClickAway(tooltipRef, () => {
22
- if (isOpen) {
23
- setIsOpen(false);
24
- }
25
- });
26
- const classNameList = [TOOLTIP_CLASS_NAME, tooltipClassName];
27
- const tooltipClassNames = classNameList.join(" ");
28
- return /* @__PURE__ */jsx(Tooltip$1, {
29
- ref: tooltipRef,
30
- isOpen,
31
- ...rest,
32
- tooltipClassName: tooltipClassNames,
33
- children: /* @__PURE__ */jsxs("div", {
34
- ref: target,
35
- onMouseLeave: () => setIsOpen(false),
36
- onMouseEnter: () => setIsOpen(true),
37
- onTouchStart: () => setIsOpen(!isOpen),
38
- children: [/* @__PURE__ */jsx(TooltipStyles, {}), children]
39
- })
40
- });
41
- };
42
- export { Tooltip };
43
- //# sourceMappingURL=Tooltip.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Tooltip.mjs","sources":["../../../src/components/Tooltip/Tooltip.tsx"],"sourcesContent":["import type { TooltipProps } from \"@ubnt/ui-components/Tooltip\";\nimport { useEffect, useRef, useState } from \"react\";\nimport { useClickAway, useWindowScroll } from \"react-use\";\n\nimport * as S from \"./Tooltip.styles\";\nimport { TOOLTIP_CLASS_NAME } from \"./Tooltip.styles\";\n\nexport const Tooltip = ({\n children,\n tooltipClassName,\n ...rest\n}: TooltipProps) => {\n const target = useRef<HTMLDivElement>(null);\n const tooltipRef = useRef<HTMLDivElement>(null);\n const { y: scrollY } = useWindowScroll();\n\n const [isOpen, setIsOpen] = useState<boolean>();\n\n // Hide tooltip when scrolling\n useEffect(() => {\n setIsOpen(false);\n scrollY;\n }, [scrollY]);\n\n useClickAway(tooltipRef, () => {\n if (isOpen) {\n setIsOpen(false);\n }\n });\n\n const classNameList = [TOOLTIP_CLASS_NAME, tooltipClassName];\n const tooltipClassNames = classNameList.join(\" \");\n\n return (\n <S.Tooltip\n ref={tooltipRef}\n isOpen={isOpen}\n {...rest}\n tooltipClassName={tooltipClassNames}\n >\n <div\n ref={target}\n onMouseLeave={() => setIsOpen(false)}\n onMouseEnter={() => setIsOpen(true)}\n onTouchStart={() => setIsOpen(!isOpen)}\n >\n <S.TooltipStyles />\n {children}\n </div>\n </S.Tooltip>\n );\n};\n"],"names":["Tooltip","children","tooltipClassName","rest","target","useRef","tooltipRef","y","scrollY","useWindowScroll","isOpen","setIsOpen","useState","useEffect","useClickAway","classNameList","TOOLTIP_CLASS_NAME","tooltipClassNames","join","jsx","S.Tooltip","ref","jsxs","onMouseLeave","onMouseEnter","onTouchStart","S.TooltipStyles"],"mappings":";;;;;AAOO,MAAMA,UAAUA,CAAC;EACtBC,QAAA;EACAC,gBAAA;EACA,GAAGC;AACL,CAAoB,KAAA;EACZ,MAAAC,MAAA,GAASC,OAAuB,IAAI,CAAA;EACpC,MAAAC,UAAA,GAAaD,OAAuB,IAAI,CAAA;EAC9C,MAAM;IAAEE,CAAA,EAAGC;EAAQ,CAAA,GAAIC,eAAgB,CAAA,CAAA;EAEvC,MAAM,CAACC,MAAA,EAAQC,SAAS,CAAA,GAAIC,QAAkB,CAAA,CAAA;EAG9CC,SAAA,CAAU,MAAM;IACdF,SAAA,CAAU,KAAK,CAAA;IACfH,OAAA;EAAA,CACF,EAAG,CAACA,OAAO,CAAC,CAAA;EAEZM,YAAA,CAAaR,YAAY,MAAM;IAC7B,IAAII,MAAQ,EAAA;MACVC,SAAA,CAAU,KAAK,CAAA;IACjB;EAAA,CACD,CAAA;EAEK,MAAAI,aAAA,GAAgB,CAACC,kBAAA,EAAoBd,gBAAgB,CAAA;EACrD,MAAAe,iBAAA,GAAoBF,aAAc,CAAAG,IAAA,CAAK,GAAG,CAAA;EAG9C,sBAAAC,GAAA,CAACC,SAAE,EAAF;IACCC,GAAK,EAAAf,UAAA;IACLI,MAAA;IACC,GAAGP,IAAA;IACJD,gBAAkB,EAAAe,iBAAA;IAElBhB,QAAA,iBAAAqB,IAAA,CAAC,KAAA,EAAA;MACCD,GAAK,EAAAjB,MAAA;MACLmB,YAAA,EAAcA,CAAA,KAAMZ,SAAA,CAAU,KAAK,CAAA;MACnCa,YAAA,EAAcA,CAAA,KAAMb,SAAA,CAAU,IAAI,CAAA;MAClCc,YAAc,EAAAA,CAAA,KAAMd,SAAU,CAAA,CAACD,MAAM,CAAA;MAErCT,QAAA,EAAA,CAAA,eAACkB,GAAA,CAAAO,eAAA,EAAgB,CAAA,EAChBzB,QAAA;IAAA,CACH;EAAA,CAAA,CACF;AAEJ,CAAA;"}
@@ -1,32 +0,0 @@
1
- export declare const TOOLTIP_CLASS_NAME = "custom-tooltip";
2
- export declare const Tooltip: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<{
3
- message?: import("react").ReactNode;
4
- tooltipMessageClassName?: string;
5
- messageProps?: Omit<import("@ubnt/ui-components").TextProps, "forwardedRef">;
6
- omitTextWrapper?: boolean;
7
- leftRightInset?: number;
8
- isHoverable?: boolean;
9
- } & {
10
- title?: import("react").ReactNode;
11
- description?: import("react").ReactNode;
12
- children?: import("react").ReactNode;
13
- isOpen?: boolean;
14
- disableHover?: boolean;
15
- isInteractive?: boolean;
16
- cursorType?: "default" | "pointer";
17
- width?: string | number;
18
- maxWidth?: string | number;
19
- position?: import("@ubnt/ui-components/Tooltip").VisualTooltipPosition | import("@ubnt/ui-components/Tooltip").TooltipPosition;
20
- motif?: import("@ubnt/ui-components").Motif;
21
- tooltipClassName?: string;
22
- offset?: number;
23
- delay?: number | import("@ubnt/ui-components").DelayOptions;
24
- autoPosition?: boolean | import("@ubnt/ui-components/Tooltip").TooltipPosition[];
25
- animate?: boolean;
26
- noWrap?: boolean;
27
- className?: string;
28
- style?: import("react").CSSProperties;
29
- portal?: boolean;
30
- onClick?: import("react").MouseEventHandler;
31
- } & Omit<import("react").HTMLAttributes<HTMLElement>, "title"> & import("react").RefAttributes<HTMLElement>>, import("styled-components").DefaultTheme, {}, never>;
32
- export declare const TooltipStyles: import("styled-components").GlobalStyleComponent<{}, import("styled-components").DefaultTheme>;
@@ -1,44 +0,0 @@
1
- 'use strict';
2
-
3
- var Tooltip$1 = require('@ubnt/ui-components/Tooltip');
4
- var styled = require('styled-components');
5
- var theme = require('../../constants/theme.js');
6
- function _interopDefault(e) {
7
- return e && e.__esModule ? e : {
8
- default: e
9
- };
10
- }
11
- var styled__default = /*#__PURE__*/_interopDefault(styled);
12
- "use strict";
13
- const TOOLTIP_CLASS_NAME = "custom-tooltip";
14
- const Tooltip = styled__default["default"](Tooltip$1.Tooltip)`
15
- display: flex;
16
- `;
17
- const TooltipStyles = styled.createGlobalStyle`
18
- .${TOOLTIP_CLASS_NAME} {
19
- white-space: nowrap;
20
- z-index: ${theme.theme.zIndex.header + 1}!important;
21
- border-radius: 8px;
22
- color: #808893;
23
- font-size: 14px;
24
- line-height: 20px;
25
- box-shadow: 0 0 1px 0 rgb(33 35 39 / 0.08), 0 12px 48px 0 rgb(33 35 39 / 0.12);
26
- background-color: #fff;
27
- padding: 16px;
28
-
29
- * {
30
- color: #808893;
31
- font-size: 14px;
32
- line-height: 20px;
33
- }
34
-
35
- &::before {
36
- background-color: #fff;
37
- box-shadow: -4px -4px 4px -4px rgb(33 35 39 / .08);
38
- }
39
- }
40
- `;
41
- exports.TOOLTIP_CLASS_NAME = TOOLTIP_CLASS_NAME;
42
- exports.Tooltip = Tooltip;
43
- exports.TooltipStyles = TooltipStyles;
44
- //# sourceMappingURL=Tooltip.styles.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Tooltip.styles.js","sources":["../../../src/components/Tooltip/Tooltip.styles.tsx"],"sourcesContent":["import { Tooltip as BaseTooltip } from \"@ubnt/ui-components/Tooltip\";\nimport styled, { createGlobalStyle } from \"styled-components\";\n\nimport { theme } from \"../../constants/theme\";\n\nexport const TOOLTIP_CLASS_NAME = \"custom-tooltip\";\n\nexport const Tooltip = styled(BaseTooltip)`\n display: flex;\n`;\n\nexport const TooltipStyles = createGlobalStyle`\n .${TOOLTIP_CLASS_NAME} {\n white-space: nowrap;\n z-index: ${theme.zIndex.header + 1}!important;\n border-radius: 8px;\n color: #808893;\n font-size: 14px;\n line-height: 20px;\n box-shadow: 0 0 1px 0 rgb(33 35 39 / 0.08), 0 12px 48px 0 rgb(33 35 39 / 0.12);\n background-color: #fff;\n padding: 16px;\n\n * {\n color: #808893;\n font-size: 14px;\n line-height: 20px;\n }\n\n &::before {\n background-color: #fff;\n box-shadow: -4px -4px 4px -4px rgb(33 35 39 / .08);\n }\n }\n`;\n"],"names":["TOOLTIP_CLASS_NAME","Tooltip","styled","BaseTooltip","TooltipStyles","createGlobalStyle","theme","zIndex","header"],"mappings":";;;;;;;;;;;;AAKO,MAAMA,kBAAqB,GAAA,gBAAA;AAErB,MAAAC,OAAA,GAAUC,eAAAA,CAAAA,SAAAA,EAAOC,SAAAA,CAAAA,OAAW,CAAA;AAAA;AAAA,CAAA;AAIlC,MAAMC,aAAgB,GAAAC,MAAAA,CAAAA,iBAAA;AAAA,KACxBL,kBAAkB;AAAA;AAAA,eAERM,WAAA,CAAMC,MAAO,CAAAC,MAAA,GAAS,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA;;;"}
@@ -1,34 +0,0 @@
1
- import { Tooltip as Tooltip$1 } from '@ubnt/ui-components/Tooltip';
2
- import styled, { createGlobalStyle } from 'styled-components';
3
- import { theme } from '../../constants/theme.mjs';
4
- "use strict";
5
- const TOOLTIP_CLASS_NAME = "custom-tooltip";
6
- const Tooltip = styled(Tooltip$1)`
7
- display: flex;
8
- `;
9
- const TooltipStyles = createGlobalStyle`
10
- .${TOOLTIP_CLASS_NAME} {
11
- white-space: nowrap;
12
- z-index: ${theme.zIndex.header + 1}!important;
13
- border-radius: 8px;
14
- color: #808893;
15
- font-size: 14px;
16
- line-height: 20px;
17
- box-shadow: 0 0 1px 0 rgb(33 35 39 / 0.08), 0 12px 48px 0 rgb(33 35 39 / 0.12);
18
- background-color: #fff;
19
- padding: 16px;
20
-
21
- * {
22
- color: #808893;
23
- font-size: 14px;
24
- line-height: 20px;
25
- }
26
-
27
- &::before {
28
- background-color: #fff;
29
- box-shadow: -4px -4px 4px -4px rgb(33 35 39 / .08);
30
- }
31
- }
32
- `;
33
- export { TOOLTIP_CLASS_NAME, Tooltip, TooltipStyles };
34
- //# sourceMappingURL=Tooltip.styles.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Tooltip.styles.mjs","sources":["../../../src/components/Tooltip/Tooltip.styles.tsx"],"sourcesContent":["import { Tooltip as BaseTooltip } from \"@ubnt/ui-components/Tooltip\";\nimport styled, { createGlobalStyle } from \"styled-components\";\n\nimport { theme } from \"../../constants/theme\";\n\nexport const TOOLTIP_CLASS_NAME = \"custom-tooltip\";\n\nexport const Tooltip = styled(BaseTooltip)`\n display: flex;\n`;\n\nexport const TooltipStyles = createGlobalStyle`\n .${TOOLTIP_CLASS_NAME} {\n white-space: nowrap;\n z-index: ${theme.zIndex.header + 1}!important;\n border-radius: 8px;\n color: #808893;\n font-size: 14px;\n line-height: 20px;\n box-shadow: 0 0 1px 0 rgb(33 35 39 / 0.08), 0 12px 48px 0 rgb(33 35 39 / 0.12);\n background-color: #fff;\n padding: 16px;\n\n * {\n color: #808893;\n font-size: 14px;\n line-height: 20px;\n }\n\n &::before {\n background-color: #fff;\n box-shadow: -4px -4px 4px -4px rgb(33 35 39 / .08);\n }\n }\n`;\n"],"names":["TOOLTIP_CLASS_NAME","Tooltip","styled","BaseTooltip","TooltipStyles","createGlobalStyle","theme","zIndex","header"],"mappings":";;;;AAKO,MAAMA,kBAAqB,GAAA,gBAAA;AAErB,MAAAC,OAAA,GAAUC,OAAOC,SAAW,CAAA;AAAA;AAAA,CAAA;AAIlC,MAAMC,aAAgB,GAAAC,iBAAA;AAAA,KACxBL,kBAAkB;AAAA;AAAA,eAERM,KAAA,CAAMC,MAAO,CAAAC,MAAA,GAAS,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA;"}
@@ -1 +0,0 @@
1
- export { Tooltip } from "./Tooltip";
@@ -1,6 +0,0 @@
1
- 'use strict';
2
-
3
- var Tooltip = require('./Tooltip.js');
4
- "use strict";
5
- exports.Tooltip = Tooltip.Tooltip;
6
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
@@ -1,3 +0,0 @@
1
- export { Tooltip } from './Tooltip.mjs';
2
- "use strict";
3
- //# sourceMappingURL=index.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -1,26 +0,0 @@
1
- import type { Currency } from "../../../types";
2
- import type { Cents, Dino, DinoCurrency } from "../types";
3
- /**
4
- * Helper class to distribute a fixed amount (e.g. discount) between multiple items.
5
- * For example when trying to apply 5$ discount to 3 items, we need to distribute it evenly as possible
6
- */
7
- export declare class FixedAmountAllocator {
8
- /**
9
- * How much we have left to allocate for given allocation from the remaining total
10
- */
11
- remainingAllocationAmount: Dino;
12
- /**
13
- * How much we have left to allocate in total
14
- */
15
- remainingTotalAmount: Dino;
16
- currency: DinoCurrency;
17
- constructor({ initialAllocateAmount, initialTotalAmount, currency, }: {
18
- initialAllocateAmount: Cents;
19
- initialTotalAmount: Cents;
20
- currency: Currency;
21
- });
22
- /**
23
- * We always allocate biggest share to first item
24
- */
25
- allocate(lineItemTotal: Cents, currency: Currency): Dino;
26
- }
@@ -1,55 +0,0 @@
1
- 'use strict';
2
-
3
- var dinero_js = require('dinero.js');
4
- var errors = require('../../errors.js');
5
- var misc = require('../misc.js');
6
- "use strict";
7
- var __defProp = Object.defineProperty;
8
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
9
- enumerable: true,
10
- configurable: true,
11
- writable: true,
12
- value
13
- }) : obj[key] = value;
14
- var __publicField = (obj, key, value) => {
15
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
16
- return value;
17
- };
18
- class FixedAmountAllocator {
19
- constructor({
20
- initialAllocateAmount,
21
- initialTotalAmount,
22
- currency
23
- }) {
24
- /**
25
- * How much we have left to allocate for given allocation from the remaining total
26
- */
27
- __publicField(this, "remainingAllocationAmount");
28
- /**
29
- * How much we have left to allocate in total
30
- */
31
- __publicField(this, "remainingTotalAmount");
32
- __publicField(this, "currency");
33
- this.remainingAllocationAmount = misc.getDinero(initialAllocateAmount, currency);
34
- this.remainingTotalAmount = misc.getDinero(initialTotalAmount, currency);
35
- this.currency = misc.getDineroCurrency(currency);
36
- }
37
- /**
38
- * We always allocate biggest share to first item
39
- */
40
- allocate(lineItemTotal, currency) {
41
- errors.assert(this.currency.code === currency, `Currency mismatch, expected ${currency}, got ${this.currency.code}`);
42
- const lineItemTotalDinero = misc.getDinero(lineItemTotal, currency);
43
- if (lineItemTotal === 0) {
44
- return lineItemTotalDinero;
45
- }
46
- const [allocationAmount, remainingAllocationAmount] = dinero_js.allocate(this.remainingAllocationAmount, [lineItemTotal, Math.max(misc.amount(this.remainingTotalAmount) - lineItemTotal, 0)]);
47
- errors.assert(!!allocationAmount, "Allocation amount is zero");
48
- errors.assert(!!remainingAllocationAmount, "Remaining allocation remainder is zero");
49
- this.remainingAllocationAmount = remainingAllocationAmount;
50
- this.remainingTotalAmount = dinero_js.subtract(this.remainingTotalAmount, lineItemTotalDinero);
51
- return dinero_js.greaterThan(allocationAmount, lineItemTotalDinero) ? lineItemTotalDinero : allocationAmount;
52
- }
53
- }
54
- exports.FixedAmountAllocator = FixedAmountAllocator;
55
- //# sourceMappingURL=fixedAmount.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fixedAmount.js","sources":["../../../../src/utils/money/allocators/fixedAmount.ts"],"sourcesContent":["import { allocate, greaterThan, subtract } from \"dinero.js\";\n\nimport type { Currency } from \"../../../types\";\nimport { assert } from \"../../errors\";\nimport { amount, getDinero, getDineroCurrency } from \"../misc\";\nimport type { Cents, Dino, DinoCurrency } from \"../types\";\n\n/**\n * Helper class to distribute a fixed amount (e.g. discount) between multiple items.\n * For example when trying to apply 5$ discount to 3 items, we need to distribute it evenly as possible\n */\nexport class FixedAmountAllocator {\n /**\n * How much we have left to allocate for given allocation from the remaining total\n */\n public remainingAllocationAmount: Dino;\n /**\n * How much we have left to allocate in total\n */\n public remainingTotalAmount: Dino;\n public currency: DinoCurrency;\n\n constructor({\n initialAllocateAmount,\n initialTotalAmount,\n currency,\n }: {\n initialAllocateAmount: Cents;\n initialTotalAmount: Cents;\n currency: Currency;\n }) {\n this.remainingAllocationAmount = getDinero(initialAllocateAmount, currency);\n this.remainingTotalAmount = getDinero(initialTotalAmount, currency);\n this.currency = getDineroCurrency(currency);\n }\n\n /**\n * We always allocate biggest share to first item\n */\n allocate(lineItemTotal: Cents, currency: Currency): Dino {\n assert(\n this.currency.code === currency,\n `Currency mismatch, expected ${currency}, got ${this.currency.code}`,\n );\n const lineItemTotalDinero = getDinero(lineItemTotal, currency);\n /**\n * If total price of line items is zero, it means it's free, thus no discount\n * can be calculated (it's either 0 or infinity, but let's go with 0)\n */\n if (lineItemTotal === 0) {\n return lineItemTotalDinero;\n }\n\n const [allocationAmount, remainingAllocationAmount] = allocate(\n this.remainingAllocationAmount,\n [\n lineItemTotal,\n Math.max(amount(this.remainingTotalAmount) - lineItemTotal, 0),\n ],\n );\n\n assert(!!allocationAmount, \"Allocation amount is zero\");\n assert(\n !!remainingAllocationAmount,\n \"Remaining allocation remainder is zero\",\n );\n\n this.remainingAllocationAmount = remainingAllocationAmount;\n this.remainingTotalAmount = subtract(\n this.remainingTotalAmount,\n lineItemTotalDinero,\n );\n\n /**\n * The discount amount is evenly split but can still be higher than the line item total\n * Need to ceil the price to be not more than the line item total\n */\n return greaterThan(allocationAmount, lineItemTotalDinero)\n ? lineItemTotalDinero\n : allocationAmount;\n }\n}\n"],"names":["FixedAmountAllocator","constructor","initialAllocateAmount","initialTotalAmount","currency","__publicField","remainingAllocationAmount","getDinero","remainingTotalAmount","getDineroCurrency","allocate","lineItemTotal","assert","code","lineItemTotalDinero","allocationAmount","Math","max","amount","subtract","greaterThan"],"mappings":";;;;;;;;;;;;;;;;;AAWO,MAAMA,oBAAqB,CAAA;EAWhCC,WAAYA,CAAA;IACVC,qBAAA;IACAC,kBAAA;IACAC;EAAA,CAKC,EAAA;IAfH;AAAA;AAAA;IAAOC,aAAA,CAAA,IAAA,EAAA,2BAAA,CAAA;IAIP;AAAA;AAAA;IAAOA,aAAA,CAAA,IAAA,EAAA,sBAAA,CAAA;IACAA,aAAA,CAAA,IAAA,EAAA,UAAA,CAAA;IAWA,IAAA,CAAAC,yBAAA,GAA4BC,IAAAA,CAAAA,SAAU,CAAAL,qBAAA,EAAuBE,QAAQ,CAAA;IACrE,IAAA,CAAAI,oBAAA,GAAuBD,IAAAA,CAAAA,SAAU,CAAAJ,kBAAA,EAAoBC,QAAQ,CAAA;IAC7D,IAAA,CAAAA,QAAA,GAAWK,uBAAkBL,QAAQ,CAAA;EAC5C;EAAA;AAAA;AAAA;EAKAM,QAAAA,CAASC,eAAsBP,QAA0B,EAAA;IACvDQ,MAAA,CAAAA,MAAA,CACE,IAAA,CAAKR,SAASS,IAAS,KAAAT,QAAA,EACQ,+BAAAA,QAAiB,SAAA,IAAA,CAAKA,SAASS,IAAI,EAAA,CACpE;IACM,MAAAC,mBAAA,GAAsBP,IAAAA,CAAAA,SAAU,CAAAI,aAAA,EAAeP,QAAQ,CAAA;IAK7D,IAAIO,kBAAkB,CAAG,EAAA;MAChB,OAAAG,mBAAA;IACT;IAEM,MAAA,CAACC,gBAAkB,EAAAT,yBAAyB,CAAI,GAAAI,SAAA,CAAAA,QAAA,CACpD,IAAK,CAAAJ,yBAAA,EACL,CACEK,aAAA,EACAK,KAAKC,GAAI,CAAAC,WAAA,CAAO,KAAKV,oBAAoB,CAAA,GAAIG,eAAe,CAAC,CAAA,CAC/D,CACF;IAEOC,MAAAA,CAAAA,MAAA,CAAA,CAAC,CAACG,gBAAA,EAAkB,2BAA2B,CAAA;IACtDH,MAAA,CAAAA,MAAA,CACE,CAAC,CAACN,yBAAA,EACF,wCAAA,CACF;IAEA,IAAA,CAAKA,yBAA4B,GAAAA,yBAAA;IACjC,IAAA,CAAKE,oBAAuB,GAAAW,SAAA,CAAAA,QAAA,CAC1B,IAAK,CAAAX,oBAAA,EACLM,mBAAA,CACF;IAMA,OAAOM,SAAY,CAAAA,WAAA,CAAAL,gBAAA,EAAkBD,mBAAmB,CAAA,GACpDA,mBACA,GAAAC,gBAAA;EACN;AACF;"}
@@ -1,53 +0,0 @@
1
- import { allocate, subtract, greaterThan } from 'dinero.js';
2
- import { assert } from '../../errors.mjs';
3
- import { getDinero, getDineroCurrency, amount } from '../misc.mjs';
4
- "use strict";
5
- var __defProp = Object.defineProperty;
6
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
7
- enumerable: true,
8
- configurable: true,
9
- writable: true,
10
- value
11
- }) : obj[key] = value;
12
- var __publicField = (obj, key, value) => {
13
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
14
- return value;
15
- };
16
- class FixedAmountAllocator {
17
- constructor({
18
- initialAllocateAmount,
19
- initialTotalAmount,
20
- currency
21
- }) {
22
- /**
23
- * How much we have left to allocate for given allocation from the remaining total
24
- */
25
- __publicField(this, "remainingAllocationAmount");
26
- /**
27
- * How much we have left to allocate in total
28
- */
29
- __publicField(this, "remainingTotalAmount");
30
- __publicField(this, "currency");
31
- this.remainingAllocationAmount = getDinero(initialAllocateAmount, currency);
32
- this.remainingTotalAmount = getDinero(initialTotalAmount, currency);
33
- this.currency = getDineroCurrency(currency);
34
- }
35
- /**
36
- * We always allocate biggest share to first item
37
- */
38
- allocate(lineItemTotal, currency) {
39
- assert(this.currency.code === currency, `Currency mismatch, expected ${currency}, got ${this.currency.code}`);
40
- const lineItemTotalDinero = getDinero(lineItemTotal, currency);
41
- if (lineItemTotal === 0) {
42
- return lineItemTotalDinero;
43
- }
44
- const [allocationAmount, remainingAllocationAmount] = allocate(this.remainingAllocationAmount, [lineItemTotal, Math.max(amount(this.remainingTotalAmount) - lineItemTotal, 0)]);
45
- assert(!!allocationAmount, "Allocation amount is zero");
46
- assert(!!remainingAllocationAmount, "Remaining allocation remainder is zero");
47
- this.remainingAllocationAmount = remainingAllocationAmount;
48
- this.remainingTotalAmount = subtract(this.remainingTotalAmount, lineItemTotalDinero);
49
- return greaterThan(allocationAmount, lineItemTotalDinero) ? lineItemTotalDinero : allocationAmount;
50
- }
51
- }
52
- export { FixedAmountAllocator };
53
- //# sourceMappingURL=fixedAmount.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fixedAmount.mjs","sources":["../../../../src/utils/money/allocators/fixedAmount.ts"],"sourcesContent":["import { allocate, greaterThan, subtract } from \"dinero.js\";\n\nimport type { Currency } from \"../../../types\";\nimport { assert } from \"../../errors\";\nimport { amount, getDinero, getDineroCurrency } from \"../misc\";\nimport type { Cents, Dino, DinoCurrency } from \"../types\";\n\n/**\n * Helper class to distribute a fixed amount (e.g. discount) between multiple items.\n * For example when trying to apply 5$ discount to 3 items, we need to distribute it evenly as possible\n */\nexport class FixedAmountAllocator {\n /**\n * How much we have left to allocate for given allocation from the remaining total\n */\n public remainingAllocationAmount: Dino;\n /**\n * How much we have left to allocate in total\n */\n public remainingTotalAmount: Dino;\n public currency: DinoCurrency;\n\n constructor({\n initialAllocateAmount,\n initialTotalAmount,\n currency,\n }: {\n initialAllocateAmount: Cents;\n initialTotalAmount: Cents;\n currency: Currency;\n }) {\n this.remainingAllocationAmount = getDinero(initialAllocateAmount, currency);\n this.remainingTotalAmount = getDinero(initialTotalAmount, currency);\n this.currency = getDineroCurrency(currency);\n }\n\n /**\n * We always allocate biggest share to first item\n */\n allocate(lineItemTotal: Cents, currency: Currency): Dino {\n assert(\n this.currency.code === currency,\n `Currency mismatch, expected ${currency}, got ${this.currency.code}`,\n );\n const lineItemTotalDinero = getDinero(lineItemTotal, currency);\n /**\n * If total price of line items is zero, it means it's free, thus no discount\n * can be calculated (it's either 0 or infinity, but let's go with 0)\n */\n if (lineItemTotal === 0) {\n return lineItemTotalDinero;\n }\n\n const [allocationAmount, remainingAllocationAmount] = allocate(\n this.remainingAllocationAmount,\n [\n lineItemTotal,\n Math.max(amount(this.remainingTotalAmount) - lineItemTotal, 0),\n ],\n );\n\n assert(!!allocationAmount, \"Allocation amount is zero\");\n assert(\n !!remainingAllocationAmount,\n \"Remaining allocation remainder is zero\",\n );\n\n this.remainingAllocationAmount = remainingAllocationAmount;\n this.remainingTotalAmount = subtract(\n this.remainingTotalAmount,\n lineItemTotalDinero,\n );\n\n /**\n * The discount amount is evenly split but can still be higher than the line item total\n * Need to ceil the price to be not more than the line item total\n */\n return greaterThan(allocationAmount, lineItemTotalDinero)\n ? lineItemTotalDinero\n : allocationAmount;\n }\n}\n"],"names":["FixedAmountAllocator","constructor","initialAllocateAmount","initialTotalAmount","currency","__publicField","remainingAllocationAmount","getDinero","remainingTotalAmount","getDineroCurrency","allocate","lineItemTotal","assert","code","lineItemTotalDinero","allocationAmount","Math","max","amount","subtract","greaterThan"],"mappings":";;;;;;;;;;;;;;;AAWO,MAAMA,oBAAqB,CAAA;EAWhCC,WAAYA,CAAA;IACVC,qBAAA;IACAC,kBAAA;IACAC;EAAA,CAKC,EAAA;IAfH;AAAA;AAAA;IAAOC,aAAA,CAAA,IAAA,EAAA,2BAAA,CAAA;IAIP;AAAA;AAAA;IAAOA,aAAA,CAAA,IAAA,EAAA,sBAAA,CAAA;IACAA,aAAA,CAAA,IAAA,EAAA,UAAA,CAAA;IAWA,IAAA,CAAAC,yBAAA,GAA4BC,SAAU,CAAAL,qBAAA,EAAuBE,QAAQ,CAAA;IACrE,IAAA,CAAAI,oBAAA,GAAuBD,SAAU,CAAAJ,kBAAA,EAAoBC,QAAQ,CAAA;IAC7D,IAAA,CAAAA,QAAA,GAAWK,kBAAkBL,QAAQ,CAAA;EAC5C;EAAA;AAAA;AAAA;EAKAM,QAAAA,CAASC,eAAsBP,QAA0B,EAAA;IACvDQ,MAAA,CACE,IAAA,CAAKR,SAASS,IAAS,KAAAT,QAAA,EACQ,+BAAAA,QAAiB,SAAA,IAAA,CAAKA,SAASS,IAAI,EAAA,CACpE;IACM,MAAAC,mBAAA,GAAsBP,SAAU,CAAAI,aAAA,EAAeP,QAAQ,CAAA;IAK7D,IAAIO,kBAAkB,CAAG,EAAA;MAChB,OAAAG,mBAAA;IACT;IAEM,MAAA,CAACC,gBAAkB,EAAAT,yBAAyB,CAAI,GAAAI,QAAA,CACpD,IAAK,CAAAJ,yBAAA,EACL,CACEK,aAAA,EACAK,KAAKC,GAAI,CAAAC,MAAA,CAAO,KAAKV,oBAAoB,CAAA,GAAIG,eAAe,CAAC,CAAA,CAC/D,CACF;IAEOC,MAAA,CAAA,CAAC,CAACG,gBAAA,EAAkB,2BAA2B,CAAA;IACtDH,MAAA,CACE,CAAC,CAACN,yBAAA,EACF,wCAAA,CACF;IAEA,IAAA,CAAKA,yBAA4B,GAAAA,yBAAA;IACjC,IAAA,CAAKE,oBAAuB,GAAAW,QAAA,CAC1B,IAAK,CAAAX,oBAAA,EACLM,mBAAA,CACF;IAMA,OAAOM,WAAY,CAAAL,gBAAA,EAAkBD,mBAAmB,CAAA,GACpDA,mBACA,GAAAC,gBAAA;EACN;AACF;"}
@@ -1,2 +0,0 @@
1
- export * from "./fixedAmount";
2
- export * from "./productAmount";
@@ -1,8 +0,0 @@
1
- 'use strict';
2
-
3
- var fixedAmount = require('./fixedAmount.js');
4
- var productAmount = require('./productAmount.js');
5
- "use strict";
6
- exports.FixedAmountAllocator = fixedAmount.FixedAmountAllocator;
7
- exports.ProductAmountAllocator = productAmount.ProductAmountAllocator;
8
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
@@ -1,4 +0,0 @@
1
- export { FixedAmountAllocator } from './fixedAmount.mjs';
2
- export { ProductAmountAllocator } from './productAmount.mjs';
3
- "use strict";
4
- //# sourceMappingURL=index.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
@@ -1,13 +0,0 @@
1
- import type { FullLineItemSummary } from "../types";
2
- /**
3
- * Helper class to distribute a total amount for a product
4
- */
5
- export declare class ProductAmountAllocator {
6
- #private;
7
- /**
8
- * Remaining quantity to allocate
9
- */
10
- quantity: number;
11
- constructor(productSummary: FullLineItemSummary);
12
- allocateQty(quantity: number): FullLineItemSummary;
13
- }