Skip to content

Commit 333d6bf

Browse files
committed
(U) add support for Glimmer TypeScript, #828 part 2 of 2
1 parent 97a71c4 commit 333d6bf

File tree

5 files changed

+204
-3
lines changed

5 files changed

+204
-3
lines changed

Unix/cloc

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5792,15 +5792,18 @@ sub invoke_generator { # {{{1
57925792
if ($opt_fullpath and any_match($F, 0, \$rule, @opt_not_match_d)) {
57935793
$Ignored{$F} = "--not-match-d=$rule";
57945794
next;
5795-
} elsif (any_match(basename($F), 0, \$rule, @opt_not_match_d)) {
5795+
} elsif (!$opt_fullpath and any_match(basename($F), 0, \$rule, @opt_not_match_d)) {
57965796
$Ignored{$F} = "--not-match-d (basename) =$rule";
57975797
next;
57985798
}
57995799
}
58005800
if (@opt_not_match_f) {
58015801
my $rule;
5802-
if (any_match(basename($F), 0, \$rule, @opt_not_match_f)) {
5803-
$Ignored{$F} = "--not-match-d =$rule";
5802+
if ($opt_fullpath and any_match($F, 0, \$rule, @opt_not_match_f)) {
5803+
$Ignored{$F} = "--not-match-f=$rule";
5804+
next;
5805+
} elsif (!$opt_fullpath and any_match(basename($F), 0, \$rule, @opt_not_match_f)) {
5806+
$Ignored{$F} = "--not-match-f (basename) =$rule";
58045807
next;
58055808
}
58065809
}
@@ -8432,6 +8435,7 @@ sub set_constants { # {{{1
84328435
'fp' => 'GLSL' ,
84338436
'fbs' => 'Flatbuffers' ,
84348437
'gjs' => 'Glimmer JavaScript' ,
8438+
'gts' => 'Glimmer TypeScript' ,
84358439
'glsl' => 'GLSL' ,
84368440
'graphqls' => 'GraphQL' ,
84378441
'gql' => 'GraphQL' ,
@@ -9718,6 +9722,15 @@ sub set_constants { # {{{1
97189722
[ 'rm_comments_in_strings', '"', '//', '' ],
97199723
[ 'call_regexp_common' , 'C++' ],
97209724
],
9725+
'Glimmer TypeScript' => [
9726+
[ 'remove_between_general', '{{!', '}}' ],
9727+
[ 'remove_between_general', '<!--', '-->' ],
9728+
[ 'rm_comments_in_strings', "'", '/*', '*/' ],
9729+
[ 'rm_comments_in_strings', "'", '//', '' ],
9730+
[ 'rm_comments_in_strings', '"', '/*', '*/' ],
9731+
[ 'rm_comments_in_strings', '"', '//', '' ],
9732+
[ 'call_regexp_common' , 'C++' ],
9733+
],
97219734
'GLSL' => [
97229735
[ 'rm_comments_in_strings', '"', '/*', '*/' ],
97239736
[ 'rm_comments_in_strings', '"', '//', '' ],
@@ -11186,6 +11199,7 @@ sub set_constants { # {{{1
1118611199
'Gleam' => 2.50,
1118711200
'GLSL' => 2.00,
1118811201
'Glimmer JavaScript' => 3.50,
11202+
'Glimmer TypeScript' => 3.50,
1118911203
'gml' => 1.74,
1119011204
'gpss' => 1.74,
1119111205
'guest' => 2.86,

Unix/t/00_C.t

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,11 @@ my @Tests = (
409409
'ref' => '../tests/outputs/body.gjs.yaml',
410410
'args' => '../tests/inputs/body.gjs',
411411
},
412+
{
413+
'name' => 'Glimmer TypeScript',
414+
'ref' => '../tests/outputs/input.gts.yaml',
415+
'args' => '../tests/inputs/input.gts',
416+
},
412417
{
413418
'name' => 'GLSL',
414419
'ref' => '../tests/outputs/blur.glsl.yaml',

cloc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8450,6 +8450,7 @@ sub set_constants { # {{{1
84508450
'fp' => 'GLSL' ,
84518451
'fbs' => 'Flatbuffers' ,
84528452
'gjs' => 'Glimmer JavaScript' ,
8453+
'gts' => 'Glimmer TypeScript' ,
84538454
'glsl' => 'GLSL' ,
84548455
'graphqls' => 'GraphQL' ,
84558456
'gql' => 'GraphQL' ,
@@ -9736,6 +9737,15 @@ sub set_constants { # {{{1
97369737
[ 'rm_comments_in_strings', '"', '//', '' ],
97379738
[ 'call_regexp_common' , 'C++' ],
97389739
],
9740+
'Glimmer TypeScript' => [
9741+
[ 'remove_between_general', '{{!', '}}' ],
9742+
[ 'remove_between_general', '<!--', '-->' ],
9743+
[ 'rm_comments_in_strings', "'", '/*', '*/' ],
9744+
[ 'rm_comments_in_strings', "'", '//', '' ],
9745+
[ 'rm_comments_in_strings', '"', '/*', '*/' ],
9746+
[ 'rm_comments_in_strings', '"', '//', '' ],
9747+
[ 'call_regexp_common' , 'C++' ],
9748+
],
97399749
'GLSL' => [
97409750
[ 'rm_comments_in_strings', '"', '/*', '*/' ],
97419751
[ 'rm_comments_in_strings', '"', '//', '' ],
@@ -11204,6 +11214,7 @@ sub set_constants { # {{{1
1120411214
'Gleam' => 2.50,
1120511215
'GLSL' => 2.00,
1120611216
'Glimmer JavaScript' => 3.50,
11217+
'Glimmer TypeScript' => 3.50,
1120711218
'gml' => 1.74,
1120811219
'gpss' => 1.74,
1120911220
'guest' => 2.86,

tests/inputs/input.gts

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
{{! partial of
2+
https://raw.githubusercontent.com/josemarluedke/frontile/a9680f2681a8b1193feba0fdc27871566bcde120/packages/forms/src/components/input.gts
3+
}}
4+
import Component from '@glimmer/component';
5+
import { tracked } from '@glimmer/tracking';
6+
import { action } from '@ember/object';
7+
import { on } from '@ember/modifier';
8+
import {
9+
useStyles,
10+
type InputSlots,
11+
type InputVariants,
12+
type SlotsToClasses
13+
} from '@frontile/theme';
14+
import { FormControl, type FormControlSharedArgs } from './form-control';
15+
import { triggerFormInputEvent } from '../utils';
16+
import { ref } from '@frontile/utilities';
17+
import { CloseButton } from '@frontile/buttons';
18+
19+
interface Args extends FormControlSharedArgs {
20+
type?: string;
21+
value?: string;
22+
name?: string;
23+
size?: InputVariants['size'];
24+
classes?: SlotsToClasses<InputSlots>;
25+
26+
/**
27+
* Whether to include a clear button
28+
*/
29+
isClearable?: boolean;
30+
31+
/**
32+
* Controls pointer-events property of startContent.
33+
* If you want to pass the click event to the input, set it to `none`.
34+
*
35+
* @defaultValue 'auto'
36+
*/
37+
startContentPointerEvents?: 'none' | 'auto';
38+
39+
/**
40+
* Controls pointer-events property of endContent.
41+
* If you want to pass the click event to the input, set it to `none`.
42+
*
43+
* @defaultValue 'auto'
44+
*/
45+
endContentPointerEvents?: 'none' | 'auto';
46+
47+
/**
48+
* Callback when oninput is triggered
49+
*/
50+
onInput?: (value: string, event?: InputEvent) => void;
51+
52+
/**
53+
* Callback when onchange is triggered
54+
*/
55+
onChange?: (value: string, event?: InputEvent) => void;
56+
}
57+
58+
interface InputSignature {
59+
Args: Args;
60+
Blocks: {
61+
startContent: [];
62+
endContent: [];
63+
};
64+
Element: HTMLInputElement;
65+
}
66+
67+
function or(arg1: unknown, arg2: unknown): boolean {
68+
return !!(arg1 || arg2);
69+
}
70+
71+
class Input extends Component<InputSignature> {
72+
@tracked uncontrolledValue: string = '';
73+
74+
inputRef = ref<HTMLInputElement>();
75+
76+
if (this.isControlled) {
77+
this.args.onInput?.(value, event as InputEvent);
78+
} else {
79+
this.uncontrolledValue = value;
80+
}
81+
}
82+
83+
@action handleOnChange(event: Event): void {
84+
const value = (event.target as HTMLInputElement).value;
85+
86+
if (this.isControlled) {
87+
this.args.onChange?.(value, event as InputEvent);
88+
} else {
89+
this.uncontrolledValue = value;
90+
}
91+
}
92+
93+
this.inputRef.element?.focus();
94+
triggerFormInputEvent(this.inputRef.element);
95+
}
96+
97+
<template>
98+
<FormControl
99+
@size={{@size}}
100+
@label={{@label}}
101+
@isRequired={{@isRequired}}
102+
@description={{@description}}
103+
@errors={{@errors}}
104+
@isInvalid={{@isInvalid}}
105+
@class={{this.classes.base class=@classes.base}}
106+
as |c|
107+
>
108+
<div class={{this.classes.innerContainer class=@classes.innerContainer}}>
109+
{{#if (has-block "startContent")}}
110+
<div
111+
data-test-id="input-start-content"
112+
class={{this.classes.startContent
113+
class=@classes.startContent
114+
startContentPointerEvents=(if
115+
@startContentPointerEvents @startContentPointerEvents "auto"
116+
)
117+
}}
118+
>
119+
{{yield to="startContent"}}
120+
</div>
121+
{{/if}}
122+
<input
123+
{{this.inputRef.setup}}
124+
{{on "input" this.handleOnInput}}
125+
{{on "change" this.handleOnChange}}
126+
id={{c.id}}
127+
}}
128+
data-component="input"
129+
aria-invalid={{if c.isInvalid "true"}}
130+
aria-describedby={{c.describedBy @description c.isInvalid}}
131+
...attributes
132+
/>
133+
{{#if (or (has-block "endContent") this.isClearable)}}
134+
<div
135+
>
136+
{{yield to="endContent"}}
137+
138+
{{#if this.isClearable}}
139+
<CloseButton
140+
/>
141+
{{/if}}
142+
</div>
143+
{{/if}}
144+
</div>
145+
</FormControl>
146+
</template>
147+
}
148+
149+
export { Input, type InputSignature };
150+
export default Input;

tests/outputs/input.gts.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
# github.com/AlDanial/cloc
3+
header :
4+
cloc_url : github.com/AlDanial/cloc
5+
cloc_version : 2.01
6+
elapsed_seconds : 0.00317215919494629
7+
n_files : 1
8+
n_lines : 150
9+
files_per_second : 315.242690717775
10+
lines_per_second : 47286.4036076663
11+
report_file : ../outputs/input.gts.yaml
12+
'Glimmer TypeScript' :
13+
nFiles: 1
14+
blank: 17
15+
comment: 24
16+
code: 109
17+
SUM:
18+
blank: 17
19+
comment: 24
20+
code: 109
21+
nFiles: 1

0 commit comments

Comments
 (0)