mirror of
https://github.com/hariroshan/elm-native-library.git
synced 2025-01-07 17:27:48 +03:00
added prefixing within constants
This commit is contained in:
parent
457bc16bb6
commit
43a71aa26e
@ -9,6 +9,9 @@ let dashed: string => string = %raw(`
|
||||
return str.replace(/[A-Z]/g, m => "-" + m.toLowerCase());
|
||||
}
|
||||
`)
|
||||
|
||||
let prefixWithBind = arr => Belt.Array.concat(arr, arr->Belt.Array.map(x => `bind-${x}`))
|
||||
|
||||
/* copy(Array.from(temp1.children).map(x => x.innerText).filter(x => !(x.startsWith('_') || x.endsWith("Event"))).filter(x => !textBase.includes(x))) */
|
||||
let view: array<string> =
|
||||
[
|
||||
@ -126,16 +129,21 @@ let view: array<string> =
|
||||
"visibility",
|
||||
"width",
|
||||
"key",
|
||||
]->Belt.Array.map(dashed)
|
||||
]
|
||||
->Belt.Array.map(dashed)
|
||||
->prefixWithBind
|
||||
|
||||
let paddings: array<string> =
|
||||
["padding", "paddingBottom", "paddingLeft", "paddingRight", "paddingTop"]->Belt.Array.map(dashed)
|
||||
["padding", "paddingBottom", "paddingLeft", "paddingRight", "paddingTop"]
|
||||
->Belt.Array.map(dashed)
|
||||
->prefixWithBind
|
||||
->prefixWithBind
|
||||
|
||||
let layoutBase: array<string> =
|
||||
[
|
||||
view,
|
||||
paddings,
|
||||
["clipToBounds", "isPassThroughParentEnabled"]->Belt.Array.map(dashed),
|
||||
["clipToBounds", "isPassThroughParentEnabled"]->Belt.Array.map(dashed)->prefixWithBind,
|
||||
]->Belt.Array.concatMany
|
||||
|
||||
let textBase: array<string> =
|
||||
@ -157,33 +165,35 @@ let textBase: array<string> =
|
||||
"textTransform",
|
||||
"whiteSpace",
|
||||
"textWrap",
|
||||
]->Belt.Array.map(dashed),
|
||||
]
|
||||
->Belt.Array.map(dashed)
|
||||
->prefixWithBind,
|
||||
]->Belt.Array.concatMany
|
||||
|
||||
let dockLayout: array<string> =
|
||||
[layoutBase, ["stretchLastChild"]->Belt.Array.map(dashed)]->Belt.Array.concatMany
|
||||
[layoutBase, ["stretchLastChild"]->Belt.Array.map(dashed)->prefixWithBind]->Belt.Array.concatMany
|
||||
|
||||
let gridLayout: array<string> =
|
||||
[
|
||||
layoutBase,
|
||||
["columns", "rows"]->Belt.Array.map(dashed),
|
||||
]->Belt.Array.concatMany
|
||||
[layoutBase, ["columns", "rows"]->Belt.Array.map(dashed)->prefixWithBind]->Belt.Array.concatMany
|
||||
|
||||
let stackLayout: array<string> =
|
||||
[layoutBase, ["orientation"]->Belt.Array.map(dashed)]->Belt.Array.concatMany
|
||||
[layoutBase, ["orientation"]->Belt.Array.map(dashed)->prefixWithBind]->Belt.Array.concatMany
|
||||
|
||||
let wrapLayout: array<string> =
|
||||
[stackLayout, ["itemHeight", "itemWidth"]->Belt.Array.map(dashed)]->Belt.Array.concatMany
|
||||
[
|
||||
stackLayout,
|
||||
["itemHeight", "itemWidth"]->Belt.Array.map(dashed)->prefixWithBind,
|
||||
]->Belt.Array.concatMany
|
||||
|
||||
let flexboxLayout: array<string> =
|
||||
[
|
||||
layoutBase,
|
||||
["alignContent", "alignItems", "flexDirection", "flexWrap", "justifyContent"]->Belt.Array.map(
|
||||
dashed,
|
||||
),
|
||||
["alignContent", "alignItems", "flexDirection", "flexWrap", "justifyContent"]
|
||||
->Belt.Array.map(dashed)
|
||||
->prefixWithBind,
|
||||
]->Belt.Array.concatMany
|
||||
|
||||
let button = [textBase, ["textWrap"]->Belt.Array.map(dashed)]->Belt.Array.concatMany
|
||||
let button = [textBase, ["textWrap"]->Belt.Array.map(dashed)->prefixWithBind]->Belt.Array.concatMany
|
||||
|
||||
let frameBase =
|
||||
[
|
||||
@ -194,7 +204,9 @@ let frameBase =
|
||||
"transition",
|
||||
"defaultAnimatedNavigation",
|
||||
"defaultTransition",
|
||||
]->Belt.Array.map(dashed),
|
||||
]
|
||||
->Belt.Array.map(dashed)
|
||||
->prefixWithBind,
|
||||
]->Belt.Array.concatMany
|
||||
|
||||
let pageBase =
|
||||
@ -207,35 +219,33 @@ let pageBase =
|
||||
"backgroundSpanUnderStatusBar",
|
||||
"enableSwipeBackNavigation",
|
||||
"statusBarStyle",
|
||||
]->Belt.Array.map(dashed),
|
||||
]
|
||||
->Belt.Array.map(dashed)
|
||||
->prefixWithBind,
|
||||
]->Belt.Array.concatMany
|
||||
|
||||
let activityIndicator = [view, ["busy"]->Belt.Array.map(dashed)]->Belt.Array.concatMany
|
||||
let activityIndicator =
|
||||
[view, ["busy"]->Belt.Array.map(dashed)->prefixWithBind]->Belt.Array.concatMany
|
||||
|
||||
/* for simplicity using view instead of viewBase */
|
||||
let formattedString =
|
||||
[
|
||||
view,
|
||||
["fontStyle", "style", "fontFamily", "fontWeight"]->Belt.Array.map(dashed),
|
||||
["fontStyle", "style", "fontFamily", "fontWeight"]->Belt.Array.map(dashed)->prefixWithBind,
|
||||
]->Belt.Array.concatMany
|
||||
|
||||
let span = [formattedString, ["text"]->Belt.Array.map(dashed)]->Belt.Array.concatMany
|
||||
let span =
|
||||
[formattedString, ["text"]->Belt.Array.map(dashed)->prefixWithBind]->Belt.Array.concatMany
|
||||
|
||||
let datePicker =
|
||||
[
|
||||
view,
|
||||
[
|
||||
"date",
|
||||
"day",
|
||||
"iosPreferredDatePickerStyle",
|
||||
"maxDate",
|
||||
"minDate",
|
||||
"month",
|
||||
"year",
|
||||
]->Belt.Array.map(dashed),
|
||||
["date", "day", "iosPreferredDatePickerStyle", "maxDate", "minDate", "month", "year"]
|
||||
->Belt.Array.map(dashed)
|
||||
->prefixWithBind,
|
||||
]->Belt.Array.concatMany
|
||||
|
||||
let htmlView = [view, ["html"]->Belt.Array.map(dashed)]->Belt.Array.concatMany
|
||||
let htmlView = [view, ["html"]->Belt.Array.map(dashed)->prefixWithBind]->Belt.Array.concatMany
|
||||
|
||||
let image =
|
||||
[
|
||||
@ -249,12 +259,16 @@ let image =
|
||||
"src",
|
||||
"stretch",
|
||||
"tintColor",
|
||||
]->Belt.Array.map(dashed),
|
||||
]
|
||||
->Belt.Array.map(dashed)
|
||||
->prefixWithBind,
|
||||
]->Belt.Array.concatMany
|
||||
|
||||
let listPicker = [view, ["selectedIndex"]->Belt.Array.map(dashed)]->Belt.Array.concatMany
|
||||
let listPicker =
|
||||
[view, ["selectedIndex"]->Belt.Array.map(dashed)->prefixWithBind]->Belt.Array.concatMany
|
||||
|
||||
let progress = [view, ["maxValue", "value"]->Belt.Array.map(dashed)]->Belt.Array.concatMany
|
||||
let progress =
|
||||
[view, ["maxValue", "value"]->Belt.Array.map(dashed)->prefixWithBind]->Belt.Array.concatMany
|
||||
|
||||
let scrollView =
|
||||
[
|
||||
@ -267,27 +281,36 @@ let scrollView =
|
||||
"scrollableHeight",
|
||||
"scrollableWidth",
|
||||
"verticalOffset",
|
||||
]->Belt.Array.map(dashed),
|
||||
]
|
||||
->Belt.Array.map(dashed)
|
||||
->prefixWithBind,
|
||||
]->Belt.Array.concatMany
|
||||
|
||||
let searchBar =
|
||||
[
|
||||
view,
|
||||
["hint", "text", "textFieldBackgroundColor", "textFieldHintColor"]->Belt.Array.map(dashed),
|
||||
["hint", "text", "textFieldBackgroundColor", "textFieldHintColor"]
|
||||
->Belt.Array.map(dashed)
|
||||
->prefixWithBind,
|
||||
]->Belt.Array.concatMany
|
||||
|
||||
let segmentedBarItem = [view, ["title"]->Belt.Array.map(dashed)]->Belt.Array.concatMany
|
||||
let segmentedBarItem =
|
||||
[view, ["title"]->Belt.Array.map(dashed)->prefixWithBind]->Belt.Array.concatMany
|
||||
|
||||
let segmentedBar =
|
||||
[
|
||||
view,
|
||||
["selectedBackgroundColor", "selectedIndex"]->Belt.Array.map(dashed),
|
||||
["selectedBackgroundColor", "selectedIndex"]->Belt.Array.map(dashed)->prefixWithBind,
|
||||
]->Belt.Array.concatMany
|
||||
|
||||
let slider =
|
||||
[view, ["value", "minValue", "maxValue"]->Belt.Array.map(dashed)]->Belt.Array.concatMany
|
||||
[
|
||||
view,
|
||||
["value", "minValue", "maxValue"]->Belt.Array.map(dashed)->prefixWithBind,
|
||||
]->Belt.Array.concatMany
|
||||
|
||||
let switchComponent = [view, ["checked"]->Belt.Array.map(dashed)]->Belt.Array.concatMany
|
||||
let switchComponent =
|
||||
[view, ["checked"]->Belt.Array.map(dashed)->prefixWithBind]->Belt.Array.concatMany
|
||||
|
||||
let tabView =
|
||||
[
|
||||
@ -303,13 +326,15 @@ let tabView =
|
||||
"tabBackgroundColor",
|
||||
"tabTextColor",
|
||||
"tabTextFontSize",
|
||||
]->Belt.Array.map(dashed),
|
||||
]
|
||||
->Belt.Array.map(dashed)
|
||||
->prefixWithBind,
|
||||
]->Belt.Array.concatMany
|
||||
|
||||
let tabViewItem =
|
||||
[
|
||||
view,
|
||||
["canBeLoaded", "iconSource", "textTransform", "title"]->Belt.Array.map(dashed),
|
||||
["canBeLoaded", "iconSource", "textTransform", "title"]->Belt.Array.map(dashed)->prefixWithBind,
|
||||
]->Belt.Array.concatMany
|
||||
|
||||
let commonTextBase =
|
||||
@ -335,18 +360,25 @@ let commonTextBase =
|
||||
"textTransform",
|
||||
"updateTextTrigger",
|
||||
"whiteSpace",
|
||||
]->Belt.Array.map(dashed)
|
||||
]
|
||||
->Belt.Array.map(dashed)
|
||||
->prefixWithBind
|
||||
|
||||
let textField =
|
||||
[
|
||||
view,
|
||||
paddings,
|
||||
commonTextBase,
|
||||
["closeOnReturn", "secure", "secureWithoutAutofill"]->Belt.Array.map(dashed),
|
||||
["closeOnReturn", "secure", "secureWithoutAutofill"]->Belt.Array.map(dashed)->prefixWithBind,
|
||||
]->Belt.Array.concatMany
|
||||
|
||||
let textView =
|
||||
[view, paddings, commonTextBase, ["maxLines"]->Belt.Array.map(dashed)]->Belt.Array.concatMany
|
||||
[
|
||||
view,
|
||||
paddings,
|
||||
commonTextBase,
|
||||
["maxLines"]->Belt.Array.map(dashed)->prefixWithBind,
|
||||
]->Belt.Array.concatMany
|
||||
|
||||
let timePicker =
|
||||
[
|
||||
@ -361,25 +393,26 @@ let timePicker =
|
||||
"minute",
|
||||
"minuteInterval",
|
||||
"time",
|
||||
]->Belt.Array.map(dashed),
|
||||
]
|
||||
->Belt.Array.map(dashed)
|
||||
->prefixWithBind,
|
||||
]->Belt.Array.concatMany
|
||||
|
||||
let webView =
|
||||
[view, ["canGoBack", "canGoForward", "src"]->Belt.Array.map(dashed)]->Belt.Array.concatMany
|
||||
[
|
||||
view,
|
||||
["canGoBack", "canGoForward", "src"]->Belt.Array.map(dashed)->prefixWithBind,
|
||||
]->Belt.Array.concatMany
|
||||
|
||||
let actionBar = [view, ["title", "flat"]->Belt.Array.map(dashed)]->Belt.Array.concatMany
|
||||
let actionBar =
|
||||
[view, ["title", "flat"]->Belt.Array.map(dashed)->prefixWithBind]->Belt.Array.concatMany
|
||||
|
||||
let actionItem =
|
||||
[
|
||||
view,
|
||||
[
|
||||
"text",
|
||||
"icon",
|
||||
"ios.position",
|
||||
"android.position",
|
||||
"ios.systemIcon",
|
||||
"android.systemIcon",
|
||||
]->Belt.Array.map(dashed),
|
||||
["text", "icon", "ios.position", "android.position", "ios.systemIcon", "android.systemIcon"]
|
||||
->Belt.Array.map(dashed)
|
||||
->prefixWithBind,
|
||||
]->Belt.Array.concatMany
|
||||
|
||||
let navigationButton = actionItem
|
||||
@ -387,12 +420,9 @@ let navigationButton = actionItem
|
||||
let listView =
|
||||
[
|
||||
view,
|
||||
[
|
||||
"itemTemplateSelector",
|
||||
"iosEstimatedRowHeight",
|
||||
"rowHeight",
|
||||
"separatorColor",
|
||||
]->Belt.Array.map(dashed),
|
||||
["itemTemplateSelector", "iosEstimatedRowHeight", "rowHeight", "separatorColor"]
|
||||
->Belt.Array.map(dashed)
|
||||
->prefixWithBind,
|
||||
]->Belt.Array.concatMany
|
||||
|
||||
// Js.log("****************************")
|
||||
|
@ -3,15 +3,13 @@ let makeRender = helperAdd =>
|
||||
helperAdd(. current.parentElement, current)
|
||||
)
|
||||
|
||||
let prefixWithBind = arr => Belt.Array.concat(arr, arr->Belt.Array.map(x => `bind-${x}`))
|
||||
|
||||
let buildHandler: (
|
||||
unit => Types.nativeObject,
|
||||
array<string>,
|
||||
Js.Nullable.t<(. Types.htmlElement, Types.nativeObject) => unit>,
|
||||
) => Types.handler = (new, observedAttributes, render) => {
|
||||
init: (. ()) => new(),
|
||||
observedAttributes: prefixWithBind(observedAttributes),
|
||||
observedAttributes,
|
||||
render,
|
||||
handlerKind: Types.Element,
|
||||
update: NativescriptCore.update,
|
||||
|
@ -26,9 +26,9 @@ module Application = {
|
||||
(
|
||||
Constants.camelCased(extracted),
|
||||
// Allows expression binding only when attribute is prefixed.
|
||||
if extracted != attr && assignmentKind == Types.BindingExpression {
|
||||
newValue
|
||||
// Global Eval expression is skipped to prevent user from executing JS
|
||||
if assignmentKind == Types.BindingExpression {
|
||||
extracted != attr ? newValue : (value, Types.String)
|
||||
// Global Eval expression is skipped to prevent user from executing JS
|
||||
} else if attr == "text" && assignmentKind == Types.GlobalEvalExpression {
|
||||
(value, Types.String)
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user