Skip to content

Commit

Permalink
$mol_view_tree2 misc fixes while build hyoo
Browse files Browse the repository at this point in the history
  • Loading branch information
zerkalica committed Nov 27, 2023
1 parent 241119b commit 274b90a
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 25 deletions.
32 changes: 16 additions & 16 deletions style/func/func.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ namespace $ {
}

static clamp(
min: $mol_style_unit< any >,
mid: $mol_style_unit< any >,
max: $mol_style_unit< any >,
min: $mol_style_unit2,
mid: $mol_style_unit2,
max: $mol_style_unit2,
) {
return new $mol_style_func(
'clamp',
Expand All @@ -99,7 +99,7 @@ namespace $ {
}

static linear(
...breakpoints : Array<number | [number, number | $mol_style_unit<'%'>]>
...breakpoints : Array<number | [number, number | $mol_style_unit2<'%'>]>
){
return new $mol_style_func(
"linear",
Expand All @@ -126,23 +126,23 @@ namespace $ {
return new $mol_style_func( 'steps', [ value, step_position ] )
}

static blur(value?: $mol_style_unit<$mol_style_unit_length>){
static blur(value?: $mol_style_unit2<$mol_style_unit_length>){
return new $mol_style_func( 'blur', value ?? "" );
}

static brightness(value?: number | $mol_style_unit<'%'>){
static brightness(value?: number | $mol_style_unit2<'%'>){
return new $mol_style_func( 'brightness', value ?? "" );
}

static contrast(value?: number | $mol_style_unit<'%'>){
static contrast(value?: number | $mol_style_unit2<'%'>){
return new $mol_style_func( 'contrast', value ?? "" );
}

static drop_shadow(
color: $mol_style_properties_color,
x_offset: $mol_style_unit<$mol_style_unit_length>,
y_offset: $mol_style_unit<$mol_style_unit_length>,
blur_radius?: $mol_style_unit<$mol_style_unit_length>
x_offset: $mol_style_unit2<$mol_style_unit_length>,
y_offset: $mol_style_unit2<$mol_style_unit_length>,
blur_radius?: $mol_style_unit2<$mol_style_unit_length>
) {
return new $mol_style_func(
"drop-shadow",
Expand All @@ -152,27 +152,27 @@ namespace $ {
);
}

static grayscale(value?: number | $mol_style_unit<'%'>){
static grayscale(value?: number | $mol_style_unit2<'%'>){
return new $mol_style_func( 'grayscale', value ?? "" );
}

static hue_rotate(value?: 0 | $mol_style_unit<$mol_style_unit_angle>){
static hue_rotate(value?: 0 | $mol_style_unit2<$mol_style_unit_angle>){
return new $mol_style_func( 'hue-rotate', value ?? "")
}

static invert(value?: number | $mol_style_unit<'%'>){
static invert(value?: number | $mol_style_unit2<'%'>){
return new $mol_style_func( 'invert', value ?? "" );
}

static opacity(value?: number | $mol_style_unit<'%'>){
static opacity(value?: number | $mol_style_unit2<'%'>){
return new $mol_style_func( 'opacity', value ?? "" );
}

static sepia(value?: number | $mol_style_unit<'%'>){
static sepia(value?: number | $mol_style_unit2<'%'>){
return new $mol_style_func( 'sepia', value ?? "" );
}

static saturate(value?: number | $mol_style_unit<'%'>){
static saturate(value?: number | $mol_style_unit2<'%'>){
return new $mol_style_func( 'saturate', value ?? "" );
}

Expand Down
4 changes: 2 additions & 2 deletions style/properties/properties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ namespace $ {
* The animation can start later, immediately from its beginning, or immediately and partway through the animation.
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/animation-delay
*/
delay? : $mol_style_unit<$mol_style_unit_time> | $mol_style_unit<$mol_style_unit_time>[][] | Common
delay? : $mol_style_unit2<$mol_style_unit_time> | $mol_style_unit2<$mol_style_unit_time>[][] | Common

/**
* Sets whether an animation should play forward, backward, or alternate back and forth between playing the sequence forward and backward.
Expand All @@ -175,7 +175,7 @@ namespace $ {
* Sets the length of time that an animation takes to complete one cycle.
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/animation-duration
*/
duration? : $mol_style_unit<$mol_style_unit_time> | $mol_style_unit<$mol_style_unit_time>[][] | Common
duration? : $mol_style_unit2<$mol_style_unit_time> | $mol_style_unit2<$mol_style_unit_time>[][] | Common

/**
* Sets how a CSS animation applies styles to its target before and after its execution.
Expand Down
4 changes: 3 additions & 1 deletion style/unit/unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ namespace $ {
export type $mol_style_unit_time = 's' | 'ms'

export type $mol_style_unit_any = $mol_style_unit_length | $mol_style_unit_angle | $mol_style_unit_time


export type $mol_style_unit2< Quanity extends $mol_style_unit_any = $mol_style_unit_any> = `${number}${Quanity}`

/**
* CSS Units
* @see https://mol.hyoo.ru/#!section=docs/=xwq9q5_f966fg
Expand Down
1 change: 1 addition & 0 deletions text/text/text.view.tree
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ $mol_text $mol_list
text \
param \
flow_tokens /
block_text* \
auto /
<= auto_scroll null
- \Blocks
Expand Down
4 changes: 2 additions & 2 deletions view/tree2/class/match.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
namespace $ {
const class_regex = /^[$A-Z][$\w<>]+$/

export function $mol_view_tree2_class_match(klass: $mol_tree2) {
if (! klass.type) return false
export function $mol_view_tree2_class_match(klass?: $mol_tree2) {
if (! klass?.type) return false
if (klass.type === 'NaN' || klass.type === 'Infinity') return false

return class_regex.test(klass.type)
Expand Down
4 changes: 4 additions & 0 deletions view/tree2/class/props.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ namespace $.$$ {
const src = `
${d}my_test ${d}my_super
title @ \\title
sub2 /
<= Сlose_icon ${d}mol_icon_cross
sub /
<= Title ${d}mol_view
sub /
Expand Down Expand Up @@ -32,13 +34,15 @@ namespace $.$$ {

const dest = $$.$mol_tree2_from_string(`
title @ \\title
sub2 / <= Сlose_icon
sub /
<= Title
<= Close
Some ${d}mol_speech
Text => f
g => h
plugins / <= Speech
Сlose_icon ${d}mol_icon_cross
Title ${d}mol_view sub / <= title
close?event null
Close ${d}mol_button
Expand Down
2 changes: 1 addition & 1 deletion view/tree2/class/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ namespace $ {
let right
const operator = left.kids[0]

if (operator?.type === '=>') {
if (operator?.type === '=>' && context.factory) {
right = operator.kids[0]
if (! right) this.$mol_fail(err`Need a child ${operator.span}`)
if (! context.factory) this.$mol_fail(err`Need a parent ${left.span}`)
Expand Down
7 changes: 7 additions & 0 deletions view/tree2/prop/parts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ namespace $ {
})
},

'prop in upper case'($) {
const parts = get_parts('Close_icon')
$mol_assert_equal(parts.name, 'Close_icon')
$mol_assert_equal(parts.key, '')
$mol_assert_equal(parts.next, '')
},

'prop with index'($) {
const parts = get_parts('some_bla*')
$mol_assert_equal(parts.name, 'some_bla')
Expand Down
2 changes: 1 addition & 1 deletion view/tree2/prop/parts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace $ {

if (! groups) {
this.$mol_fail(
$mol_view_tree2_error_str`Required prop like some*? at ${prop.span}`
$mol_view_tree2_error_str`${prop.type ? `Cyrillic symbol in ${prop.type}? ` : ''}Required prop like some*? at ${prop.span}`
)
}

Expand Down
2 changes: 0 additions & 2 deletions view/tree2/to/dts/dts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ namespace $ {
}

function params_of( this: $, prop: $mol_tree2, ... val: $mol_tree2[] ) {

const { name, key, next } = this.$mol_view_tree2_prop_parts(prop)

if (next && (! val.length || ! val[0].value) ) {
Expand Down Expand Up @@ -309,7 +308,6 @@ namespace $ {
)
)
}

return [
input.data( input.type ),
]
Expand Down
9 changes: 9 additions & 0 deletions view/tree2/to/js/test/js.simple.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,15 @@ namespace $ {
)
},

'simple throw if cyrillic name'( $ ) {
$mol_assert_fail(() => {
$mol_view_tree2_to_js_test_run(`
Foo $mol_object
sub / <= Сlose_icon $mol_object
`)
})
},

'simple empty legacy indexed channel throws error'( $ ) {
$mol_assert_fail(() => {
$mol_view_tree2_to_js_test_run(`
Expand Down

0 comments on commit 274b90a

Please sign in to comment.