oo-loop 1.0.3 → 1.1.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.
- package/dist/loop.css +1 -1
- package/package.json +5 -6
- package/scss/_fn.scss +13 -0
- package/scss/_init.scss +6 -4
- package/scss/_loop.scss +1 -1
- package/scss/_pre.scss +3 -1
- package/scss/base/_type.scss +6 -4
- package/scss/components/_button.scss +16 -13
- package/scss/components/_column.scss +39 -34
- package/scss/components/_template.scss +48 -42
- package/scss/components/form/_checkbox.scss +8 -5
- package/scss/components/form/_input.scss +4 -2
- package/scss/components/form/_radio.scss +9 -6
- package/scss/components/form/_select.scss +43 -40
- package/scss/components/form/_toggle.scss +7 -4
- package/scss/functions/_color.scss +30 -16
- package/scss/functions/_convert.scss +24 -9
- package/scss/functions/_empty.scss +8 -3
- package/scss/functions/_extract.scss +9 -5
- package/scss/functions/_list.scss +9 -6
- package/scss/functions/_map.scss +15 -44
- package/scss/functions/_number.scss +16 -11
- package/scss/functions/_replace.scss +7 -4
- package/scss/functions/_split.scss +12 -8
- package/scss/functions/_strip.scss +3 -1
- package/scss/functions/_type.scss +7 -5
- package/scss/helpers/_container.scss +4 -2
- package/scss/helpers/_miscellaneous.scss +4 -2
- package/scss/helpers/_visibility.scss +7 -5
- package/scss/mixins/_breakpoint.scss +15 -10
- package/scss/mixins/_component.scss +19 -18
- package/scss/mixins/_loop.scss +13 -13
- package/scss/mixins/_props.scss +17 -14
- package/scss/mixins/_utilities.scss +21 -18
- package/scss/oo/_all.scss +11 -0
- package/scss/oo/_oo.scss +42 -0
- package/scss/{functions → oo}/_ooAdd.scss +9 -6
- package/scss/oo/_ooAlias.scss +146 -0
- package/scss/oo/_ooMerge.scss +41 -0
- package/scss/{functions → oo}/_ooParse.scss +20 -16
- package/scss/{functions → oo}/_ooPipe.scss +5 -3
- package/scss/{functions → oo}/_ooRef.scss +31 -25
- package/scss/{functions → oo}/_ooSet.scss +18 -13
- package/scss/utilities/_color.scss +3 -1
- package/scss/utilities/_float.scss +5 -2
- package/scss/utilities/_spacing.scss +3 -1
- package/scss/utilities/_typography.scss +3 -1
- package/scss/utilities/_wrapper.scss +3 -1
- package/CHANGELOG.md +0 -236
- package/scss/functions/_all.scss +0 -21
- package/scss/functions/_oo.scss +0 -38
- package/scss/functions/_ooAlias.scss +0 -126
- /package/scss/{functions → oo}/_ooUse.scss +0 -0
package/scss/mixins/_props.scss
CHANGED
|
@@ -1,21 +1,24 @@
|
|
|
1
|
+
@use 'sass:map';
|
|
2
|
+
@use 'sass:string';
|
|
3
|
+
@use '../fn';
|
|
1
4
|
|
|
2
5
|
/// Generate Properties
|
|
3
6
|
/// @param $propertiesMap
|
|
4
7
|
|
|
5
8
|
@mixin generateProperties($propertiesMap) {
|
|
6
|
-
@if isMap($propertiesMap) {
|
|
9
|
+
@if fn.isMap($propertiesMap) {
|
|
7
10
|
@each $propertyName, $propertyValue in $propertiesMap {
|
|
8
|
-
$propertyName: toKebabCase($propertyName);
|
|
11
|
+
$propertyName: fn.toKebabCase($propertyName);
|
|
9
12
|
|
|
10
|
-
@if isString($propertyName) and
|
|
13
|
+
@if fn.isString($propertyName) and string.slice($propertyName,1,1) == ':' {
|
|
11
14
|
&#{$propertyName} {
|
|
12
15
|
@include generateProperties($propertyValue);
|
|
13
16
|
}
|
|
14
|
-
} @else if isMap($propertyValue) and areKeysBreakpoints($propertyValue) {
|
|
17
|
+
} @else if fn.isMap($propertyValue) and areKeysBreakpoints($propertyValue) {
|
|
15
18
|
@include generatePropertyBreakpoints($propertyName, $propertyValue);
|
|
16
|
-
} @else if isMap($propertyValue) and $propertyName == '>' {
|
|
19
|
+
} @else if fn.isMap($propertyValue) and $propertyName == '>' {
|
|
17
20
|
@each $childSelector, $childProps in $propertyValue {
|
|
18
|
-
$childSelector: toKebabCase($childSelector);
|
|
21
|
+
$childSelector: fn.toKebabCase($childSelector);
|
|
19
22
|
#{$childSelector} {
|
|
20
23
|
@include generateProperties($childProps);
|
|
21
24
|
}
|
|
@@ -35,11 +38,11 @@
|
|
|
35
38
|
}
|
|
36
39
|
}
|
|
37
40
|
@mixin breakpointProperty($propertiesMap) {
|
|
38
|
-
@if isNotMap($propertiesMap) {
|
|
41
|
+
@if fn.isNotMap($propertiesMap) {
|
|
39
42
|
@error 'Pass a property Map with `breakpointProperty()`';
|
|
40
43
|
}
|
|
41
44
|
@each $propertyName, $propertyValue in $propertiesMap {
|
|
42
|
-
$propertyName: toKebabCase($propertyName);
|
|
45
|
+
$propertyName: fn.toKebabCase($propertyName);
|
|
43
46
|
@if not areKeysBreakpoints($propertyValue) {
|
|
44
47
|
@error 'Use a breakpoint map as a property value with `breakpointProperty()`';
|
|
45
48
|
}
|
|
@@ -48,7 +51,7 @@
|
|
|
48
51
|
}
|
|
49
52
|
|
|
50
53
|
@mixin generateStatesProperties($statesPropertiesMap) {
|
|
51
|
-
@if isMap($statesPropertiesMap) {
|
|
54
|
+
@if fn.isMap($statesPropertiesMap) {
|
|
52
55
|
@each $state, $props in $statesPropertiesMap {
|
|
53
56
|
&:#{$state} {
|
|
54
57
|
@include generateProperties($props);
|
|
@@ -58,12 +61,12 @@
|
|
|
58
61
|
}
|
|
59
62
|
|
|
60
63
|
@mixin generateStyles($element) {
|
|
61
|
-
@if isMap($element) {
|
|
62
|
-
@if map
|
|
63
|
-
@include generateProperties(map
|
|
64
|
+
@if fn.isMap($element) {
|
|
65
|
+
@if map.has-key($element, 'props') {
|
|
66
|
+
@include generateProperties(map.get($element, 'props'));
|
|
64
67
|
}
|
|
65
|
-
@if map
|
|
66
|
-
@include generateStatesProperties(map
|
|
68
|
+
@if map.has-key($element, 'states') {
|
|
69
|
+
@include generateStatesProperties(map.get($element, 'states'));
|
|
67
70
|
}
|
|
68
71
|
}
|
|
69
72
|
}
|
|
@@ -1,23 +1,26 @@
|
|
|
1
|
-
@
|
|
1
|
+
@use 'sass:list';
|
|
2
|
+
@use 'sass:map';
|
|
3
|
+
@use 'sass:string';
|
|
4
|
+
@use '../fn';
|
|
2
5
|
|
|
3
6
|
/// Generate Utilities
|
|
4
7
|
/// @param $utilitiesMap
|
|
5
8
|
|
|
6
9
|
@mixin generateUtilities($utilitiesMap) {
|
|
7
|
-
@if map
|
|
8
|
-
and map
|
|
9
|
-
$utilitiesMap: (map
|
|
10
|
+
@if map.has-key($utilitiesMap, 'values')
|
|
11
|
+
and map.has-key($utilitiesMap, 'name') {
|
|
12
|
+
$utilitiesMap: (map.get($utilitiesMap, 'name'): $utilitiesMap);
|
|
10
13
|
}
|
|
11
14
|
|
|
12
15
|
@each $name, $options in $utilitiesMap {
|
|
13
|
-
@if isMap($options) {
|
|
14
|
-
$props: if(map
|
|
15
|
-
$propertyName: if(map
|
|
16
|
-
$prefix: if(map
|
|
17
|
-
$isImportant: if(map
|
|
18
|
-
$screens: if(map
|
|
16
|
+
@if fn.isMap($options) {
|
|
17
|
+
$props: if(map.has-key($options, 'values'), oo('values', $options), ());
|
|
18
|
+
$propertyName: if(map.has-key($options, 'property'), oo('property', $options), fn.toKebabCase($name));
|
|
19
|
+
$prefix: if(map.has-key($options, 'prefix'), oo('prefix', $options), list.nth(fn.splitDeep('-', fn.toKebabCase($name)), 1));
|
|
20
|
+
$isImportant: if(map.has-key($options, 'important'), oo('important', $options), true);
|
|
21
|
+
$screens: if(map.has-key($options, 'screens'), oo('screens', $options), ());
|
|
19
22
|
|
|
20
|
-
@if not (
|
|
23
|
+
@if not (string.slice(prefix, 1, 1) == '.') {
|
|
21
24
|
$prefix: '.' + $prefix;
|
|
22
25
|
}
|
|
23
26
|
|
|
@@ -28,7 +31,7 @@
|
|
|
28
31
|
$isImportant
|
|
29
32
|
);
|
|
30
33
|
|
|
31
|
-
@if isMap($screens) {
|
|
34
|
+
@if fn.isMap($screens) {
|
|
32
35
|
@each $class, $propsName in $screens {
|
|
33
36
|
@if $propsName == '*' {
|
|
34
37
|
@include loopBreakpoints(
|
|
@@ -38,19 +41,19 @@
|
|
|
38
41
|
$prefix,
|
|
39
42
|
$isImportant
|
|
40
43
|
)
|
|
41
|
-
} @else if isNotEmpty($propsName) {
|
|
42
|
-
$propsName: toList($propsName);
|
|
44
|
+
} @else if fn.isNotEmpty($propsName) {
|
|
45
|
+
$propsName: fn.toList($propsName);
|
|
43
46
|
$propsTarget: ();
|
|
44
47
|
@each $name in $propsName {
|
|
45
48
|
$prop-value: '';
|
|
46
|
-
@if isList($props) {
|
|
47
|
-
$index: index($props, $name);
|
|
48
|
-
$prop-value: nth($props, $index);
|
|
49
|
+
@if fn.isList($props) {
|
|
50
|
+
$index: list.index($props, $name);
|
|
51
|
+
$prop-value: list.nth($props, $index);
|
|
49
52
|
} @else {
|
|
50
53
|
$prop-value: oo(#{$name}, $props);
|
|
51
54
|
}
|
|
52
55
|
@if $prop-value {
|
|
53
|
-
$propsTarget: map
|
|
56
|
+
$propsTarget: map.merge($propsTarget, (#{$name}: $prop-value));
|
|
54
57
|
}
|
|
55
58
|
}
|
|
56
59
|
@include loopBreakpoints(
|
package/scss/oo/_oo.scss
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
@use 'sass:list';
|
|
2
|
+
@use 'sass:string';
|
|
3
|
+
@use '../fn';
|
|
4
|
+
|
|
5
|
+
/// oo
|
|
6
|
+
/// Get value from a map with the ooFormat (default $ooLoop)
|
|
7
|
+
/// @param string $key ooFormat key
|
|
8
|
+
/// @param map|null $map the map to update (default $ooLoop)
|
|
9
|
+
/// @return mixed
|
|
10
|
+
|
|
11
|
+
@function oo($key, $map:null) {
|
|
12
|
+
$map: if($map == null, $ooLoop, $map);
|
|
13
|
+
|
|
14
|
+
// double check if quotes exist (issue with some sass version and PostCSS Parser)
|
|
15
|
+
@if string.slice($key, 1, 1) == '"' and string.slice($key, string.length($key), - 1) == '"' {
|
|
16
|
+
$key: string.slice($key, 2, string.length($key) - 1);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@if string.index($key, '.') == null {
|
|
20
|
+
@return fn.getMapValue($map, $key);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
$list: fn.splitDeep('.', $key);
|
|
24
|
+
|
|
25
|
+
@for $i from 1 through list.length($list) {
|
|
26
|
+
$value: fn.getMapValue($map, list.nth($list, $i));
|
|
27
|
+
@if $i == list.length($list) and fn.isEmpty($value) {
|
|
28
|
+
$value: fn.getMapValue($map, fn.toKebabCase(list.nth($list, $i)));
|
|
29
|
+
}
|
|
30
|
+
$map: $value;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@return $map;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/// ooPrefix
|
|
37
|
+
/// get loop prefix
|
|
38
|
+
/// @return string
|
|
39
|
+
|
|
40
|
+
@function ooPrefix() {
|
|
41
|
+
@return if(oo(dataAttr) == true, 'data-oo', 'oo');
|
|
42
|
+
}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
@use 'sass:list';
|
|
2
|
+
@use '../fn';
|
|
3
|
+
|
|
1
4
|
/// ooAdd
|
|
2
5
|
/// Push new map value to an another set of map with the ooFormat (default $ooLoop)
|
|
3
6
|
/// @param string $key ooFormat key
|
|
@@ -8,7 +11,7 @@
|
|
|
8
11
|
@function ooAdd($key, $mapValue, $map:null) {
|
|
9
12
|
$currentValue: oo($key, $map);
|
|
10
13
|
|
|
11
|
-
@if isEmpty($currentValue) {
|
|
14
|
+
@if fn.isEmpty($currentValue) {
|
|
12
15
|
$newValue: ooSetSoft($key, $mapValue, $map);
|
|
13
16
|
@return $newValue;
|
|
14
17
|
}
|
|
@@ -17,15 +20,15 @@
|
|
|
17
20
|
$currentValue: getRefValue($currentValue, $map);
|
|
18
21
|
}
|
|
19
22
|
|
|
20
|
-
@if isString($currentValue) {
|
|
21
|
-
$currentValue: toList($currentValue);
|
|
23
|
+
@if fn.isString($currentValue) {
|
|
24
|
+
$currentValue: fn.toList($currentValue);
|
|
22
25
|
}
|
|
23
26
|
|
|
24
|
-
@if isList($currentValue) {
|
|
25
|
-
$newValue: ooSetSoft($key, append($currentValue, $mapValue), $map);
|
|
27
|
+
@if fn.isList($currentValue) {
|
|
28
|
+
$newValue: ooSetSoft($key, list.append($currentValue, $mapValue), $map);
|
|
26
29
|
@return $newValue;
|
|
27
30
|
}
|
|
28
31
|
|
|
29
|
-
$newValue: ooSetSoft($key,
|
|
32
|
+
$newValue: ooSetSoft($key, ooMergeDeep($currentValue, $mapValue, $map), $map);
|
|
30
33
|
@return $newValue;
|
|
31
34
|
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
@use 'sass:color';
|
|
2
|
+
@use 'sass:list';
|
|
3
|
+
@use 'sass:map';
|
|
4
|
+
@use 'sass:meta';
|
|
5
|
+
@use "sass:string";
|
|
6
|
+
@use "../fn";
|
|
7
|
+
|
|
8
|
+
$ooAlias: (
|
|
9
|
+
(
|
|
10
|
+
name: 'ooDarken',
|
|
11
|
+
function: 'adjust-color',
|
|
12
|
+
keywordsArg: ('lightness': -1),
|
|
13
|
+
paramType: ('color', 'number'),
|
|
14
|
+
),
|
|
15
|
+
(
|
|
16
|
+
name: 'ooLighten',
|
|
17
|
+
function: 'adjust-color',
|
|
18
|
+
keywordsArg: ('lightness': 1),
|
|
19
|
+
paramType: ('color', 'number'),
|
|
20
|
+
),
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
// Aliases function used before init
|
|
25
|
+
|
|
26
|
+
@function ooDarken($value, $percentage) {
|
|
27
|
+
@if fn.isNotColor($value) {
|
|
28
|
+
@return $value;
|
|
29
|
+
}
|
|
30
|
+
@return color.adjust($value, $lightness: -$percentage);
|
|
31
|
+
}
|
|
32
|
+
@function ooLighten($value, $percentage) {
|
|
33
|
+
@if fn.isNotColor($value) {
|
|
34
|
+
@return $value;
|
|
35
|
+
}
|
|
36
|
+
@return color.adjust($value, $lightness: $percentage);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/// isAlias
|
|
40
|
+
/// check if a string is a sass alias function
|
|
41
|
+
/// @param string $string the string to check
|
|
42
|
+
/// @return bool
|
|
43
|
+
|
|
44
|
+
@function isAlias($string) {
|
|
45
|
+
@if fn.isNotString($string) {
|
|
46
|
+
@return false;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
$isAlias: false;
|
|
50
|
+
@each $alias in $ooAlias {
|
|
51
|
+
$aliasName: fn.getMapValue($alias, 'name');
|
|
52
|
+
$aliasLength: string.length($aliasName);
|
|
53
|
+
@if string.slice(#{$string}, 1, $aliasLength + 1) == '#{$aliasName}(' and string.slice(#{$string}, string.length(#{$string})) == ')' {
|
|
54
|
+
$isAlias: true;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
@return $isAlias;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/// getAliasInfo
|
|
61
|
+
/// retrieve the alias information
|
|
62
|
+
/// @param string $aliasFunction The complete alias function
|
|
63
|
+
/// @return map|null
|
|
64
|
+
|
|
65
|
+
@function getAliasInfo($aliasFunction) {
|
|
66
|
+
@each $alias in $ooAlias {
|
|
67
|
+
$aliasName: fn.getMapValue($alias, 'name');
|
|
68
|
+
$aliasLength: string.length($aliasName);
|
|
69
|
+
$aliasFunctionName: fn.stripSpaces(string.slice($aliasFunction, 1, $aliasLength));
|
|
70
|
+
|
|
71
|
+
@if $aliasFunctionName == $aliasName {
|
|
72
|
+
$currentAlias: $alias;
|
|
73
|
+
$functionName: fn.getMapValue($alias, 'function');
|
|
74
|
+
|
|
75
|
+
@return (
|
|
76
|
+
name: $aliasName,
|
|
77
|
+
nameLength: $aliasLength,
|
|
78
|
+
function: if(meta.function-exists('get-function'), meta.get-function($functionName), $functionName),
|
|
79
|
+
functionName: $functionName,
|
|
80
|
+
keywordsArg: fn.getMapValue($alias, 'keywordsArg'),
|
|
81
|
+
paramType: fn.getMapValue($alias, 'paramType'),
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
@return null;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/// getAliasValue
|
|
90
|
+
/// retrieve the value of an alias function
|
|
91
|
+
/// @param string $aliasFunction The complete alias function
|
|
92
|
+
/// @param string $value Value of the 1st parameter
|
|
93
|
+
/// @return bool
|
|
94
|
+
|
|
95
|
+
@function getAliasValue($aliasFunction, $value:null) {
|
|
96
|
+
$name: null;
|
|
97
|
+
$paramType: null;
|
|
98
|
+
$keywordsArg: null;
|
|
99
|
+
$function: null;
|
|
100
|
+
$params: fn.splitDeep(',', meta.inspect($aliasFunction));
|
|
101
|
+
$param1: list.nth($params, 1);
|
|
102
|
+
|
|
103
|
+
$aliasInfo: getAliasInfo($aliasFunction);
|
|
104
|
+
|
|
105
|
+
@if $aliasInfo != null {
|
|
106
|
+
$name: fn.getMapValue($aliasInfo, 'name');
|
|
107
|
+
$function: fn.getMapValue($aliasInfo, 'function');
|
|
108
|
+
$keywordsArg: fn.getMapValue($aliasInfo, 'keywordsArg');
|
|
109
|
+
$paramType: fn.getMapValue($aliasInfo, 'paramType');
|
|
110
|
+
$param1: fn.stripSpaces(string.slice($param1, fn.getMapValue($aliasInfo, 'nameLength') + 2, string.length($param1)));
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
$param1: if($value==null, $param1, $value);
|
|
114
|
+
|
|
115
|
+
@if list.length($params) > 1 {
|
|
116
|
+
$param2: fn.stripSpaces(string.slice(#{list.nth($params, 2)}, 1, -2));
|
|
117
|
+
|
|
118
|
+
$param1Type: null;
|
|
119
|
+
$param2Type: null;
|
|
120
|
+
|
|
121
|
+
@if $paramType != null {
|
|
122
|
+
$param1Type: list.nth($paramType, 1);
|
|
123
|
+
$param2Type: list.nth($paramType, 2);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
$param1: fn.toType($param1Type, $param1);
|
|
127
|
+
$param2: fn.toType($param2Type, $param2);
|
|
128
|
+
|
|
129
|
+
@if meta.type-of($param1) != $param1Type or meta.type-of($param2) != $param2Type {
|
|
130
|
+
@warn('The alias `#{$aliasFunction}` is targetting `#{$value}` and therefore cannot be used with the sass function `#{getMapValue($aliasInfo, 'functionName')}`');
|
|
131
|
+
@return $value;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
@if fn.isMap($keywordsArg) {
|
|
135
|
+
$argKey: list.nth(map.keys($keywordsArg), 1);
|
|
136
|
+
$param2: map.get($keywordsArg, $argKey) * $param2;
|
|
137
|
+
@if ($argKey == 'lightness') {
|
|
138
|
+
@return meta.call($function, $param1, $lightness: $param2);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
@return meta.call($function, $param1, $param2);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
@return meta.call($function, $param1);
|
|
146
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
@use 'sass:map';
|
|
2
|
+
@use 'sass:meta';
|
|
3
|
+
@use '../fn';
|
|
4
|
+
|
|
5
|
+
/// ooMergeDeep
|
|
6
|
+
/// Non destructive map merge in the ooLoop.
|
|
7
|
+
/// @credit-to https://gist.github.com/pentzzsolt
|
|
8
|
+
/// @param map $parentMap Map of data to be merged into
|
|
9
|
+
/// @param map $childMap The set of data
|
|
10
|
+
/// @param map $refMap The base map to refer too, usually equivalent to the $ooLoop before going into nested merge
|
|
11
|
+
/// @param bool $forceKebab force the use of kebab-case property
|
|
12
|
+
/// @return map
|
|
13
|
+
|
|
14
|
+
@function ooMergeDeep($parentMap, $childMap, $refMap: null, $forceKebab: false) {
|
|
15
|
+
$map: $parentMap;
|
|
16
|
+
|
|
17
|
+
@if not fn.isMap($map) {
|
|
18
|
+
@return $map;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
$refMap: if($refMap ==null, $ooLoop, $refMap);
|
|
22
|
+
|
|
23
|
+
@each $key, $value in $childMap {
|
|
24
|
+
$key: if($forceKebab, fn.toKebabCase($key), $key);
|
|
25
|
+
|
|
26
|
+
@if isRef(map.get($map, $key)) {
|
|
27
|
+
$mapValue: getRefValue(map.get($map, $key), $refMap);
|
|
28
|
+
$map: map.merge($map, ($key: $mapValue));
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@if (not map.has-key($map, $key)) or (meta.type-of(map.get($map, $key)) != meta.type-of($value)) or (not (fn.isMap(map.get($map, $key)) and fn.isMap($value))) {
|
|
32
|
+
$map: map.merge($map, ($key: $value));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@else {
|
|
36
|
+
$map: map.merge($map, ($key: ooMergeDeep(map.get($map, $key), $value, $refMap, fn.inList($key, ('props', 'states')))));
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@return $map;
|
|
41
|
+
}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
@use 'sass:list';
|
|
2
|
+
@use 'sass:string';
|
|
3
|
+
@use '../fn';
|
|
4
|
+
|
|
1
5
|
/// ooParse
|
|
2
6
|
/// Parse a map of data making sure all references is being replaced
|
|
3
7
|
/// @param map $map
|
|
@@ -24,13 +28,13 @@
|
|
|
24
28
|
$parentMap: if($backup == null, $map, $backup);
|
|
25
29
|
|
|
26
30
|
@each $key, $value in $map {
|
|
27
|
-
@if isMap($value) {
|
|
31
|
+
@if fn.isMap($value) {
|
|
28
32
|
// set path to remember where we came from in a nested environment
|
|
29
|
-
$path: if(isEmpty($path), '#{$key}', '#{$path}.#{$key}');
|
|
33
|
+
$path: if(fn.isEmpty($path), '#{$key}', '#{$path}.#{$key}');
|
|
30
34
|
$newValue: parser($value, $parentMap, $path);
|
|
31
|
-
$map: setMapValue($map, $key, $newValue);
|
|
35
|
+
$map: fn.setMapValue($map, $key, $newValue);
|
|
32
36
|
// clear latest child in path to go backup in the nested environment
|
|
33
|
-
$path: if(length(
|
|
37
|
+
$path: if(list.length(fn.splitDeep('.', $path)) > 1, fn.replace('.#{$key}', '', $path), fn.replace('#{$key}', '', $path));
|
|
34
38
|
} @else if hasRef($value) {
|
|
35
39
|
$ooRef: extractRef($value);
|
|
36
40
|
$newValue: getRefValue($ooRef, $parentMap);
|
|
@@ -39,28 +43,28 @@
|
|
|
39
43
|
$newValue: getSpreadMap($value, $parentMap);
|
|
40
44
|
}
|
|
41
45
|
|
|
42
|
-
@if isList($value) and isNotMap($newValue) {
|
|
43
|
-
$refIndex: index($value, $ooRef);
|
|
46
|
+
@if fn.isList($value) and fn.isNotMap($newValue) {
|
|
47
|
+
$refIndex: list.index($value, $ooRef);
|
|
44
48
|
$newListValue: ();
|
|
45
|
-
@for $i from 1 through length($value) {
|
|
46
|
-
@if (isAlias(nth($value, $i))) {
|
|
49
|
+
@for $i from 1 through list.length($value) {
|
|
50
|
+
@if (isAlias(list.nth($value, $i))) {
|
|
47
51
|
@if hasRef($newValue) {
|
|
48
|
-
$newListValue: append($newListValue, replace($ooRef, $newValue, nth($value, $i)));
|
|
52
|
+
$newListValue: list.append($newListValue, fn.replace($ooRef, $newValue, list.nth($value, $i)));
|
|
49
53
|
} @else {
|
|
50
|
-
$newListValue: append($newListValue, getAliasValue(nth($value, $i), $newValue));
|
|
54
|
+
$newListValue: list.append($newListValue, getAliasValue(list.nth($value, $i), $newValue));
|
|
51
55
|
}
|
|
52
56
|
} @else if ($i == $refIndex) {
|
|
53
|
-
$newListValue: append($newListValue, $newValue)
|
|
57
|
+
$newListValue: list.append($newListValue, $newValue)
|
|
54
58
|
} @else {
|
|
55
|
-
$newListValue: append($newListValue, nth($value, $i))
|
|
59
|
+
$newListValue: list.append($newListValue, list.nth($value, $i))
|
|
56
60
|
}
|
|
57
61
|
}
|
|
58
62
|
$newValue: $newListValue;
|
|
59
63
|
}
|
|
60
64
|
|
|
61
|
-
@if isAlias($value) and isNotList($value) {
|
|
65
|
+
@if isAlias($value) and fn.isNotList($value) {
|
|
62
66
|
@if hasRef($newValue) {
|
|
63
|
-
$newValue: replace($ooRef, $newValue, $value);
|
|
67
|
+
$newValue: string.replace($ooRef, $newValue, $value);
|
|
64
68
|
} @else {
|
|
65
69
|
$newValue: getAliasValue($value, $newValue);
|
|
66
70
|
}
|
|
@@ -69,8 +73,8 @@
|
|
|
69
73
|
$map: ooSetSoft($key, $newValue, $map);
|
|
70
74
|
|
|
71
75
|
//update backup
|
|
72
|
-
@if isEmpty($path) {
|
|
73
|
-
$parentMap:
|
|
76
|
+
@if fn.isEmpty($path) {
|
|
77
|
+
$parentMap: ooMergeDeep($parentMap, $map);
|
|
74
78
|
} @else {
|
|
75
79
|
$parentMap: ooSetSoft($path, $map, $parentMap);
|
|
76
80
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
@use '../fn';
|
|
2
|
+
|
|
1
3
|
/// ooPipe
|
|
2
4
|
/// Pipe list of ooSet Rules
|
|
3
5
|
/// @param list $rules List of rules
|
|
@@ -6,10 +8,10 @@
|
|
|
6
8
|
@function ooPipe($rules...) {
|
|
7
9
|
$map: $ooLoop;
|
|
8
10
|
@each $rule in $rules {
|
|
9
|
-
@if getMapValue($rule, 'action') == 'add' {
|
|
10
|
-
$map: ooAdd(getMapValue($rule, 'path'), getMapValue($rule, 'value'), $map);
|
|
11
|
+
@if fn.getMapValue($rule, 'action') == 'add' {
|
|
12
|
+
$map: ooAdd(fn.getMapValue($rule, 'path'), fn.getMapValue($rule, 'value'), $map);
|
|
11
13
|
} @else {
|
|
12
|
-
$map: ooSetHard(getMapValue($rule, 'path'), getMapValue($rule, 'value'), $map);
|
|
14
|
+
$map: ooSetHard(fn.getMapValue($rule, 'path'), fn.getMapValue($rule, 'value'), $map);
|
|
13
15
|
}
|
|
14
16
|
}
|
|
15
17
|
@return $map;
|
|
@@ -1,13 +1,19 @@
|
|
|
1
|
+
@use "sass:list";
|
|
2
|
+
@use "sass:map";
|
|
3
|
+
@use "sass:meta";
|
|
4
|
+
@use 'sass:string';
|
|
5
|
+
@use '../fn';
|
|
6
|
+
|
|
1
7
|
/// hasRef
|
|
2
8
|
/// Check if a map has a ooFormat
|
|
3
9
|
/// @param mixed
|
|
4
10
|
/// @return bool
|
|
5
11
|
|
|
6
12
|
@function hasRef($search) {
|
|
7
|
-
@if isNotString($search) {
|
|
8
|
-
$search: inspect($search);
|
|
13
|
+
@if fn.isNotString($search) {
|
|
14
|
+
$search: meta.inspect($search);
|
|
9
15
|
}
|
|
10
|
-
@return if(
|
|
16
|
+
@return if(string.index($search, 'this(') == null, false, true);
|
|
11
17
|
}
|
|
12
18
|
|
|
13
19
|
|
|
@@ -17,10 +23,10 @@
|
|
|
17
23
|
/// @return bool
|
|
18
24
|
|
|
19
25
|
@function isRef($string) {
|
|
20
|
-
@if isNotString($string) {
|
|
21
|
-
$string: inspect($string);
|
|
26
|
+
@if fn.isNotString($string) {
|
|
27
|
+
$string: meta.inspect($string);
|
|
22
28
|
}
|
|
23
|
-
@return
|
|
29
|
+
@return string.slice($string, 1, 5) == 'this(' and string.slice($string, string.length($string)) == ')';
|
|
24
30
|
}
|
|
25
31
|
|
|
26
32
|
/// hasSpreadOperator
|
|
@@ -29,10 +35,10 @@
|
|
|
29
35
|
/// @return bool
|
|
30
36
|
|
|
31
37
|
@function hasSpreadOperator($ref) {
|
|
32
|
-
@if isNotString($ref) {
|
|
33
|
-
$ref: inspect($ref);
|
|
38
|
+
@if fn.isNotString($ref) {
|
|
39
|
+
$ref: meta.inspect($ref);
|
|
34
40
|
}
|
|
35
|
-
@return if(
|
|
41
|
+
@return if(string.index($ref, '_this(') == null, false, true);
|
|
36
42
|
}
|
|
37
43
|
|
|
38
44
|
/// getRefPath
|
|
@@ -41,10 +47,10 @@
|
|
|
41
47
|
/// @return String
|
|
42
48
|
|
|
43
49
|
@function getRefPath($string) {
|
|
44
|
-
@if isNotString($string) {
|
|
45
|
-
$string: inspect($string);
|
|
50
|
+
@if fn.isNotString($string) {
|
|
51
|
+
$string: meta.inspect($string);
|
|
46
52
|
}
|
|
47
|
-
@return
|
|
53
|
+
@return string.slice($string, 6, -2);
|
|
48
54
|
}
|
|
49
55
|
|
|
50
56
|
/// getRefValue
|
|
@@ -68,27 +74,27 @@
|
|
|
68
74
|
/// @return map
|
|
69
75
|
|
|
70
76
|
@function getSpreadMap($list, $map) {
|
|
71
|
-
@if isNotList($list) {
|
|
77
|
+
@if fn.isNotList($list) {
|
|
72
78
|
@error 'spread operator must be used within a list';
|
|
73
79
|
}
|
|
74
80
|
$newMapValue: ();
|
|
75
|
-
@for $i from 1 through length($list) {
|
|
76
|
-
@if hasSpreadOperator(nth($list, $i)) {
|
|
77
|
-
$ref: extractRef(nth($list, $i));
|
|
81
|
+
@for $i from 1 through list.length($list) {
|
|
82
|
+
@if hasSpreadOperator(list.nth($list, $i)) {
|
|
83
|
+
$ref: extractRef(list.nth($list, $i));
|
|
78
84
|
$refValue: getRefValue($ref, $map);
|
|
79
85
|
@if hasSpreadOperator($refValue) {
|
|
80
86
|
$refValue: getSpreadMap($refValue, $map);
|
|
81
87
|
}
|
|
82
|
-
@if isNotMap($refValue) {
|
|
88
|
+
@if fn.isNotMap($refValue) {
|
|
83
89
|
//the use of replace is for some sass version
|
|
84
|
-
$refPathList:
|
|
85
|
-
$refValue: (nth($refPathList, length($refPathList)): $refValue);
|
|
90
|
+
$refPathList: fn.splitDeep('.', fn.replace('"', '', getRefPath($ref)));
|
|
91
|
+
$refValue: (list.nth($refPathList, list.length($refPathList)): $refValue);
|
|
86
92
|
}
|
|
87
|
-
$newMapValue: map
|
|
88
|
-
} @else if isNotMap(nth($list, $i)) {
|
|
93
|
+
$newMapValue: map.merge($newMapValue, $refValue);
|
|
94
|
+
} @else if fn.isNotMap(list.nth($list, $i)) {
|
|
89
95
|
@error 'spread operator only works along map';
|
|
90
96
|
} @else {
|
|
91
|
-
$newMapValue: map
|
|
97
|
+
$newMapValue: map.merge($newMapValue, list.nth($list, $i));
|
|
92
98
|
}
|
|
93
99
|
}
|
|
94
100
|
@return $newMapValue;
|
|
@@ -100,12 +106,12 @@
|
|
|
100
106
|
/// @return string
|
|
101
107
|
|
|
102
108
|
@function extractRef($string) {
|
|
103
|
-
@if isNotString($string) {
|
|
104
|
-
$string: inspect($string)
|
|
109
|
+
@if fn.isNotString($string) {
|
|
110
|
+
$string: meta.inspect($string)
|
|
105
111
|
}
|
|
106
112
|
@if not hasRef($string) {
|
|
107
113
|
@return $string;
|
|
108
114
|
}
|
|
109
|
-
$extractString: extract('this(', ')', $string);
|
|
115
|
+
$extractString: fn.extract('this(', ')', $string);
|
|
110
116
|
@return $extractString;
|
|
111
117
|
}
|