@danielito1996/compose-svelted 0.2.7-alpha01 → 0.2.7-alpha02
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/components/layouts/Box.svelte +33 -11
- package/dist/components/layouts/Box.svelte.d.ts +2 -11
- package/dist/components/layouts/Column.svelte +30 -7
- package/dist/components/layouts/LayoutContext.d.ts +1 -0
- package/dist/components/layouts/LayoutContext.js +1 -0
- package/dist/components/layouts/Row.svelte +31 -8
- package/dist/components/layouts/resolveAlignment.d.ts +4 -0
- package/dist/components/layouts/resolveAlignment.js +44 -0
- package/dist/components/layouts/resolveFlexAlignSelf.d.ts +2 -0
- package/dist/components/layouts/resolveFlexAlignSelf.js +10 -0
- package/dist/core/modifier/ModifierImpl.d.ts +13 -19
- package/dist/core/modifier/ModifierImpl.js +63 -151
- package/package.json +1 -1
|
@@ -1,25 +1,47 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { Modifier } from "../../core/modifier/Modifier";
|
|
3
|
-
import type {BoxAlignment} from "./Alignment";
|
|
3
|
+
import type { BoxAlignment } from "./Alignment";
|
|
4
|
+
import {resolveBoxAlignment} from "./resolveAlignment";
|
|
4
5
|
|
|
5
6
|
export let modifier: Modifier = Modifier.empty();
|
|
6
7
|
export let contentAlignment: BoxAlignment | undefined = undefined;
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Box-level alignment:
|
|
11
|
+
* Alinea TODOS los hijos (Compose Box behavior)
|
|
12
|
+
*/
|
|
13
|
+
function contentAlignmentStyle(alignment: BoxAlignment): string {
|
|
14
|
+
const [h, v = h] = alignment.split(" ");
|
|
9
15
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const v = vert === "flex-start" ? "flex-start" : vert === "flex-end" ? "flex-end" : "center";
|
|
16
|
+
const justify =
|
|
17
|
+
h === "flex-start" ? "flex-start" :
|
|
18
|
+
h === "flex-end" ? "flex-end" :
|
|
19
|
+
"center";
|
|
15
20
|
|
|
16
|
-
|
|
21
|
+
const align =
|
|
22
|
+
v === "flex-start" ? "flex-start" :
|
|
23
|
+
v === "flex-end" ? "flex-end" :
|
|
24
|
+
"center";
|
|
25
|
+
|
|
26
|
+
return `
|
|
27
|
+
display:flex;
|
|
28
|
+
justify-content:${justify};
|
|
29
|
+
align-items:${align};
|
|
30
|
+
`;
|
|
17
31
|
}
|
|
18
32
|
</script>
|
|
19
33
|
|
|
20
34
|
<div
|
|
21
|
-
class="
|
|
22
|
-
style={
|
|
35
|
+
class="compose-box"
|
|
36
|
+
style={`
|
|
37
|
+
position:relative;
|
|
38
|
+
${contentAlignment ? contentAlignmentStyle(contentAlignment) : ""}
|
|
39
|
+
${modifier.toStyle()}
|
|
40
|
+
`}
|
|
23
41
|
>
|
|
24
|
-
|
|
42
|
+
<!--
|
|
43
|
+
Slot con scope:
|
|
44
|
+
Cada hijo puede traer su propio Modifier
|
|
45
|
+
-->
|
|
46
|
+
style={`position:relative;${modifier.toStyle()}`}
|
|
25
47
|
</div>
|
|
@@ -13,20 +13,11 @@ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> =
|
|
|
13
13
|
};
|
|
14
14
|
z_$$bindings?: Bindings;
|
|
15
15
|
}
|
|
16
|
-
|
|
17
|
-
default: any;
|
|
18
|
-
} ? Props extends Record<string, never> ? any : {
|
|
19
|
-
children?: any;
|
|
20
|
-
} : {});
|
|
21
|
-
declare const Box: $$__sveltets_2_IsomorphicComponent<$$__sveltets_2_PropsWithChildren<{
|
|
16
|
+
declare const Box: $$__sveltets_2_IsomorphicComponent<{
|
|
22
17
|
modifier?: Modifier;
|
|
23
18
|
contentAlignment?: BoxAlignment | undefined;
|
|
24
19
|
}, {
|
|
25
|
-
default: {};
|
|
26
|
-
}>, {
|
|
27
20
|
[evt: string]: CustomEvent<any>;
|
|
28
|
-
}, {
|
|
29
|
-
default: {};
|
|
30
|
-
}, {}, string>;
|
|
21
|
+
}, {}, {}, string>;
|
|
31
22
|
type Box = InstanceType<typeof Box>;
|
|
32
23
|
export default Box;
|
|
@@ -4,20 +4,43 @@
|
|
|
4
4
|
import { Arrangement } from "./Arrangement";
|
|
5
5
|
import type { ArrangementValue } from "./Arrangement";
|
|
6
6
|
import type { HorizontalAlignment } from "./Alignment";
|
|
7
|
+
import {resolveFlexAlignSelf} from "./resolveFlexAlignSelf";
|
|
7
8
|
|
|
8
9
|
export let modifier: Modifier = Modifier.empty();
|
|
10
|
+
|
|
11
|
+
// Cross-axis (horizontal en Column)
|
|
9
12
|
export let horizontalAlignment: HorizontalAlignment = Alignment.Start;
|
|
13
|
+
|
|
14
|
+
// Main-axis (vertical en Column)
|
|
10
15
|
export let verticalArrangement: ArrangementValue = Arrangement.Start;
|
|
16
|
+
|
|
17
|
+
$: gapStyle =
|
|
18
|
+
verticalArrangement.type === "spaced"
|
|
19
|
+
? `gap:${verticalArrangement.gap}px;`
|
|
20
|
+
: "";
|
|
11
21
|
</script>
|
|
12
22
|
|
|
13
23
|
<div
|
|
14
|
-
class="
|
|
24
|
+
class="compose-column"
|
|
15
25
|
style={`
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
26
|
+
display: flex;
|
|
27
|
+
flex-direction: column;
|
|
28
|
+
align-items: ${horizontalAlignment};
|
|
29
|
+
justify-content: ${verticalArrangement.justifyContent};
|
|
30
|
+
${gapStyle}
|
|
31
|
+
${modifier.toStyle()}
|
|
32
|
+
`}
|
|
21
33
|
>
|
|
22
|
-
<slot
|
|
34
|
+
<slot let:modifier>
|
|
35
|
+
<div
|
|
36
|
+
style={`
|
|
37
|
+
${modifier?.getMeta().align
|
|
38
|
+
? resolveFlexAlignSelf(modifier.getMeta().align)
|
|
39
|
+
: ""}
|
|
40
|
+
${modifier?.toStyle()}
|
|
41
|
+
`}
|
|
42
|
+
>
|
|
43
|
+
<slot />
|
|
44
|
+
</div>
|
|
45
|
+
</slot>
|
|
23
46
|
</div>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type LayoutContext = "flex" | "box";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -4,20 +4,43 @@
|
|
|
4
4
|
import { Arrangement } from "./Arrangement";
|
|
5
5
|
import type { ArrangementValue } from "./Arrangement";
|
|
6
6
|
import type { VerticalAlignment } from "./Alignment";
|
|
7
|
+
import {resolveFlexAlignSelf} from "./resolveFlexAlignSelf";
|
|
7
8
|
|
|
8
9
|
export let modifier: Modifier = Modifier.empty();
|
|
9
|
-
|
|
10
|
+
|
|
11
|
+
// Cross-axis (vertical en Row)
|
|
12
|
+
export let verticalAlignment: VerticalAlignment = Alignment.CenterVertically;
|
|
13
|
+
|
|
14
|
+
// Main-axis (horizontal en Row)
|
|
10
15
|
export let horizontalArrangement: ArrangementValue = Arrangement.Start;
|
|
16
|
+
|
|
17
|
+
$: gapStyle =
|
|
18
|
+
horizontalArrangement.type === "spaced"
|
|
19
|
+
? `gap:${horizontalArrangement.gap}px;`
|
|
20
|
+
: "";
|
|
11
21
|
</script>
|
|
12
22
|
|
|
13
23
|
<div
|
|
14
|
-
class="
|
|
24
|
+
class="compose-row"
|
|
15
25
|
style={`
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
26
|
+
display: flex;
|
|
27
|
+
flex-direction: row;
|
|
28
|
+
align-items: ${verticalAlignment};
|
|
29
|
+
justify-content: ${horizontalArrangement.justifyContent};
|
|
30
|
+
${gapStyle}
|
|
31
|
+
${modifier.toStyle()}
|
|
32
|
+
`}
|
|
21
33
|
>
|
|
22
|
-
<slot
|
|
34
|
+
<slot let:modifier>
|
|
35
|
+
<div
|
|
36
|
+
style={`
|
|
37
|
+
${modifier?.getMeta().align
|
|
38
|
+
? resolveFlexAlignSelf(modifier.getMeta().align)
|
|
39
|
+
: ""}
|
|
40
|
+
${modifier?.toStyle()}
|
|
41
|
+
`}
|
|
42
|
+
>
|
|
43
|
+
<slot />
|
|
44
|
+
</div>
|
|
45
|
+
</slot>
|
|
23
46
|
</div>
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/* =========================
|
|
2
|
+
* Box (position:absolute)
|
|
3
|
+
* ========================= */
|
|
4
|
+
export function resolveBoxAlignment(alignment) {
|
|
5
|
+
var _a;
|
|
6
|
+
if (!alignment)
|
|
7
|
+
return "";
|
|
8
|
+
var parts = alignment.split(" ");
|
|
9
|
+
var h = parts[0];
|
|
10
|
+
var v = (_a = parts[1]) !== null && _a !== void 0 ? _a : parts[0];
|
|
11
|
+
var style = "position:absolute;";
|
|
12
|
+
// Vertical
|
|
13
|
+
if (v === "flex-start")
|
|
14
|
+
style += "top:0;";
|
|
15
|
+
else if (v === "flex-end")
|
|
16
|
+
style += "bottom:0;";
|
|
17
|
+
else
|
|
18
|
+
style += "top:50%;";
|
|
19
|
+
// Horizontal
|
|
20
|
+
if (h === "flex-start")
|
|
21
|
+
style += "left:0;";
|
|
22
|
+
else if (h === "flex-end")
|
|
23
|
+
style += "right:0;";
|
|
24
|
+
else
|
|
25
|
+
style += "left:50%;";
|
|
26
|
+
if (h === "center" || v === "center") {
|
|
27
|
+
style += "transform:translate(-50%,-50%);";
|
|
28
|
+
}
|
|
29
|
+
return style;
|
|
30
|
+
}
|
|
31
|
+
/* =========================
|
|
32
|
+
* Flex (Row / Column)
|
|
33
|
+
* ========================= */
|
|
34
|
+
export function resolveFlexAlignment(mod) {
|
|
35
|
+
var align = mod.getMeta().align;
|
|
36
|
+
if (!align)
|
|
37
|
+
return "";
|
|
38
|
+
var horizontal = align.split(" ")[0];
|
|
39
|
+
return "\n align-self:".concat(horizontal === "center"
|
|
40
|
+
? "center"
|
|
41
|
+
: horizontal === "flex-end"
|
|
42
|
+
? "flex-end"
|
|
43
|
+
: "flex-start", ";\n ");
|
|
44
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export function resolveFlexAlignSelf(alignment) {
|
|
2
|
+
var _a;
|
|
3
|
+
var parts = alignment.split(" ");
|
|
4
|
+
var vertical = (_a = parts[1]) !== null && _a !== void 0 ? _a : parts[0];
|
|
5
|
+
if (vertical === "flex-start")
|
|
6
|
+
return "align-self:flex-start;";
|
|
7
|
+
if (vertical === "flex-end")
|
|
8
|
+
return "align-self:flex-end;";
|
|
9
|
+
return "align-self:center;";
|
|
10
|
+
}
|
|
@@ -1,38 +1,32 @@
|
|
|
1
1
|
import type { BoxAlignment } from "../../components/layouts/Alignment";
|
|
2
2
|
import type { Shape } from "../shapes/Shape";
|
|
3
3
|
import type { ColorToken } from "../theme/ColorScheme";
|
|
4
|
+
export type ModifierMeta = {
|
|
5
|
+
align?: BoxAlignment;
|
|
6
|
+
};
|
|
4
7
|
export type ModifierEntry = {
|
|
5
8
|
className?: string;
|
|
6
9
|
style?: string;
|
|
10
|
+
meta?: ModifierMeta;
|
|
7
11
|
};
|
|
8
12
|
export declare class ModifierImpl {
|
|
9
13
|
private readonly entries;
|
|
10
14
|
constructor(entries?: ModifierEntry[]);
|
|
11
15
|
then(other: ModifierImpl): ModifierImpl;
|
|
12
|
-
paddingHorizontal(value: number): ModifierImpl;
|
|
13
|
-
verticalScroll(enabled?: boolean): ModifierImpl;
|
|
14
|
-
horizontalScroll(enabled?: boolean): ModifierImpl;
|
|
15
|
-
paddingVertical(value: number): ModifierImpl;
|
|
16
16
|
fillMaxWidth(): ModifierImpl;
|
|
17
17
|
fillMaxHeight(): ModifierImpl;
|
|
18
18
|
fillMaxSize(): ModifierImpl;
|
|
19
|
-
background(color: ColorToken | string): ModifierImpl;
|
|
20
19
|
weight(weight: number, fill?: boolean): ModifierImpl;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
end?: number;
|
|
27
|
-
}, unit?: string): ModifierImpl;
|
|
28
|
-
width(value: number | string, unit?: string): ModifierImpl;
|
|
29
|
-
height(value: number | string, unit?: string): ModifierImpl;
|
|
30
|
-
marginTop(value: number, unit?: string): ModifierImpl;
|
|
31
|
-
clip(shape: Shape): ModifierImpl;
|
|
32
|
-
size(value: number | string, unit?: string): ModifierImpl;
|
|
33
|
-
offset(x: number, y: number): ModifierImpl;
|
|
34
|
-
clickable(onClick: () => void): ModifierImpl;
|
|
20
|
+
padding(value: number): ModifierImpl;
|
|
21
|
+
paddingHorizontal(value: number): ModifierImpl;
|
|
22
|
+
paddingVertical(value: number): ModifierImpl;
|
|
23
|
+
marginTop(value: number): ModifierImpl;
|
|
24
|
+
background(color: ColorToken | string): ModifierImpl;
|
|
35
25
|
border(width: number, color: string, shape?: Shape): ModifierImpl;
|
|
26
|
+
clip(shape: Shape): ModifierImpl;
|
|
27
|
+
align(alignment: BoxAlignment): ModifierImpl;
|
|
28
|
+
clickable(): ModifierImpl;
|
|
36
29
|
toStyle(): string;
|
|
37
30
|
toClass(): string;
|
|
31
|
+
getMeta(): ModifierMeta;
|
|
38
32
|
}
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
1
12
|
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
2
13
|
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
3
14
|
if (ar || !(i in from)) {
|
|
@@ -8,40 +19,19 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
8
19
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
9
20
|
};
|
|
10
21
|
import { resolveColor } from "../theme/resolve";
|
|
22
|
+
/* =========================
|
|
23
|
+
* ModifierImpl
|
|
24
|
+
* ========================= */
|
|
11
25
|
var ModifierImpl = /** @class */ (function () {
|
|
12
26
|
function ModifierImpl(entries) {
|
|
13
27
|
if (entries === void 0) { entries = []; }
|
|
14
28
|
this.entries = entries;
|
|
15
29
|
}
|
|
30
|
+
/* -------- composición -------- */
|
|
16
31
|
ModifierImpl.prototype.then = function (other) {
|
|
17
32
|
return new ModifierImpl(__spreadArray(__spreadArray([], this.entries, true), other.entries, true));
|
|
18
33
|
};
|
|
19
|
-
|
|
20
|
-
return this.then(new ModifierImpl([
|
|
21
|
-
{ style: "padding-left:".concat(value, "px;padding-right:").concat(value, "px;") },
|
|
22
|
-
]));
|
|
23
|
-
};
|
|
24
|
-
ModifierImpl.prototype.verticalScroll = function (enabled) {
|
|
25
|
-
if (enabled === void 0) { enabled = true; }
|
|
26
|
-
return this.then(new ModifierImpl([{
|
|
27
|
-
style: enabled
|
|
28
|
-
? "overflow-y:auto;overflow-x:hidden;-webkit-overflow-scrolling:touch;"
|
|
29
|
-
: ''
|
|
30
|
-
}]));
|
|
31
|
-
};
|
|
32
|
-
ModifierImpl.prototype.horizontalScroll = function (enabled) {
|
|
33
|
-
if (enabled === void 0) { enabled = true; }
|
|
34
|
-
return this.then(new ModifierImpl([{
|
|
35
|
-
style: enabled
|
|
36
|
-
? "overflow-x:auto;overflow-y:hidden;-webkit-overflow-scrolling:touch;white-space:nowrap;"
|
|
37
|
-
: ''
|
|
38
|
-
}]));
|
|
39
|
-
};
|
|
40
|
-
ModifierImpl.prototype.paddingVertical = function (value) {
|
|
41
|
-
return this.then(new ModifierImpl([
|
|
42
|
-
{ style: "padding-top:".concat(value, "px;padding-bottom:").concat(value, "px;") },
|
|
43
|
-
]));
|
|
44
|
-
};
|
|
34
|
+
/* -------- layout size -------- */
|
|
45
35
|
ModifierImpl.prototype.fillMaxWidth = function () {
|
|
46
36
|
return this.then(new ModifierImpl([{ style: "width:100%;" }]));
|
|
47
37
|
};
|
|
@@ -51,164 +41,86 @@ var ModifierImpl = /** @class */ (function () {
|
|
|
51
41
|
ModifierImpl.prototype.fillMaxSize = function () {
|
|
52
42
|
return this.then(new ModifierImpl([{ style: "width:100%;height:100%;" }]));
|
|
53
43
|
};
|
|
54
|
-
ModifierImpl.prototype.background = function (color) {
|
|
55
|
-
var resolved;
|
|
56
|
-
if (typeof color === "string" &&
|
|
57
|
-
(color.startsWith("#") ||
|
|
58
|
-
color.startsWith("rgb") ||
|
|
59
|
-
color.startsWith("hsl") ||
|
|
60
|
-
color === "transparent" ||
|
|
61
|
-
color === "currentColor")) {
|
|
62
|
-
// Color CSS directo
|
|
63
|
-
resolved = color;
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
// Token de ComposeTheme
|
|
67
|
-
resolved = resolveColor(color);
|
|
68
|
-
}
|
|
69
|
-
return this.then(new ModifierImpl([
|
|
70
|
-
{ style: "background:".concat(resolved, ";") }
|
|
71
|
-
]));
|
|
72
|
-
};
|
|
73
44
|
ModifierImpl.prototype.weight = function (weight, fill) {
|
|
74
45
|
if (fill === void 0) { fill = true; }
|
|
75
|
-
if (weight <= 0)
|
|
76
|
-
console.warn("Modifier.weight() debe ser > 0");
|
|
46
|
+
if (weight <= 0)
|
|
77
47
|
return this;
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
];
|
|
84
|
-
return this.then(new ModifierImpl([{ style: styleParts.join(" ") }]));
|
|
85
|
-
};
|
|
86
|
-
ModifierImpl.prototype.align = function (alignment) {
|
|
87
|
-
var parts = alignment.split(' ');
|
|
88
|
-
var horizontal = parts[0]; // flex-start, center, flex-end
|
|
89
|
-
var vertical = parts[1] || parts[0]; // para casos simples como "center"
|
|
90
|
-
var style = 'position: absolute;';
|
|
91
|
-
// Vertical
|
|
92
|
-
if (vertical === 'flex-start') {
|
|
93
|
-
style += 'top: 0;';
|
|
94
|
-
}
|
|
95
|
-
else if (vertical === 'flex-end') {
|
|
96
|
-
style += 'bottom: 0;';
|
|
97
|
-
}
|
|
98
|
-
else if (vertical === 'center') {
|
|
99
|
-
style += 'top: 50%; transform: translateY(-50%);';
|
|
100
|
-
}
|
|
101
|
-
// Horizontal
|
|
102
|
-
if (horizontal === 'flex-start') {
|
|
103
|
-
style += 'left: 0;';
|
|
104
|
-
}
|
|
105
|
-
else if (horizontal === 'flex-end') {
|
|
106
|
-
style += 'right: 0;';
|
|
107
|
-
}
|
|
108
|
-
else if (horizontal === 'center') {
|
|
109
|
-
style += 'left: 50%;';
|
|
110
|
-
// Combinar transform si ya hay translateY
|
|
111
|
-
if (style.includes('translateY')) {
|
|
112
|
-
style = style.replace('translateY(-50%)', 'translate(-50%, -50%)');
|
|
113
|
-
}
|
|
114
|
-
else {
|
|
115
|
-
style += 'transform: translateX(-50%);';
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
return this.then(new ModifierImpl([{ style: style }]));
|
|
119
|
-
};
|
|
120
|
-
ModifierImpl.prototype.padding = function (valueOrParams, unit) {
|
|
121
|
-
if (valueOrParams === void 0) { valueOrParams = 0; }
|
|
122
|
-
if (unit === void 0) { unit = 'px'; }
|
|
123
|
-
var style = '';
|
|
124
|
-
if (typeof valueOrParams === 'number') {
|
|
125
|
-
// Padding uniforme
|
|
126
|
-
style = "padding:".concat(valueOrParams).concat(unit, ";");
|
|
127
|
-
}
|
|
128
|
-
else {
|
|
129
|
-
// Padding direccional
|
|
130
|
-
var _a = valueOrParams.top, top = _a === void 0 ? 0 : _a, _b = valueOrParams.bottom, bottom = _b === void 0 ? 0 : _b, _c = valueOrParams.start, start = _c === void 0 ? 0 : _c, _d = valueOrParams.end, end = _d === void 0 ? 0 : _d;
|
|
131
|
-
style = "\n padding-top:".concat(top).concat(unit, ";\n padding-bottom:").concat(bottom).concat(unit, ";\n padding-left:").concat(start).concat(unit, ";\n //padding-right:").concat(end).concat(unit, ";\n ").trim();
|
|
132
|
-
}
|
|
133
|
-
return this.then(new ModifierImpl([{ style: style }]));
|
|
134
|
-
};
|
|
135
|
-
ModifierImpl.prototype.width = function (value, unit) {
|
|
136
|
-
if (unit === void 0) { unit = 'px'; }
|
|
137
|
-
var size = typeof value === 'number' ? "".concat(value).concat(unit) : value;
|
|
138
|
-
return this.then(new ModifierImpl([{ style: "width:".concat(size, ";") }]));
|
|
48
|
+
return this.then(new ModifierImpl([
|
|
49
|
+
{
|
|
50
|
+
style: "\n flex-grow:".concat(weight, ";\n flex-shrink:").concat(fill ? 1 : 0, ";\n flex-basis:0%;\n "),
|
|
51
|
+
},
|
|
52
|
+
]));
|
|
139
53
|
};
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
return this.then(new ModifierImpl([{ style: "height:".concat(size, ";") }]));
|
|
54
|
+
/* -------- padding / margin -------- */
|
|
55
|
+
ModifierImpl.prototype.padding = function (value) {
|
|
56
|
+
return this.then(new ModifierImpl([{ style: "padding:".concat(value, "px;") }]));
|
|
144
57
|
};
|
|
145
|
-
ModifierImpl.prototype.
|
|
146
|
-
|
|
147
|
-
|
|
58
|
+
ModifierImpl.prototype.paddingHorizontal = function (value) {
|
|
59
|
+
return this.then(new ModifierImpl([
|
|
60
|
+
{ style: "padding-left:".concat(value, "px;padding-right:").concat(value, "px;") },
|
|
61
|
+
]));
|
|
148
62
|
};
|
|
149
|
-
ModifierImpl.prototype.
|
|
63
|
+
ModifierImpl.prototype.paddingVertical = function (value) {
|
|
150
64
|
return this.then(new ModifierImpl([
|
|
151
|
-
{
|
|
152
|
-
style: "\n border-radius:".concat(shape.toCssBorderRadius(), ";\n overflow:hidden;\n ")
|
|
153
|
-
}
|
|
65
|
+
{ style: "padding-top:".concat(value, "px;padding-bottom:").concat(value, "px;") },
|
|
154
66
|
]));
|
|
155
67
|
};
|
|
156
|
-
ModifierImpl.prototype.
|
|
157
|
-
|
|
158
|
-
|
|
68
|
+
ModifierImpl.prototype.marginTop = function (value) {
|
|
69
|
+
return this.then(new ModifierImpl([{ style: "margin-top:".concat(value, "px;") }]));
|
|
70
|
+
};
|
|
71
|
+
/* -------- background / border -------- */
|
|
72
|
+
ModifierImpl.prototype.background = function (color) {
|
|
73
|
+
var resolved = typeof color === "string"
|
|
74
|
+
? color
|
|
75
|
+
: resolveColor(color);
|
|
76
|
+
return this.then(new ModifierImpl([{ style: "background:".concat(resolved, ";") }]));
|
|
77
|
+
};
|
|
78
|
+
ModifierImpl.prototype.border = function (width, color, shape) {
|
|
79
|
+
if (width <= 0)
|
|
159
80
|
return this;
|
|
160
|
-
}
|
|
161
|
-
var resolved;
|
|
162
|
-
if (typeof value === "number") {
|
|
163
|
-
if (isNaN(value))
|
|
164
|
-
return this;
|
|
165
|
-
resolved = "".concat(value).concat(unit);
|
|
166
|
-
}
|
|
167
|
-
else {
|
|
168
|
-
if (value.trim() === "")
|
|
169
|
-
return this;
|
|
170
|
-
resolved = value;
|
|
171
|
-
}
|
|
172
81
|
return this.then(new ModifierImpl([
|
|
173
82
|
{
|
|
174
|
-
style: "
|
|
175
|
-
}
|
|
83
|
+
style: "\n border:".concat(width, "px solid ").concat(color, ";\n ").concat(shape ? "border-radius:".concat(shape.toCssBorderRadius(), ";") : "", "\n "),
|
|
84
|
+
},
|
|
176
85
|
]));
|
|
177
86
|
};
|
|
178
|
-
ModifierImpl.prototype.
|
|
179
|
-
if (isNaN(x) || isNaN(y))
|
|
180
|
-
return this;
|
|
87
|
+
ModifierImpl.prototype.clip = function (shape) {
|
|
181
88
|
return this.then(new ModifierImpl([
|
|
182
89
|
{
|
|
183
|
-
style: "
|
|
184
|
-
}
|
|
90
|
+
style: "\n border-radius:".concat(shape.toCssBorderRadius(), ";\n overflow:hidden;\n "),
|
|
91
|
+
},
|
|
185
92
|
]));
|
|
186
93
|
};
|
|
187
|
-
|
|
94
|
+
/* -------- posicionamiento semántico -------- */
|
|
95
|
+
ModifierImpl.prototype.align = function (alignment) {
|
|
188
96
|
return this.then(new ModifierImpl([
|
|
189
97
|
{
|
|
190
|
-
|
|
191
|
-
style: "\n cursor: pointer;\n user-select: none;\n "
|
|
98
|
+
meta: { align: alignment }
|
|
192
99
|
}
|
|
193
100
|
]));
|
|
194
101
|
};
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
return this;
|
|
198
|
-
var radius = shape ? shape.toCssBorderRadius() : undefined;
|
|
102
|
+
/* -------- interacción -------- */
|
|
103
|
+
ModifierImpl.prototype.clickable = function () {
|
|
199
104
|
return this.then(new ModifierImpl([
|
|
200
105
|
{
|
|
201
|
-
|
|
202
|
-
|
|
106
|
+
className: "compose-clickable",
|
|
107
|
+
style: "cursor:pointer;user-select:none;",
|
|
108
|
+
},
|
|
203
109
|
]));
|
|
204
110
|
};
|
|
205
|
-
|
|
111
|
+
/* -------- consumo interno -------- */
|
|
206
112
|
ModifierImpl.prototype.toStyle = function () {
|
|
207
113
|
return this.entries.map(function (e) { var _a; return (_a = e.style) !== null && _a !== void 0 ? _a : ""; }).join("");
|
|
208
114
|
};
|
|
209
115
|
ModifierImpl.prototype.toClass = function () {
|
|
210
116
|
return this.entries.map(function (e) { var _a; return (_a = e.className) !== null && _a !== void 0 ? _a : ""; }).join(" ");
|
|
211
117
|
};
|
|
118
|
+
ModifierImpl.prototype.getMeta = function () {
|
|
119
|
+
return this.entries.reduce(function (acc, e) {
|
|
120
|
+
var _a;
|
|
121
|
+
return (__assign(__assign({}, acc), ((_a = e.meta) !== null && _a !== void 0 ? _a : {})));
|
|
122
|
+
}, {});
|
|
123
|
+
};
|
|
212
124
|
return ModifierImpl;
|
|
213
125
|
}());
|
|
214
126
|
export { ModifierImpl };
|