aloha-vue 2.74.0 → 2.75.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 (167) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/LICENSE +22 -21
  3. package/dist/aloha-vue.css +105 -105
  4. package/dist/aloha-vue.css.map +1 -1
  5. package/dist/aloha-vue.es.js +59267 -64918
  6. package/dist/aloha-vue.umd.js +338 -211
  7. package/package.json +27 -34
  8. package/scss/components/ATable.scss +2 -2
  9. package/scss/utils/button.scss +362 -362
  10. package/scss/utils/funktions.scss +162 -162
  11. package/src/AAccordion/AAccordionItem/AAccordionItem.js +235 -230
  12. package/src/ACarousel/ACarousel.js +7 -2
  13. package/src/ADropdown/ADropdown.js +4 -1
  14. package/src/AFilters/AFilterCenter/AFilterCenter.js +5 -1
  15. package/src/AFilters/AFilterCenter/AFilterCenterItem/AFilterCenterItem.js +7 -2
  16. package/src/AFilters/AFiltersHorizontal/AFiltersHorizontal.js +412 -396
  17. package/src/AFilters/AFiltersHorizontal/AFiltersHorizontalFilter/AFiltersHorizontalFilter.js +102 -99
  18. package/src/AFilters/AFiltersHorizontal/compositionAPI/FiltersSavedDeleteAPI.js +108 -108
  19. package/src/AFilters/AFiltersMain/AFiltersMain.js +114 -111
  20. package/src/AFilters/AFiltersSaveModal/compositionAPI/SaveAPI.js +65 -65
  21. package/src/ALinkCopy/ALinkCopy.js +98 -95
  22. package/src/ALinkCopy/compositionAPI/CopyAPI.js +48 -48
  23. package/src/AList/__tests__/AList.test.js +33 -33
  24. package/src/AList/compositionAPI/__tests__/TagAPI.test.js +43 -43
  25. package/src/AMenu/AMenu.js +4 -1
  26. package/src/AMenu/AMenuBreadcrumbs/AMenuBreadcrumbs.js +240 -237
  27. package/src/AMenu/AMenuPanelLink/AMenuPanelLink.js +4 -1
  28. package/src/AMenu/AMenuSearchPanelBreadcrumbs/AMenuSearchPanelBreadcrumbs.js +122 -119
  29. package/src/AModalWizard/AModalWizard.js +58 -53
  30. package/src/AModalWizard/compositionAPI/__tests__/ScrollAPI.test.js +46 -46
  31. package/src/APagination/APaginationPages/APaginationPages.js +15 -4
  32. package/src/ARate/ARate.js +254 -249
  33. package/src/ARate/ARateIcon/ADecimalIcon/ADecimalIcon.js +53 -50
  34. package/src/ARate/ARateIcon/ARateIcon.js +109 -104
  35. package/src/AResizer/AResizer.js +167 -162
  36. package/src/ATable/ATableHeaderTh/compositionAPI/SortAPI.js +172 -167
  37. package/src/ATable/ATableHeaderThAction/ATableHeaderThAction.js +14 -4
  38. package/src/ATable/ATableHeaderThAction/ATableHeaderThActionItem/ATableHeaderThActionItem.js +191 -184
  39. package/src/ATable/ATablePreviewDown/ATablePreviewDown.js +72 -69
  40. package/src/ATable/ATablePreviewRight/ATablePreviewRight.js +265 -258
  41. package/src/ATable/ATableSortingAdditional/ATableSortingAdditional.js +224 -219
  42. package/src/ATable/ATableSortingAdditional/__tests__/ATableSortingAdditional.AttributesAPI.test.js +39 -39
  43. package/src/ATable/ATableSortingAdditional/__tests__/ATableSortingAdditional.ColumnsAPI.test.js +68 -68
  44. package/src/ATable/ATableSortingAdditional/__tests__/ATableSortingAdditional.DropdownAPI.test.js +45 -45
  45. package/src/ATable/ATableSortingAdditional/__tests__/ATableSortingAdditional.FormAPI.test.js +95 -95
  46. package/src/ATable/ATableSortingAdditional/__tests__/ATableSortingAdditional.ModelAPI.test.js +1 -1
  47. package/src/ATable/ATableTd/ATableTd.js +4 -1
  48. package/src/ATable/ATableTdAction/ATableTdAction.js +19 -12
  49. package/src/ATable/ATableTopPanel/ATableTopPanel.js +11 -3
  50. package/src/ATable/ATableTr/ATableTr.js +408 -405
  51. package/src/ATable/__tests__/ATable.HeaderSlot.test.js +102 -97
  52. package/src/ATable/__tests__/ATable.RowIdsAPI.test.js +66 -66
  53. package/src/ATableForm/ATableForm.js +88 -85
  54. package/src/ATableForm/ATableFormCellAction/ATableFormCellAction.js +14 -4
  55. package/src/ATableForm/ATableFormCellDnd/ATableFormCellDnd.js +196 -187
  56. package/src/ATableForm/ATableFormRow/compositionAPI/EditAPI.js +104 -104
  57. package/src/ATableForm/__tests__/ATableForm.DragAndDropAPI.test.js +200 -212
  58. package/src/ATableForm/__tests__/ATableForm.ListView.test.js +134 -174
  59. package/src/ATableForm/compositionAPI/IconsAPI.js +24 -21
  60. package/src/AVerticalScroll/AVerticalScroll.js +182 -177
  61. package/src/AWizard/AWizard.js +26 -21
  62. package/src/AWizard/AWizardStep/AWizardStep.js +275 -270
  63. package/src/AWizard/compositionAPI/__tests__/ChangeStepAPI.test.js +32 -32
  64. package/src/AWizard/compositionAPI/__tests__/LocalAPI.test.js +55 -55
  65. package/src/PuxDatepicker/PuxDatepickerCalendarPanel/PuxDatepickerCalendarPanel.js +646 -648
  66. package/src/PuxDatepicker/panel/PanelDate/PanelDate.js +300 -301
  67. package/src/PuxDatepicker/panel/PanelMonth/PanelMonth.js +148 -149
  68. package/src/PuxDatepicker/panel/PanelTime/PanelTime.js +256 -257
  69. package/src/PuxDatepicker/panel/PanelYear/PanelYear.js +136 -137
  70. package/src/PuxDatepicker/utils/index.js +100 -100
  71. package/src/compositionAPI/AHttpAPI.js +593 -593
  72. package/src/compositionAPI/__tests__/AHttpAPI.test.js +42 -42
  73. package/src/filters/__tests__/filterBoolean.test.js +38 -38
  74. package/src/filters/__tests__/filterCapitalize.test.js +38 -38
  75. package/src/filters/__tests__/filterCurrency.test.js +21 -21
  76. package/src/filters/__tests__/filterDate.test.js +42 -42
  77. package/src/filters/__tests__/filterDefaultForEmpty.test.js +24 -24
  78. package/src/filters/__tests__/filterEmail.test.js +42 -42
  79. package/src/filters/__tests__/filterEscapeHtml.test.js +45 -45
  80. package/src/filters/__tests__/filterFileSize.test.js +45 -45
  81. package/src/filters/__tests__/filterFloat.test.js +74 -74
  82. package/src/filters/__tests__/filterJson.test.js +74 -74
  83. package/src/filters/__tests__/filterKeyValue.test.js +50 -50
  84. package/src/filters/__tests__/filterLimitTo.test.js +39 -39
  85. package/src/filters/__tests__/filterLink.test.js +41 -41
  86. package/src/filters/__tests__/filterList.test.js +149 -149
  87. package/src/filters/__tests__/filterLowerCase.test.js +38 -38
  88. package/src/filters/__tests__/filterMask.test.js +80 -80
  89. package/src/filters/__tests__/filterPropertyByValue.test.js +27 -27
  90. package/src/filters/__tests__/filterSearchHighlight.test.js +129 -129
  91. package/src/filters/__tests__/filterUpperCase.test.js +38 -38
  92. package/src/filters/__tests__/filterValueByCondition.test.js +3 -3
  93. package/src/filters/filterJson.js +39 -39
  94. package/src/filters/filterValueByCondition.js +2 -2
  95. package/src/plugins/AAlertPlugin.js +16 -5
  96. package/src/plugins/AMultiselectOrderedPlugin.js +88 -81
  97. package/src/plugins/ASelectPlugin.js +12 -10
  98. package/src/ui/ACheckbox/ACheckbox.js +82 -79
  99. package/src/ui/ADatepicker/ADatepicker.js +6 -5
  100. package/src/ui/ADatepicker/compositionAPI/EventsAPI.js +297 -297
  101. package/src/ui/ADatepicker/utils/index.js +76 -76
  102. package/src/ui/ADatepickerAlt/ADatepicker.js +912 -912
  103. package/src/ui/ADatepickerAlt/utils/index.js +98 -98
  104. package/src/ui/AFieldset/__tests__/AFieldset.ClassColumn.test.js +113 -114
  105. package/src/ui/AFormElementBtnClear/AFormElementBtnClear.js +4 -1
  106. package/src/ui/AInputCurrency/AInputCurrency.js +20 -15
  107. package/src/ui/AInputCurrency/__tests__/AInputCurrency.ModelAPI.test.js +73 -73
  108. package/src/ui/AInputNumber/AInputNumber.js +17 -12
  109. package/src/ui/AJson/AJson.js +12 -3
  110. package/src/ui/AJson/compositionAPI/JsonAPI.js +116 -116
  111. package/src/ui/ALabel/__tests__/ALabel.IdAPI.test.js +42 -42
  112. package/src/ui/ALabel/__tests__/ALabel.LabelAPI.test.js +33 -33
  113. package/src/ui/ARadio/ARadio.js +80 -77
  114. package/src/ui/ASelect/ASelect.js +390 -383
  115. package/src/ui/ASelect/ASelectElement/ASelectElement.js +179 -176
  116. package/src/ui/ASelect/ASelectValueCloseable/ASelectValueCloseable.js +143 -141
  117. package/src/ui/ASelect/__tests__/SelectedFirstAPI.test.js +101 -101
  118. package/src/ui/ASelect/__tests__/SelectedVisibleAPI.test.js +98 -98
  119. package/src/ui/ASlider/compositionAPI/SliderAPI.js +23 -23
  120. package/src/ui/AValidatedJson/AValidatedJson.js +4 -1
  121. package/src/ui/AValidatedJson/AValidatedJsonItem/AValidatedJsonItem.js +308 -298
  122. package/src/ui/compositionApi/UiCollapseAPI.js +68 -63
  123. package/src/ui/compositionApi/UiInputAutofillAPI.js +41 -41
  124. package/src/ui/compositionApi/__tests__/UIDataGroupAPI.test.js +106 -106
  125. package/src/ui/compositionApi/__tests__/UIExcludeRenderAttributesAPI.test.js +39 -39
  126. package/src/ui/compositionApi/__tests__/UiDataWithKeyIdAndLabelAPI.test.js +128 -128
  127. package/src/ui/compositionApi/__tests__/UiSearchAPI.test.js +71 -71
  128. package/src/utils/EventBus.js +51 -8
  129. package/src/utils/__tests__/EventBus.test.js +138 -0
  130. package/src/utils/__tests__/utils.aOrderBy.test.js +1 -1
  131. package/src/utils/__tests__/utils.aSortBy.test.js +1 -1
  132. package/src/utils/__tests__/utils.getTotalNestedCount.test.js +56 -56
  133. package/src/utils/__tests__/utils.isArrayOfArrays.test.js +44 -44
  134. package/src/utils/__tests__/utils.isArrayOfStrings.test.js +36 -36
  135. package/src/utils/__tests__/utilsArray.aFirst.test.js +1 -1
  136. package/src/utils/__tests__/utilsArray.aLast.test.js +1 -1
  137. package/src/utils/__tests__/utilsLang.isArguments.test.js +1 -1
  138. package/src/utils/__tests__/utilsLang.isArray.test.js +1 -1
  139. package/src/utils/__tests__/utilsLang.isArrayBuffer.test.js +1 -1
  140. package/src/utils/__tests__/utilsLang.isBoolean.test.js +1 -1
  141. package/src/utils/__tests__/utilsLang.isBuffer.test.js +1 -1
  142. package/src/utils/__tests__/utilsLang.isDate.test.js +1 -1
  143. package/src/utils/__tests__/utilsLang.isElement.test.js +5 -3
  144. package/src/utils/__tests__/utilsLang.isError.test.js +1 -1
  145. package/src/utils/__tests__/utilsLang.isFinite.test.js +1 -1
  146. package/src/utils/__tests__/utilsLang.isFunction.test.js +1 -1
  147. package/src/utils/__tests__/utilsLang.isInteger.test.js +1 -1
  148. package/src/utils/__tests__/utilsLang.isMap.test.js +1 -1
  149. package/src/utils/__tests__/utilsLang.isNaN.test.js +1 -1
  150. package/src/utils/__tests__/utilsLang.isNil.test.js +1 -1
  151. package/src/utils/__tests__/utilsLang.isNull.test.js +1 -1
  152. package/src/utils/__tests__/utilsLang.isNumber.test.js +1 -1
  153. package/src/utils/__tests__/utilsLang.isObject.test.js +1 -1
  154. package/src/utils/__tests__/utilsLang.isObjectLike.test.js +5 -3
  155. package/src/utils/__tests__/utilsLang.isPlainObject.test.js +3 -2
  156. package/src/utils/__tests__/utilsLang.isPromise.test.js +5 -2
  157. package/src/utils/__tests__/utilsLang.isRegExp.test.js +1 -1
  158. package/src/utils/__tests__/utilsLang.isSet.test.js +1 -1
  159. package/src/utils/__tests__/utilsLang.isString.test.js +1 -1
  160. package/src/utils/__tests__/utilsLang.isSymbol.test.js +5 -3
  161. package/src/utils/__tests__/utilsLang.isUndefined.test.js +1 -1
  162. package/src/utils/__tests__/utilsLang.isWeakMap.test.js +1 -1
  163. package/src/utils/__tests__/utilsLang.isWeakSet.test.js +1 -1
  164. package/src/utils/__tests__/utilsMath.isEven.test.js +43 -43
  165. package/src/utils/__tests__/utilsMath.isOdd.test.js +43 -43
  166. package/src/utils/__tests__/utilsUi.isModelForFilterNotEmpty.test.js +65 -65
  167. package/src/utils/autosize.js +1 -1
@@ -1,163 +1,163 @@
1
- @use "sass:color";
2
- @use "sass:list";
3
- @use "sass:map";
4
- @use "sass:math";
5
- @use "sass:string";
6
-
7
- @function prepend($list, $value) {
8
- $list-new: ($value,);
9
- @each $item in $list {
10
- $list-new: list.append($list-new, $item);
11
- }
12
- @return $list-new;
13
- }
14
-
15
- @function to-rgb($value) {
16
- @return color.channel($value, "red", $space: rgb), color.channel($value, "green", $space: rgb), color.channel($value, "blue", $space: rgb);
17
- }
18
-
19
- @function tint-color($color, $weight) {
20
- @return color.mix(white, $color, $weight);
21
- }
22
-
23
- @function shade-color($color, $weight) {
24
- @return color.mix(black, $color, $weight);
25
- }
26
-
27
- // Shade the color if the weight is positive, else tint it
28
- @function shift-color($color, $weight) {
29
- @return if($weight > 0, shade-color($color, $weight), tint-color($color, -$weight));
30
- }
31
-
32
- // Color contrast
33
- // See https://github.com/twbs/bootstrap/pull/30168
34
-
35
- // A list of pre-calculated numbers of pow(divide((divide($value, 255) + .055), 1.055), 2.4). (from 0 to 255)
36
- // stylelint-disable-next-line scss/dollar-variable-default, scss/dollar-variable-pattern
37
- $_luminance-list: .0008 .001 .0011 .0013 .0015 .0017 .002 .0022 .0025 .0027 .003 .0033 .0037 .004 .0044 .0048 .0052 .0056 .006 .0065 .007 .0075 .008 .0086 .0091 .0097 .0103 .011 .0116 .0123 .013 .0137 .0144 .0152 .016 .0168 .0176 .0185 .0194 .0203 .0212 .0222 .0232 .0242 .0252 .0262 .0273 .0284 .0296 .0307 .0319 .0331 .0343 .0356 .0369 .0382 .0395 .0409 .0423 .0437 .0452 .0467 .0482 .0497 .0513 .0529 .0545 .0561 .0578 .0595 .0612 .063 .0648 .0666 .0685 .0704 .0723 .0742 .0762 .0782 .0802 .0823 .0844 .0865 .0887 .0908 .0931 .0953 .0976 .0999 .1022 .1046 .107 .1095 .1119 .1144 .117 .1195 .1221 .1248 .1274 .1301 .1329 .1356 .1384 .1413 .1441 .147 .15 .1529 .1559 .159 .162 .1651 .1683 .1714 .1746 .1779 .1812 .1845 .1878 .1912 .1946 .1981 .2016 .2051 .2086 .2122 .2159 .2195 .2232 .227 .2307 .2346 .2384 .2423 .2462 .2502 .2542 .2582 .2623 .2664 .2705 .2747 .2789 .2831 .2874 .2918 .2961 .3005 .305 .3095 .314 .3185 .3231 .3278 .3325 .3372 .3419 .3467 .3515 .3564 .3613 .3663 .3712 .3763 .3813 .3864 .3916 .3968 .402 .4072 .4125 .4179 .4233 .4287 .4342 .4397 .4452 .4508 .4564 .4621 .4678 .4735 .4793 .4851 .491 .4969 .5029 .5089 .5149 .521 .5271 .5333 .5395 .5457 .552 .5583 .5647 .5711 .5776 .5841 .5906 .5972 .6038 .6105 .6172 .624 .6308 .6376 .6445 .6514 .6584 .6654 .6724 .6795 .6867 .6939 .7011 .7084 .7157 .7231 .7305 .7379 .7454 .7529 .7605 .7682 .7758 .7835 .7913 .7991 .807 .8148 .8228 .8308 .8388 .8469 .855 .8632 .8714 .8796 .8879 .8963 .9047 .9131 .9216 .9301 .9387 .9473 .956 .9647 .9734 .9823 .9911 1;
38
-
39
- @function color-contrast($background, $a_color_contrast_dark: #000000, $a_color_contrast_light: #ffffff, $a_min_contrast_ratio: 4.5) {
40
- $foregrounds: $a_color_contrast_light, $a_color_contrast_dark, #ffffff, #000000;
41
- $max-ratio: 0;
42
- $max-ratio-color: null;
43
-
44
- @each $color in $foregrounds {
45
- $contrast-ratio: contrast-ratio($background, $color);
46
- @if $contrast-ratio > $a_min_contrast_ratio {
47
- @return $color;
48
- } @else if $contrast-ratio > $max-ratio {
49
- $max-ratio: $contrast-ratio;
50
- $max-ratio-color: $color;
51
- }
52
- }
53
-
54
- @warn "Found no color leading to #{$a_min_contrast_ratio}:1 contrast ratio against #{$background}...";
55
-
56
- @return $max-ratio-color;
57
- }
58
-
59
- @function contrast-ratio($background, $foreground: #ffffff) {
60
- $l1: luminance($background);
61
- $l2: luminance(opaque($background, $foreground));
62
-
63
- @return if($l1 > $l2, divide($l1 + .05, $l2 + .05), divide($l2 + .05, $l1 + .05));
64
- }
65
-
66
- // Return WCAG2.1 relative luminance
67
- // See https://www.w3.org/TR/WCAG/#dfn-relative-luminance
68
- // See https://www.w3.org/TR/WCAG/#dfn-contrast-ratio
69
- @function luminance($color) {
70
- $rgb: (
71
- "r": color.channel($color, "red", $space: rgb),
72
- "g": color.channel($color, "green", $space: rgb),
73
- "b": color.channel($color, "blue", $space: rgb),
74
- );
75
-
76
- @each $name, $value in $rgb {
77
- $value: if(divide($value, 255) < .03928, divide(divide($value, 255), 12.92), list.nth($_luminance-list, round($value + 1)));
78
- $rgb: map.merge($rgb, ($name: $value));
79
- }
80
-
81
- @return (map.get($rgb, "r") * .2126) + (map.get($rgb, "g") * .7152) + (map.get($rgb, "b") * .0722);
82
- }
83
-
84
- // Return opaque color
85
- // opaque(#fff, rgba(0, 0, 0, .5)) => #808080
86
- @function opaque($background, $foreground) {
87
- @return color.mix(rgba($foreground, 1), $background, color.opacity($foreground) * 100%);
88
- }
89
-
90
- @function divide($dividend, $divisor, $precision: 10) {
91
- $sign: if($dividend > 0 and $divisor > 0 or $dividend < 0 and $divisor < 0, 1, -1);
92
- $dividend: abs($dividend);
93
- $divisor: abs($divisor);
94
- @if $dividend == 0 {
95
- @return 0;
96
- }
97
- @if $divisor == 0 {
98
- @error "Cannot divide by 0";
99
- }
100
- $remainder: $dividend;
101
- $result: 0;
102
- $factor: 10;
103
- @while ($remainder > 0 and $precision >= 0) {
104
- $quotient: 0;
105
- @while ($remainder >= $divisor) {
106
- $remainder: $remainder - $divisor;
107
- $quotient: $quotient + 1;
108
- }
109
- $result: $result * 10 + $quotient;
110
- $factor: $factor * .1;
111
- $remainder: $remainder * 10;
112
- $precision: $precision - 1;
113
- @if ($precision < 0 and $remainder >= $divisor * 5) {
114
- $result: $result + 1;
115
- }
116
- }
117
- $result: $result * $factor * $sign;
118
- $dividend-unit: math.unit($dividend);
119
- $divisor-unit: math.unit($divisor);
120
- $unit-map: (
121
- "px": 1px,
122
- "rem": 1rem,
123
- "em": 1em,
124
- "%": 1%
125
- );
126
- @if ($dividend-unit != $divisor-unit and map-has-key($unit-map, $dividend-unit)) {
127
- $result: $result * map.get($unit-map, $dividend-unit);
128
- }
129
- @return $result;
130
- }
131
-
132
- $escaped-characters: (
133
- ("<", "%3c"),
134
- (">", "%3e"),
135
- ("#", "%23"),
136
- ("(", "%28"),
137
- (")", "%29"),
138
- ) !default;
139
-
140
- @function escape-svg($string) {
141
- @if string.index($string, "data:image/svg+xml") {
142
- @each $char, $encoded in $escaped-characters {
143
- // Do not escape the url brackets
144
- @if string.index($string, "url(") == 1 {
145
- $string: url("#{str-replace(string.slice($string, 6, -3), $char, $encoded)}");
146
- } @else {
147
- $string: str-replace($string, $char, $encoded);
148
- }
149
- }
150
- }
151
-
152
- @return $string;
153
- }
154
-
155
- @function str-replace($string, $search, $replace: "") {
156
- $index: string.index($string, $search);
157
-
158
- @if $index {
159
- @return string.slice($string, 1, $index - 1) + $replace + str-replace(string.slice($string, $index + string.length($search)), $search, $replace);
160
- }
161
-
162
- @return $string;
1
+ @use "sass:color";
2
+ @use "sass:list";
3
+ @use "sass:map";
4
+ @use "sass:math";
5
+ @use "sass:string";
6
+
7
+ @function prepend($list, $value) {
8
+ $list-new: ($value,);
9
+ @each $item in $list {
10
+ $list-new: list.append($list-new, $item);
11
+ }
12
+ @return $list-new;
13
+ }
14
+
15
+ @function to-rgb($value) {
16
+ @return color.channel($value, "red", $space: rgb), color.channel($value, "green", $space: rgb), color.channel($value, "blue", $space: rgb);
17
+ }
18
+
19
+ @function tint-color($color, $weight) {
20
+ @return color.mix(white, $color, $weight);
21
+ }
22
+
23
+ @function shade-color($color, $weight) {
24
+ @return color.mix(black, $color, $weight);
25
+ }
26
+
27
+ // Shade the color if the weight is positive, else tint it
28
+ @function shift-color($color, $weight) {
29
+ @return if(sass($weight > 0): shade-color($color, $weight); else: tint-color($color, -$weight));
30
+ }
31
+
32
+ // Color contrast
33
+ // See https://github.com/twbs/bootstrap/pull/30168
34
+
35
+ // A list of pre-calculated numbers of pow(divide((divide($value, 255) + .055), 1.055), 2.4). (from 0 to 255)
36
+ // stylelint-disable-next-line scss/dollar-variable-default, scss/dollar-variable-pattern
37
+ $_luminance-list: .0008 .001 .0011 .0013 .0015 .0017 .002 .0022 .0025 .0027 .003 .0033 .0037 .004 .0044 .0048 .0052 .0056 .006 .0065 .007 .0075 .008 .0086 .0091 .0097 .0103 .011 .0116 .0123 .013 .0137 .0144 .0152 .016 .0168 .0176 .0185 .0194 .0203 .0212 .0222 .0232 .0242 .0252 .0262 .0273 .0284 .0296 .0307 .0319 .0331 .0343 .0356 .0369 .0382 .0395 .0409 .0423 .0437 .0452 .0467 .0482 .0497 .0513 .0529 .0545 .0561 .0578 .0595 .0612 .063 .0648 .0666 .0685 .0704 .0723 .0742 .0762 .0782 .0802 .0823 .0844 .0865 .0887 .0908 .0931 .0953 .0976 .0999 .1022 .1046 .107 .1095 .1119 .1144 .117 .1195 .1221 .1248 .1274 .1301 .1329 .1356 .1384 .1413 .1441 .147 .15 .1529 .1559 .159 .162 .1651 .1683 .1714 .1746 .1779 .1812 .1845 .1878 .1912 .1946 .1981 .2016 .2051 .2086 .2122 .2159 .2195 .2232 .227 .2307 .2346 .2384 .2423 .2462 .2502 .2542 .2582 .2623 .2664 .2705 .2747 .2789 .2831 .2874 .2918 .2961 .3005 .305 .3095 .314 .3185 .3231 .3278 .3325 .3372 .3419 .3467 .3515 .3564 .3613 .3663 .3712 .3763 .3813 .3864 .3916 .3968 .402 .4072 .4125 .4179 .4233 .4287 .4342 .4397 .4452 .4508 .4564 .4621 .4678 .4735 .4793 .4851 .491 .4969 .5029 .5089 .5149 .521 .5271 .5333 .5395 .5457 .552 .5583 .5647 .5711 .5776 .5841 .5906 .5972 .6038 .6105 .6172 .624 .6308 .6376 .6445 .6514 .6584 .6654 .6724 .6795 .6867 .6939 .7011 .7084 .7157 .7231 .7305 .7379 .7454 .7529 .7605 .7682 .7758 .7835 .7913 .7991 .807 .8148 .8228 .8308 .8388 .8469 .855 .8632 .8714 .8796 .8879 .8963 .9047 .9131 .9216 .9301 .9387 .9473 .956 .9647 .9734 .9823 .9911 1;
38
+
39
+ @function color-contrast($background, $a_color_contrast_dark: #000000, $a_color_contrast_light: #ffffff, $a_min_contrast_ratio: 4.5) {
40
+ $foregrounds: $a_color_contrast_light, $a_color_contrast_dark, #ffffff, #000000;
41
+ $max-ratio: 0;
42
+ $max-ratio-color: null;
43
+
44
+ @each $color in $foregrounds {
45
+ $contrast-ratio: contrast-ratio($background, $color);
46
+ @if $contrast-ratio > $a_min_contrast_ratio {
47
+ @return $color;
48
+ } @else if $contrast-ratio > $max-ratio {
49
+ $max-ratio: $contrast-ratio;
50
+ $max-ratio-color: $color;
51
+ }
52
+ }
53
+
54
+ @warn "Found no color leading to #{$a_min_contrast_ratio}:1 contrast ratio against #{$background}...";
55
+
56
+ @return $max-ratio-color;
57
+ }
58
+
59
+ @function contrast-ratio($background, $foreground: #ffffff) {
60
+ $l1: luminance($background);
61
+ $l2: luminance(opaque($background, $foreground));
62
+
63
+ @return if(sass($l1 > $l2): divide($l1 + .05, $l2 + .05); else: divide($l2 + .05, $l1 + .05));
64
+ }
65
+
66
+ // Return WCAG2.1 relative luminance
67
+ // See https://www.w3.org/TR/WCAG/#dfn-relative-luminance
68
+ // See https://www.w3.org/TR/WCAG/#dfn-contrast-ratio
69
+ @function luminance($color) {
70
+ $rgb: (
71
+ "r": color.channel($color, "red", $space: rgb),
72
+ "g": color.channel($color, "green", $space: rgb),
73
+ "b": color.channel($color, "blue", $space: rgb),
74
+ );
75
+
76
+ @each $name, $value in $rgb {
77
+ $value: if(sass(divide($value, 255) < .03928): divide(divide($value, 255), 12.92); else: list.nth($_luminance-list, round($value + 1)));
78
+ $rgb: map.merge($rgb, ($name: $value));
79
+ }
80
+
81
+ @return (map.get($rgb, "r") * .2126) + (map.get($rgb, "g") * .7152) + (map.get($rgb, "b") * .0722);
82
+ }
83
+
84
+ // Return opaque color
85
+ // opaque(#fff, rgba(0, 0, 0, .5)) => #808080
86
+ @function opaque($background, $foreground) {
87
+ @return color.mix(rgba($foreground, 1), $background, color.opacity($foreground) * 100%);
88
+ }
89
+
90
+ @function divide($dividend, $divisor, $precision: 10) {
91
+ $sign: if(sass($dividend > 0 and $divisor > 0 or $dividend < 0 and $divisor < 0): 1; else: -1);
92
+ $dividend: abs($dividend);
93
+ $divisor: abs($divisor);
94
+ @if $dividend == 0 {
95
+ @return 0;
96
+ }
97
+ @if $divisor == 0 {
98
+ @error "Cannot divide by 0";
99
+ }
100
+ $remainder: $dividend;
101
+ $result: 0;
102
+ $factor: 10;
103
+ @while ($remainder > 0 and $precision >= 0) {
104
+ $quotient: 0;
105
+ @while ($remainder >= $divisor) {
106
+ $remainder: $remainder - $divisor;
107
+ $quotient: $quotient + 1;
108
+ }
109
+ $result: $result * 10 + $quotient;
110
+ $factor: $factor * .1;
111
+ $remainder: $remainder * 10;
112
+ $precision: $precision - 1;
113
+ @if ($precision < 0 and $remainder >= $divisor * 5) {
114
+ $result: $result + 1;
115
+ }
116
+ }
117
+ $result: $result * $factor * $sign;
118
+ $dividend-unit: math.unit($dividend);
119
+ $divisor-unit: math.unit($divisor);
120
+ $unit-map: (
121
+ "px": 1px,
122
+ "rem": 1rem,
123
+ "em": 1em,
124
+ "%": 1%
125
+ );
126
+ @if ($dividend-unit != $divisor-unit and map-has-key($unit-map, $dividend-unit)) {
127
+ $result: $result * map.get($unit-map, $dividend-unit);
128
+ }
129
+ @return $result;
130
+ }
131
+
132
+ $escaped-characters: (
133
+ ("<", "%3c"),
134
+ (">", "%3e"),
135
+ ("#", "%23"),
136
+ ("(", "%28"),
137
+ (")", "%29"),
138
+ ) !default;
139
+
140
+ @function escape-svg($string) {
141
+ @if string.index($string, "data:image/svg+xml") {
142
+ @each $char, $encoded in $escaped-characters {
143
+ // Do not escape the url brackets
144
+ @if string.index($string, "url(") == 1 {
145
+ $string: url("#{str-replace(string.slice($string, 6, -3), $char, $encoded)}");
146
+ } @else {
147
+ $string: str-replace($string, $char, $encoded);
148
+ }
149
+ }
150
+ }
151
+
152
+ @return $string;
153
+ }
154
+
155
+ @function str-replace($string, $search, $replace: "") {
156
+ $index: string.index($string, $search);
157
+
158
+ @if $index {
159
+ @return string.slice($string, 1, $index - 1) + $replace + str-replace(string.slice($string, $index + string.length($search)), $search, $replace);
160
+ }
161
+
162
+ @return $string;
163
163
  }