Abasov Akif
3 years ago
committed by
GitHub
31 changed files with 675 additions and 777 deletions
@ -0,0 +1,38 @@ |
|||||||
|
/* |
||||||
|
* Copyright 2020-2021 JetBrains s.r.o. and respective authors and developers. |
||||||
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. |
||||||
|
*/ |
||||||
|
|
||||||
|
@file:Suppress("UNUSED", "NOTHING_TO_INLINE", "FunctionName") |
||||||
|
package org.jetbrains.compose.web.css |
||||||
|
|
||||||
|
import org.w3c.dom.css.* |
||||||
|
import org.w3c.dom.css.StyleSheet |
||||||
|
|
||||||
|
inline val StyleSheet.cssRules |
||||||
|
get() = this.asDynamic().cssRules.unsafeCast<CSSRuleList>() |
||||||
|
|
||||||
|
|
||||||
|
inline fun StyleSheet.deleteRule(index: Int) { |
||||||
|
this.asDynamic().deleteRule(index) |
||||||
|
} |
||||||
|
|
||||||
|
fun StyleSheet.insertRule(cssRule: String, index: Int? = null): Int { |
||||||
|
return if (index != null) { |
||||||
|
this.asDynamic().insertRule(cssRule, index).unsafeCast<Int>() |
||||||
|
} else { |
||||||
|
this.asDynamic().insertRule(cssRule).unsafeCast<Int>() |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
inline operator fun CSSRuleList.get(index: Int): CSSRule { |
||||||
|
return this.asDynamic()[index].unsafeCast<CSSRule>() |
||||||
|
} |
||||||
|
|
||||||
|
@Suppress("NOTHING_TO_INLINE") |
||||||
|
inline fun <T : Any> jsObject(): T = |
||||||
|
js("({})") |
||||||
|
|
||||||
|
inline fun <T : Any> jsObject(builder: T.() -> Unit): T = |
||||||
|
jsObject<T>().apply(builder) |
@ -1,299 +0,0 @@ |
|||||||
@file:Suppress("UNUSED", "NOTHING_TO_INLINE") |
|
||||||
package org.jetbrains.compose.web.css |
|
||||||
|
|
||||||
import kotlinx.browser.window |
|
||||||
import org.w3c.dom.DOMMatrix |
|
||||||
import org.w3c.dom.DOMMatrixReadOnly |
|
||||||
import org.w3c.dom.Element |
|
||||||
import org.w3c.dom.css.CSSRule |
|
||||||
import org.w3c.dom.css.CSSRuleList |
|
||||||
import org.w3c.dom.css.CSSStyleRule |
|
||||||
import org.w3c.dom.css.ElementCSSInlineStyle |
|
||||||
import org.w3c.dom.css.StyleSheet |
|
||||||
|
|
||||||
inline val StyleSheet.cssRules |
|
||||||
get() = this.asDynamic().cssRules.unsafeCast<CSSRuleList>() |
|
||||||
|
|
||||||
inline fun StyleSheet.deleteRule(index: Int) { |
|
||||||
this.asDynamic().deleteRule(index) |
|
||||||
} |
|
||||||
|
|
||||||
inline val CSSStyleRule.styleMap |
|
||||||
get() = this.asDynamic().styleMap.unsafeCast<StylePropertyMap>() |
|
||||||
|
|
||||||
inline operator fun CSSRuleList.get(index: Int): CSSRule { |
|
||||||
return this.asDynamic()[index].unsafeCast<CSSRule>() |
|
||||||
} |
|
||||||
|
|
||||||
fun StyleSheet.insertRule(cssRule: String, index: Int? = null): Int { |
|
||||||
return if (index != null) { |
|
||||||
this.asDynamic().insertRule(cssRule, index).unsafeCast<Int>() |
|
||||||
} else { |
|
||||||
this.asDynamic().insertRule(cssRule).unsafeCast<Int>() |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
val ElementCSSInlineStyle.attributeStyleMap |
|
||||||
get() = this.asDynamic().attributeStyleMap.unsafeCast<StylePropertyMap>() |
|
||||||
|
|
||||||
external interface CSSStyleValue : StylePropertyValue |
|
||||||
|
|
||||||
@JsName("CSSStyleValue") |
|
||||||
open external class CSSStyleValueJS : CSSStyleValue { |
|
||||||
companion object { |
|
||||||
fun parse(property: String, cssText: String): CSSStyleValue |
|
||||||
fun parseAll(property: String, cssText: String): Array<CSSStyleValue> |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
external class CSSVariableReferenceValue( |
|
||||||
variable: String, |
|
||||||
fallback: CSSUnparsedValue? = definedExternally |
|
||||||
) { |
|
||||||
val variable: String |
|
||||||
val fallback: CSSUnparsedValue? |
|
||||||
} |
|
||||||
|
|
||||||
// type CSSUnparsedSegment = String | CSSVariableReferenceValue |
|
||||||
interface CSSUnparsedSegment { |
|
||||||
companion object { |
|
||||||
operator fun invoke(value: String) = value.unsafeCast<CSSUnparsedSegment>() |
|
||||||
operator fun invoke(value: CSSVariableReferenceValue) = |
|
||||||
value.unsafeCast<CSSUnparsedSegment>() |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
fun CSSUnparsedSegment.asString() = this.asDynamic() as? String |
|
||||||
fun CSSUnparsedSegment.asCSSVariableReferenceValue() = |
|
||||||
this.asDynamic() as? CSSVariableReferenceValue |
|
||||||
|
|
||||||
external class CSSUnparsedValue(members: Array<CSSUnparsedSegment>) : CSSStyleValue { |
|
||||||
// TODO: [Symbol.iterator]() : IterableIterator<CSSUnparsedSegment> |
|
||||||
fun forEach(handler: (CSSUnparsedSegment) -> Unit) |
|
||||||
val length: Int |
|
||||||
|
|
||||||
// readonly [index: number]: CSSUnparsedSegment |
|
||||||
operator fun get(index: Int): CSSUnparsedSegment |
|
||||||
operator fun set(index: Int, value: CSSUnparsedSegment) |
|
||||||
} |
|
||||||
|
|
||||||
// type CSSNumberish = number | CSSNumericValue |
|
||||||
interface CSSNumberish { |
|
||||||
companion object { |
|
||||||
operator fun invoke(value: Number) = value.unsafeCast<CSSNumberish>() |
|
||||||
operator fun invoke(value: CSSNumericValue) = |
|
||||||
value.unsafeCast<CSSNumberish>() |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
fun CSSNumberish.asNumber() = this.asDynamic() as? Number |
|
||||||
fun CSSNumberish.asCSSNumericValue(): CSSNumericValue? = this.asDynamic() as? CSSNumericValue |
|
||||||
|
|
||||||
// declare enum CSSNumericBaseType { |
|
||||||
// 'length', |
|
||||||
// 'angle', |
|
||||||
// 'time', |
|
||||||
// 'frequency', |
|
||||||
// 'resolution', |
|
||||||
// 'flex', |
|
||||||
// 'percent', |
|
||||||
// } |
|
||||||
enum class CSSNumericBaseType(val value: String) { |
|
||||||
@JsName("_length") |
|
||||||
length("length"), |
|
||||||
angle("angle"), |
|
||||||
time("time"), |
|
||||||
frequency("frequency"), |
|
||||||
resolution("resolution"), |
|
||||||
flex("flex"), |
|
||||||
percent("percent") |
|
||||||
} |
|
||||||
|
|
||||||
external interface CSSNumericType { |
|
||||||
val length: Number |
|
||||||
val angle: Number |
|
||||||
val time: Number |
|
||||||
val frequency: Number |
|
||||||
val resolution: Number |
|
||||||
val flex: Number |
|
||||||
val percent: Number |
|
||||||
// percentHint: CSSNumericBaseType |
|
||||||
} |
|
||||||
|
|
||||||
val CSSNumericType.percentHint |
|
||||||
get() = CSSNumericBaseType.valueOf(this.asDynamic().percentHint) |
|
||||||
// set(value) { this.asDynamic().percentHint = value.value } |
|
||||||
|
|
||||||
external interface CSSNumericValue : CSSStyleValue |
|
||||||
|
|
||||||
// declare enum CSSMathOperator { |
|
||||||
// 'sum', |
|
||||||
// 'product', |
|
||||||
// 'negate', |
|
||||||
// 'invert', |
|
||||||
// 'min', |
|
||||||
// 'max', |
|
||||||
// 'clamp', |
|
||||||
// } |
|
||||||
enum class CSSMathOperator(val value: String) { |
|
||||||
sum("sum"), |
|
||||||
product("product"), |
|
||||||
negate("negate"), |
|
||||||
invert("invert"), |
|
||||||
min("min"), |
|
||||||
max("max"), |
|
||||||
clamp("clamp") |
|
||||||
} |
|
||||||
|
|
||||||
open external class CSSMathValue : CSSNumericValue |
|
||||||
|
|
||||||
val CSSMathValue.operator |
|
||||||
get() = CSSMathOperator.valueOf(this.asDynamic().operator) |
|
||||||
// set(value) { this.asDynamic().operator = value.value } |
|
||||||
|
|
||||||
external class CSSMathSum(vararg args: CSSNumberish) : CSSMathValue { |
|
||||||
val values: CSSNumericArray |
|
||||||
} |
|
||||||
|
|
||||||
external class CSSMathProduct(vararg args: CSSNumberish) : CSSMathValue { |
|
||||||
val values: CSSNumericArray |
|
||||||
} |
|
||||||
|
|
||||||
external class CSSMathNegate(arg: CSSNumberish) : CSSMathValue { |
|
||||||
val value: CSSNumericValue |
|
||||||
} |
|
||||||
|
|
||||||
external class CSSMathInvert(arg: CSSNumberish) : CSSMathValue { |
|
||||||
val value: CSSNumericValue |
|
||||||
} |
|
||||||
|
|
||||||
external class CSSMathMin(vararg args: CSSNumberish) : CSSMathValue { |
|
||||||
val values: CSSNumericArray |
|
||||||
} |
|
||||||
|
|
||||||
external class CSSMathMax(vararg args: CSSNumberish) : CSSMathValue { |
|
||||||
val values: CSSNumericArray |
|
||||||
} |
|
||||||
|
|
||||||
external class CSSNumericArray { |
|
||||||
// TODO: [Symbol.iterator]() : IterableIterator<CSSNumericValue> |
|
||||||
fun forEach(handler: (CSSNumericValue) -> Unit) |
|
||||||
val length: Int |
|
||||||
|
|
||||||
// readonly [index: number]: CSSNumericValue |
|
||||||
operator fun get(index: Int): CSSNumericValue |
|
||||||
} |
|
||||||
|
|
||||||
external class CSSTransformValue(transforms: Array<CSSTransformComponent>) : CSSStyleValue { |
|
||||||
// [Symbol.iterator]() : IterableIterator<CSSTransformComponent> |
|
||||||
fun forEach(handler: (CSSTransformComponent) -> Unit) |
|
||||||
val length: Int |
|
||||||
|
|
||||||
// [index: number]: CSSTransformComponent |
|
||||||
operator fun get(index: Int): CSSTransformComponent |
|
||||||
operator fun set(index: Int, value: CSSTransformComponent) |
|
||||||
val is2D: Boolean |
|
||||||
fun toMatrix(): DOMMatrix |
|
||||||
} |
|
||||||
|
|
||||||
open external class CSSTransformComponent { |
|
||||||
val is2D: Boolean |
|
||||||
fun toMatrix(): DOMMatrix |
|
||||||
// toString() : string |
|
||||||
} |
|
||||||
|
|
||||||
external class CSSTranslate( |
|
||||||
x: CSSNumericValue, |
|
||||||
y: CSSNumericValue, |
|
||||||
z: CSSNumericValue? = definedExternally |
|
||||||
) : CSSTransformComponent { |
|
||||||
val x: CSSNumericValue |
|
||||||
val y: CSSNumericValue |
|
||||||
val z: CSSNumericValue |
|
||||||
} |
|
||||||
|
|
||||||
external class CSSRotate(angle: CSSNumericValue) : CSSTransformComponent { |
|
||||||
constructor(x: CSSNumberish, y: CSSNumberish, z: CSSNumberish, angle: CSSNumericValue) |
|
||||||
|
|
||||||
val x: CSSNumberish |
|
||||||
val y: CSSNumberish |
|
||||||
val z: CSSNumberish |
|
||||||
val angle: CSSNumericValue |
|
||||||
} |
|
||||||
|
|
||||||
external class CSSScale( |
|
||||||
x: CSSNumberish, |
|
||||||
y: CSSNumberish, |
|
||||||
z: CSSNumberish? = definedExternally |
|
||||||
) : CSSTransformComponent { |
|
||||||
val x: CSSNumberish |
|
||||||
val y: CSSNumberish |
|
||||||
val z: CSSNumberish |
|
||||||
} |
|
||||||
|
|
||||||
external class CSSSkew(ax: CSSNumericValue, ay: CSSNumericValue) : CSSTransformComponent { |
|
||||||
val ax: CSSNumericValue |
|
||||||
val ay: CSSNumericValue |
|
||||||
} |
|
||||||
|
|
||||||
external class CSSSkewX(ax: CSSNumericValue) : CSSTransformComponent { |
|
||||||
val ax: CSSNumericValue |
|
||||||
} |
|
||||||
|
|
||||||
external class CSSSkewY(ay: CSSNumericValue) : CSSTransformComponent { |
|
||||||
val ay: CSSNumericValue |
|
||||||
} |
|
||||||
|
|
||||||
/* Note that skew(x,y) is *not* the same as skewX(x) skewY(y), |
|
||||||
thus the separate interfaces for all three. */ |
|
||||||
|
|
||||||
external class CSSPerspective(length: CSSNumericValue) : CSSTransformComponent { |
|
||||||
val length: CSSNumericValue |
|
||||||
} |
|
||||||
|
|
||||||
external class CSSMatrixComponent( |
|
||||||
matrix: DOMMatrixReadOnly, |
|
||||||
options: CSSMatrixComponentOptions? = definedExternally |
|
||||||
) : CSSTransformComponent { |
|
||||||
val matrix: DOMMatrix |
|
||||||
} |
|
||||||
|
|
||||||
external interface CSSMatrixComponentOptions { |
|
||||||
val is2D: Boolean |
|
||||||
} |
|
||||||
|
|
||||||
external class CSSImageValue : CSSStyleValue |
|
||||||
|
|
||||||
open external class StylePropertyMapReadOnly { |
|
||||||
// TODO: [Symbol.iterator]() : IterableIterator<[string, CSSStyleValue[]]> |
|
||||||
|
|
||||||
fun get(property: String): CSSStyleValue? // CSSStyleValue | undefined |
|
||||||
fun getAll(property: String): Array<CSSStyleValue> |
|
||||||
fun has(property: String): Boolean |
|
||||||
val size: Number |
|
||||||
} |
|
||||||
|
|
||||||
fun StylePropertyMapReadOnly.forEach(handler: (String, Array<CSSStyleValue>) -> Unit) { |
|
||||||
this.asDynamic().forEach { entry: Array<dynamic> -> |
|
||||||
handler( |
|
||||||
entry[0].unsafeCast<String>(), |
|
||||||
entry[1].unsafeCast<Array<CSSStyleValue>>() |
|
||||||
) |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
// CSSStyleValue | string |
|
||||||
external interface StylePropertyValue |
|
||||||
|
|
||||||
external class StylePropertyMap : StylePropertyMapReadOnly { |
|
||||||
fun set(property: String, vararg values: StylePropertyValue) |
|
||||||
fun append(property: String, vararg values: StylePropertyValue) |
|
||||||
fun delete(property: String) |
|
||||||
fun clear() |
|
||||||
} |
|
||||||
|
|
||||||
inline fun Element.computedStyleMap(): StylePropertyMapReadOnly = |
|
||||||
this.asDynamic().computedStyleMap().unsafeCast<StylePropertyMapReadOnly>() |
|
||||||
|
|
||||||
@Suppress("unused") |
|
||||||
val cssTypedOMPolyfill = CSSTypedOMPolyfill.default(window) |
|
@ -0,0 +1,183 @@ |
|||||||
|
@file:Suppress("Unused", "NOTHING_TO_INLINE", "NESTED_CLASS_IN_EXTERNAL_INTERFACE", "INLINE_EXTERNAL_DECLARATION", "WRONG_BODY_OF_EXTERNAL_DECLARATION", "NESTED_EXTERNAL_DECLARATION") |
||||||
|
|
||||||
|
package org.jetbrains.compose.web.css |
||||||
|
|
||||||
|
external interface StylePropertyEnum: StylePropertyString |
||||||
|
inline val StylePropertyEnum.name get() = this.unsafeCast<String>() |
||||||
|
inline val StylePropertyEnum.value get() = this.unsafeCast<String>() |
||||||
|
|
||||||
|
external interface LineStyle: StylePropertyEnum { |
||||||
|
external companion object { |
||||||
|
inline val None get() = LineStyle("none") |
||||||
|
inline val Hidden get() = LineStyle("hidden") |
||||||
|
inline val Dotted get() = LineStyle("dotted") |
||||||
|
inline val Dashed get() = LineStyle("dashed") |
||||||
|
inline val Solid get() = LineStyle("solid") |
||||||
|
inline val Double get() = LineStyle("double") |
||||||
|
inline val Groove get() = LineStyle("groove") |
||||||
|
inline val Ridge get() = LineStyle("ridge") |
||||||
|
inline val Inset get() = LineStyle("inset") |
||||||
|
inline val Outset get() = LineStyle("outset") |
||||||
|
} |
||||||
|
} |
||||||
|
inline fun LineStyle(value: String) = value.unsafeCast<LineStyle>() |
||||||
|
|
||||||
|
external interface DisplayStyle: StylePropertyEnum { |
||||||
|
external companion object { |
||||||
|
inline val Block get() = DisplayStyle("block") |
||||||
|
inline val Inline get() = DisplayStyle("inline") |
||||||
|
inline val InlineBlock get() = DisplayStyle("inline-block") |
||||||
|
inline val Flex get() = DisplayStyle("flex") |
||||||
|
inline val LegacyInlineFlex get() = DisplayStyle("inline-flex") |
||||||
|
inline val Grid get() = DisplayStyle("grid") |
||||||
|
inline val LegacyInlineGrid get() = DisplayStyle("inline-grid") |
||||||
|
inline val FlowRoot get() = DisplayStyle("flow-root") |
||||||
|
|
||||||
|
inline val None get() = DisplayStyle("none") |
||||||
|
inline val Contents get() = DisplayStyle("contents") |
||||||
|
|
||||||
|
// TODO(shabunc): This properties behave them iconsistenly in both Chrome and Firefox so I turned the off so far |
||||||
|
// BlockFlow("block flow") |
||||||
|
// InlineFlow("inline flow") |
||||||
|
// InlineFlowRoot("inline flow-root") |
||||||
|
// BlocklFlex("block flex") |
||||||
|
// InlineFlex("inline flex") |
||||||
|
// BlockGrid("block grid") |
||||||
|
// InlineGrid("inline grid") |
||||||
|
// BlockFlowRoot("block flow-root") |
||||||
|
|
||||||
|
inline val Table get() = DisplayStyle("table") |
||||||
|
inline val TableRow get() = DisplayStyle("table-row") |
||||||
|
inline val ListItem get() = DisplayStyle("list-item") |
||||||
|
|
||||||
|
inline val Inherit get() = DisplayStyle("inherit") |
||||||
|
inline val Initial get() = DisplayStyle("initial") |
||||||
|
inline val Unset get() = DisplayStyle("unset") |
||||||
|
} |
||||||
|
} |
||||||
|
inline fun DisplayStyle(value: String) = value.unsafeCast<DisplayStyle>() |
||||||
|
|
||||||
|
external interface FlexDirection: StylePropertyEnum { |
||||||
|
companion object { |
||||||
|
inline val Row get() = FlexDirection("row") |
||||||
|
inline val RowReverse get() = FlexDirection("row-reverse") |
||||||
|
inline val Column get() = FlexDirection("column") |
||||||
|
inline val ColumnReverse get() = FlexDirection("column-reverse") |
||||||
|
} |
||||||
|
} |
||||||
|
inline fun FlexDirection(value: String) = value.unsafeCast<FlexDirection>() |
||||||
|
|
||||||
|
external interface FlexWrap: StylePropertyEnum { |
||||||
|
companion object { |
||||||
|
inline val Wrap get() = FlexWrap("wrap") |
||||||
|
inline val Nowrap get() = FlexWrap("nowrap") |
||||||
|
inline val WrapReverse get() = FlexWrap("wrap-reverse") |
||||||
|
} |
||||||
|
} |
||||||
|
inline fun FlexWrap(value: String) = value.unsafeCast<FlexWrap>() |
||||||
|
|
||||||
|
external interface JustifyContent: StylePropertyEnum { |
||||||
|
companion object { |
||||||
|
inline val Center get() = JustifyContent("center") |
||||||
|
inline val Start get() = JustifyContent("start") |
||||||
|
inline val End get() = JustifyContent("end") |
||||||
|
inline val FlexStart get() = JustifyContent("flex-start") |
||||||
|
inline val FlexEnd get() = JustifyContent("flex-end") |
||||||
|
inline val Left get() = JustifyContent("left") |
||||||
|
inline val Right get() = JustifyContent("right") |
||||||
|
inline val Normal get() = JustifyContent("normal") |
||||||
|
inline val SpaceBetween get() = JustifyContent("space-between") |
||||||
|
inline val SpaceAround get() = JustifyContent("space-around") |
||||||
|
inline val SpaceEvenly get() = JustifyContent("space-evenly") |
||||||
|
inline val Stretch get() = JustifyContent("stretch") |
||||||
|
inline val Inherit get() = JustifyContent("inherit") |
||||||
|
inline val Initial get() = JustifyContent("initial") |
||||||
|
inline val Unset get() = JustifyContent("unset") |
||||||
|
inline val SafeCenter get() = JustifyContent("safe center") |
||||||
|
inline val UnsafeCenter get() = JustifyContent("unsafe center") |
||||||
|
} |
||||||
|
} |
||||||
|
inline fun JustifyContent(value: String) = value.unsafeCast<JustifyContent>() |
||||||
|
|
||||||
|
external interface AlignSelf: StylePropertyEnum { |
||||||
|
companion object { |
||||||
|
inline val Auto get() = AlignSelf("auto") |
||||||
|
inline val Normal get() = AlignSelf("normal") |
||||||
|
inline val Center get() = AlignSelf("center") |
||||||
|
inline val Start get() = AlignSelf("start") |
||||||
|
inline val End get() = AlignSelf("end") |
||||||
|
inline val SelfStart get() = AlignSelf("self-start") |
||||||
|
inline val SelfEnd get() = AlignSelf("self-end") |
||||||
|
inline val FlexStart get() = AlignSelf("flex-start") |
||||||
|
inline val FlexEnd get() = AlignSelf("flex-end") |
||||||
|
inline val Baseline get() = AlignSelf("baseline") |
||||||
|
// FirstBaseline("first baseline") |
||||||
|
// LastBaseline("last baseline") |
||||||
|
inline val Stretch get() = AlignSelf("stretch") |
||||||
|
inline val SafeCenter get() = AlignSelf("safe center") |
||||||
|
inline val UnsafeCenter get() = AlignSelf("unsafe center") |
||||||
|
inline val Inherit get() = AlignSelf("inherit") |
||||||
|
inline val Initial get() = AlignSelf("initial") |
||||||
|
inline val Unset get() = AlignSelf("unset") |
||||||
|
} |
||||||
|
} |
||||||
|
inline fun AlignSelf(value: String) = value.unsafeCast<AlignSelf>() |
||||||
|
|
||||||
|
external interface AlignItems: StylePropertyEnum { |
||||||
|
companion object { |
||||||
|
inline val Normal get() = AlignItems("normal") |
||||||
|
inline val Stretch get() = AlignItems("stretch") |
||||||
|
inline val Center get() = AlignItems("center") |
||||||
|
inline val Start get() = AlignItems("start") |
||||||
|
inline val End get() = AlignItems("end") |
||||||
|
inline val FlexStart get() = AlignItems("flex-start") |
||||||
|
inline val FlexEnd get() = AlignItems("flex-end") |
||||||
|
inline val Baseline get() = AlignItems("baseline") |
||||||
|
// FirstBaseline("first baseline") |
||||||
|
// LastBaseline("last baseline") |
||||||
|
inline val SafeCenter get() = AlignItems("safe center") |
||||||
|
inline val UnsafeCenter get() = AlignItems("unsafe center") |
||||||
|
|
||||||
|
inline val Inherit get() = AlignItems("inherit") |
||||||
|
inline val Initial get() = AlignItems("initial") |
||||||
|
inline val Unset get() = AlignItems("unset") |
||||||
|
} |
||||||
|
} |
||||||
|
inline fun AlignItems(value: String) = value.unsafeCast<AlignItems>() |
||||||
|
|
||||||
|
external interface AlignContent: StylePropertyEnum { |
||||||
|
companion object { |
||||||
|
inline val Center get() = AlignContent("center") |
||||||
|
inline val Start get() = AlignContent("start") |
||||||
|
inline val End get() = AlignContent("end") |
||||||
|
inline val FlexStart get() = AlignContent("flex-start") |
||||||
|
inline val FlexEnd get() = AlignContent("flex-end") |
||||||
|
inline val Baseline get() = AlignContent("baseline") |
||||||
|
// FirstBaseline("first baseline") |
||||||
|
// LastBaseline("last baseline") |
||||||
|
inline val SafeCenter get() = AlignContent("safe center") |
||||||
|
inline val UnsafeCenter get() = AlignContent("unsafe center") |
||||||
|
inline val SpaceBetween get() = AlignContent("space-between") |
||||||
|
inline val SpaceAround get() = AlignContent("space-around") |
||||||
|
inline val SpaceEvenly get() = AlignContent("space-evenly") |
||||||
|
inline val Stretch get() = AlignContent("stretch") |
||||||
|
|
||||||
|
inline val Inherit get() = AlignContent("inherit") |
||||||
|
inline val Initial get() = AlignContent("initial") |
||||||
|
inline val Unset get() = AlignContent("unset") |
||||||
|
} |
||||||
|
} |
||||||
|
inline fun AlignContent(value: String) = value.unsafeCast<AlignContent>() |
||||||
|
|
||||||
|
external interface Position: StylePropertyEnum { |
||||||
|
companion object { |
||||||
|
inline val Static get() = Position("static") |
||||||
|
inline val Relative get() = Position("relative") |
||||||
|
inline val Absolute get() = Position("absolute") |
||||||
|
inline val Sticky get() = Position("sticky") |
||||||
|
inline val Fixed get() = Position("fixed") |
||||||
|
} |
||||||
|
} |
||||||
|
inline fun Position(value: String) = value.unsafeCast<Position>() |
||||||
|
|
||||||
|
typealias LanguageCode = String |
@ -1,15 +0,0 @@ |
|||||||
@file:Suppress("UNUSED") |
|
||||||
package org.jetbrains.compose.web.css |
|
||||||
|
|
||||||
interface CSSAutoValue : StylePropertyValue |
|
||||||
|
|
||||||
val auto = "auto".unsafeCast<CSSAutoValue>() |
|
||||||
|
|
||||||
enum class Direction { |
|
||||||
rtl, |
|
||||||
ltr; |
|
||||||
|
|
||||||
override fun toString(): String = this.name |
|
||||||
} |
|
||||||
|
|
||||||
typealias LanguageCode = String |
|
@ -0,0 +1,12 @@ |
|||||||
|
/* |
||||||
|
* Copyright 2020-2021 JetBrains s.r.o. and respective authors and developers. |
||||||
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. |
||||||
|
*/ |
||||||
|
|
||||||
|
@file:Suppress("NOTHING_TO_INLINE") |
||||||
|
|
||||||
|
package org.jetbrains.compose.web.css |
||||||
|
|
||||||
|
external interface CSSKeywordValue : CSSStyleValue |
||||||
|
|
||||||
|
inline fun CSSKeywordValue(value: String): CSSKeywordValue = CSSStyleValue(value).unsafeCast<CSSKeywordValue>() |
@ -0,0 +1,14 @@ |
|||||||
|
/* |
||||||
|
* Copyright 2020-2021 JetBrains s.r.o. and respective authors and developers. |
||||||
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. |
||||||
|
*/ |
||||||
|
|
||||||
|
package org.jetbrains.compose.web.css |
||||||
|
|
||||||
|
operator fun <T: CSSUnit> CSSSizeValue<T>.times(num: Number): CSSSizeValue<T> = CSSUnitValueTyped(value * num.toFloat(), unit) |
||||||
|
operator fun <T: CSSUnit> Number.times(unit: CSSSizeValue<T>): CSSSizeValue<T> = CSSUnitValueTyped(unit.value * toFloat(), unit.unit) |
||||||
|
|
||||||
|
operator fun <T: CSSUnit> CSSSizeValue<T>.div(num: Number): CSSSizeValue<T> = CSSUnitValueTyped(value / num.toFloat(), unit) |
||||||
|
|
||||||
|
operator fun <T: CSSUnit> CSSSizeValue<T>.plus(b: CSSSizeValue<T>): CSSSizeValue<T> = CSSUnitValueTyped(value + b.value, unit) |
||||||
|
operator fun <T: CSSUnit> CSSSizeValue<T>.minus(b: CSSSizeValue<T>): CSSSizeValue<T> = CSSUnitValueTyped(value - b.value, unit) |
@ -1,15 +0,0 @@ |
|||||||
package org.jetbrains.compose.web.css |
|
||||||
|
|
||||||
import org.w3c.dom.Window |
|
||||||
|
|
||||||
@JsModule("css-typed-om") |
|
||||||
@JsNonModule |
|
||||||
abstract external class CSSTypedOMPolyfill { |
|
||||||
companion object { |
|
||||||
fun default(window: Window) |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
fun StylePropertyMap.clear() { |
|
||||||
throw AssertionError("StylePropertyMap::clear isn't polyfilled") |
|
||||||
} |
|
@ -0,0 +1,27 @@ |
|||||||
|
/* |
||||||
|
* Copyright 2020-2021 JetBrains s.r.o. and respective authors and developers. |
||||||
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. |
||||||
|
*/ |
||||||
|
|
||||||
|
@file:Suppress("UNUSED", "NOTHING_TO_INLINE", "FunctionName") |
||||||
|
package org.jetbrains.compose.web.css |
||||||
|
|
||||||
|
external interface StylePropertyValue |
||||||
|
|
||||||
|
external interface StylePropertyNumber: StylePropertyValue |
||||||
|
external interface StylePropertyString: StylePropertyValue |
||||||
|
|
||||||
|
inline fun StylePropertyValue(value: String): StylePropertyString = value.unsafeCast<StylePropertyString>() |
||||||
|
inline fun StylePropertyValue(value: Number): StylePropertyNumber = value.unsafeCast<StylePropertyNumber>() |
||||||
|
|
||||||
|
fun StylePropertyValue.asString(): String? = if (jsTypeOf(this) == "string") this.unsafeCast<String>() else null |
||||||
|
|
||||||
|
fun StylePropertyValue.asNumber(): Number? = if (jsTypeOf(this) == "number") this.unsafeCast<Number>() else null |
||||||
|
|
||||||
|
fun StylePropertyValue.asCSSStyleValue(): CSSStyleValue? = if (jsTypeOf(this) == "object") this.unsafeCast<CSSStyleValue>() else null |
||||||
|
|
||||||
|
external interface CSSStyleValue: StylePropertyValue { |
||||||
|
override fun toString(): String |
||||||
|
} |
||||||
|
|
||||||
|
inline fun CSSStyleValue(value: String): CSSStyleValue = StylePropertyValue(value).unsafeCast<CSSStyleValue>() |
@ -0,0 +1,14 @@ |
|||||||
|
/* |
||||||
|
* Copyright 2020-2021 JetBrains s.r.o. and respective authors and developers. |
||||||
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. |
||||||
|
*/ |
||||||
|
|
||||||
|
package org.jetbrains.compose.web.css.keywords |
||||||
|
|
||||||
|
import org.jetbrains.compose.web.css.CSSKeywordValue |
||||||
|
|
||||||
|
external interface CSSAutoKeyword : CSSKeywordValue |
||||||
|
|
||||||
|
inline val auto: CSSAutoKeyword |
||||||
|
get() = CSSKeywordValue("auto").unsafeCast<CSSAutoKeyword>() |
||||||
|
|
@ -0,0 +1,116 @@ |
|||||||
|
package org.jetbrains.compose.web.core.tests |
||||||
|
|
||||||
|
import org.jetbrains.compose.web.css.* |
||||||
|
|
||||||
|
fun DisplayStyle.Companion.values() = listOf( |
||||||
|
DisplayStyle.Block, |
||||||
|
DisplayStyle.Inline, |
||||||
|
DisplayStyle.InlineBlock, |
||||||
|
DisplayStyle.Flex, |
||||||
|
DisplayStyle.LegacyInlineFlex, |
||||||
|
DisplayStyle.Grid, |
||||||
|
DisplayStyle.LegacyInlineGrid, |
||||||
|
DisplayStyle.FlowRoot, |
||||||
|
DisplayStyle.None, |
||||||
|
DisplayStyle.Contents, |
||||||
|
DisplayStyle.Table, |
||||||
|
DisplayStyle.TableRow, |
||||||
|
DisplayStyle.ListItem, |
||||||
|
DisplayStyle.Inherit, |
||||||
|
DisplayStyle.Initial, |
||||||
|
DisplayStyle.Unset |
||||||
|
) |
||||||
|
|
||||||
|
fun FlexDirection.Companion.values() = listOf( |
||||||
|
FlexDirection.Row, |
||||||
|
FlexDirection.RowReverse, |
||||||
|
FlexDirection.Column, |
||||||
|
FlexDirection.ColumnReverse |
||||||
|
) |
||||||
|
|
||||||
|
fun FlexWrap.Companion.values() = listOf( |
||||||
|
FlexWrap.Wrap, |
||||||
|
FlexWrap.Nowrap, |
||||||
|
FlexWrap.WrapReverse |
||||||
|
) |
||||||
|
|
||||||
|
fun JustifyContent.Companion.values() = listOf( |
||||||
|
JustifyContent.Center, |
||||||
|
JustifyContent.Start, |
||||||
|
JustifyContent.End, |
||||||
|
JustifyContent.FlexStart, |
||||||
|
JustifyContent.FlexEnd, |
||||||
|
JustifyContent.Left, |
||||||
|
JustifyContent.Right, |
||||||
|
JustifyContent.Normal, |
||||||
|
JustifyContent.SpaceBetween, |
||||||
|
JustifyContent.SpaceAround, |
||||||
|
JustifyContent.SpaceEvenly, |
||||||
|
JustifyContent.Stretch, |
||||||
|
JustifyContent.Inherit, |
||||||
|
JustifyContent.Initial, |
||||||
|
JustifyContent.Unset, |
||||||
|
JustifyContent.SafeCenter, |
||||||
|
JustifyContent.UnsafeCenter |
||||||
|
) |
||||||
|
|
||||||
|
fun AlignSelf.Companion.values() = listOf( |
||||||
|
AlignSelf.Auto, |
||||||
|
AlignSelf.Normal, |
||||||
|
AlignSelf.Center, |
||||||
|
AlignSelf.Start, |
||||||
|
AlignSelf.End, |
||||||
|
AlignSelf.SelfStart, |
||||||
|
AlignSelf.SelfEnd, |
||||||
|
AlignSelf.FlexStart, |
||||||
|
AlignSelf.FlexEnd, |
||||||
|
AlignSelf.Baseline, |
||||||
|
AlignSelf.Stretch, |
||||||
|
AlignSelf.SafeCenter, |
||||||
|
AlignSelf.UnsafeCenter, |
||||||
|
AlignSelf.Inherit, |
||||||
|
AlignSelf.Initial, |
||||||
|
AlignSelf.Unset |
||||||
|
) |
||||||
|
|
||||||
|
fun AlignItems.Companion.values() = listOf( |
||||||
|
AlignItems.Normal, |
||||||
|
AlignItems.Stretch, |
||||||
|
AlignItems.Center, |
||||||
|
AlignItems.Start, |
||||||
|
AlignItems.End, |
||||||
|
AlignItems.FlexStart, |
||||||
|
AlignItems.FlexEnd, |
||||||
|
AlignItems.Baseline, |
||||||
|
AlignItems.SafeCenter, |
||||||
|
AlignItems.UnsafeCenter, |
||||||
|
AlignItems.Inherit, |
||||||
|
AlignItems.Initial, |
||||||
|
AlignItems.Unset |
||||||
|
) |
||||||
|
|
||||||
|
fun AlignContent.Companion.values() = listOf( |
||||||
|
AlignContent.Center, |
||||||
|
AlignContent.Start, |
||||||
|
AlignContent.End, |
||||||
|
AlignContent.FlexStart, |
||||||
|
AlignContent.FlexEnd, |
||||||
|
AlignContent.Baseline, |
||||||
|
AlignContent.SafeCenter, |
||||||
|
AlignContent.UnsafeCenter, |
||||||
|
AlignContent.SpaceBetween, |
||||||
|
AlignContent.SpaceAround, |
||||||
|
AlignContent.SpaceEvenly, |
||||||
|
AlignContent.Stretch, |
||||||
|
AlignContent.Inherit, |
||||||
|
AlignContent.Initial, |
||||||
|
AlignContent.Unset |
||||||
|
) |
||||||
|
|
||||||
|
fun Position.Companion.values() = listOf( |
||||||
|
Position.Static, |
||||||
|
Position.Relative, |
||||||
|
Position.Absolute, |
||||||
|
Position.Sticky, |
||||||
|
Position.Fixed |
||||||
|
) |
Loading…
Reference in new issue