create-mendix-widget-gleam 1.0.0
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/bin/create-mendix-widget-gleam.mjs +4 -0
- package/package.json +24 -0
- package/src/index.mjs +291 -0
- package/src/naming.mjs +56 -0
- package/src/pm.mjs +26 -0
- package/src/prompts.mjs +116 -0
- package/src/scaffold.mjs +90 -0
- package/template/.gitattributes +21 -0
- package/template/.prettierignore +1 -0
- package/template/LICENSE +15 -0
- package/template/_gitignore +48 -0
- package/template/docs/gleam_language_tour.md +1884 -0
- package/template/gleam.toml +10 -0
- package/template/manifest.toml +9 -0
- package/template/package.json +35 -0
- package/template/prettier.config.js +6 -0
- package/template/src/__WidgetName__.editorConfig.js +5 -0
- package/template/src/__WidgetName__.js +6 -0
- package/template/src/__WidgetName__.xml +17 -0
- package/template/src/package.xml +11 -0
- package/template/src/scripts/build.gleam +8 -0
- package/template/src/scripts/cmd.gleam +4 -0
- package/template/src/scripts/cmd_ffi.mjs +6 -0
- package/template/src/scripts/dev.gleam +8 -0
- package/template/src/scripts/install.gleam +8 -0
- package/template/src/scripts/lint.gleam +7 -0
- package/template/src/scripts/lint_fix.gleam +7 -0
- package/template/src/scripts/release.gleam +8 -0
- package/template/src/scripts/start.gleam +8 -0
- package/template/src/ui/__WidgetName__.css +6 -0
- package/template/src/widget/__widget_name__.gleam +20 -0
- package/template/src/widget/__widget_name___ffi.mjs +13 -0
- package/template/src/widget/editor_config.gleam +18 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# This file was generated by Gleam
|
|
2
|
+
# You typically do not need to edit this file
|
|
3
|
+
|
|
4
|
+
packages = [
|
|
5
|
+
{ name = "gleam_stdlib", version = "0.70.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "86949BF5D1F0E4AC0AB5B06F235D8A5CC11A2DFC33BF22F752156ED61CA7D0FF" },
|
|
6
|
+
]
|
|
7
|
+
|
|
8
|
+
[requirements]
|
|
9
|
+
gleam_stdlib = { version = ">= 0.44.0 and < 2.0.0" }
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{LOWERCASE}}",
|
|
3
|
+
"widgetName": "{{PASCAL_CASE}}",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"description": "My widget description",
|
|
6
|
+
"copyright": "© Mendix Technology BV 2026. All rights reserved.",
|
|
7
|
+
"author": "",
|
|
8
|
+
"engines": {
|
|
9
|
+
"node": ">=16"
|
|
10
|
+
},
|
|
11
|
+
"license": "Apache-2.0",
|
|
12
|
+
"config": {
|
|
13
|
+
"projectPath": "./tests/testProject",
|
|
14
|
+
"mendixHost": "http://localhost:8080",
|
|
15
|
+
"developmentPort": 3000
|
|
16
|
+
},
|
|
17
|
+
"packagePath": "mendix",
|
|
18
|
+
"scripts": {
|
|
19
|
+
"prerelease": "echo skipping lint"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@mendix/pluggable-widgets-tools": "^11.8.0"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"classnames": "^2.5.1"
|
|
26
|
+
},
|
|
27
|
+
"resolutions": {
|
|
28
|
+
"react": "^19.0.0",
|
|
29
|
+
"react-dom": "^19.0.0"
|
|
30
|
+
},
|
|
31
|
+
"overrides": {
|
|
32
|
+
"react": "^19.0.0",
|
|
33
|
+
"react-dom": "^19.0.0"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<widget id="mendix.{{LOWERCASE}}.{{PASCAL_CASE}}" pluginWidget="true" needsEntityContext="true" offlineCapable="true"
|
|
3
|
+
supportedPlatform="Web"
|
|
4
|
+
xmlns="http://www.mendix.com/widget/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
5
|
+
xsi:schemaLocation="http://www.mendix.com/widget/1.0/ ../node_modules/mendix/custom_widget.xsd">
|
|
6
|
+
<name>{{DISPLAY_NAME}}</name>
|
|
7
|
+
<description>My widget description</description>
|
|
8
|
+
<icon/>
|
|
9
|
+
<properties>
|
|
10
|
+
<propertyGroup caption="General">
|
|
11
|
+
<property key="sampleText" type="string" required="false">
|
|
12
|
+
<caption>Default value</caption>
|
|
13
|
+
<description>Sample text input</description>
|
|
14
|
+
</property>
|
|
15
|
+
</propertyGroup>
|
|
16
|
+
</properties>
|
|
17
|
+
</widget>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8" ?>
|
|
2
|
+
<package xmlns="http://www.mendix.com/package/1.0/">
|
|
3
|
+
<clientModule name="{{PASCAL_CASE}}" version="1.0.0" xmlns="http://www.mendix.com/clientModule/1.0/">
|
|
4
|
+
<widgetFiles>
|
|
5
|
+
<widgetFile path="{{PASCAL_CASE}}.xml"/>
|
|
6
|
+
</widgetFiles>
|
|
7
|
+
<files>
|
|
8
|
+
<file path="mendix/{{LOWERCASE}}"/>
|
|
9
|
+
</files>
|
|
10
|
+
</clientModule>
|
|
11
|
+
</package>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Mendix Pluggable Widget - "Hello World"
|
|
2
|
+
// React 함수형 컴포넌트: fn(JsProps) -> ReactElement
|
|
3
|
+
|
|
4
|
+
// 외부 타입 (JS 값의 opaque 핸들)
|
|
5
|
+
pub type ReactElement
|
|
6
|
+
|
|
7
|
+
pub type JsProps
|
|
8
|
+
|
|
9
|
+
// FFI 바인딩
|
|
10
|
+
@external(javascript, "./{{SNAKE_CASE}}_ffi.mjs", "create_div")
|
|
11
|
+
fn create_div(class_name: String, text_content: String) -> ReactElement
|
|
12
|
+
|
|
13
|
+
@external(javascript, "./{{SNAKE_CASE}}_ffi.mjs", "get_string_prop")
|
|
14
|
+
fn get_string_prop(props: JsProps, key: String) -> String
|
|
15
|
+
|
|
16
|
+
/// 위젯 메인 함수 - Mendix 런타임이 React 컴포넌트로 호출
|
|
17
|
+
pub fn widget(props: JsProps) -> ReactElement {
|
|
18
|
+
let sample_text = get_string_prop(props, "sampleText")
|
|
19
|
+
create_div("widget-hello-world", "Hello " <> sample_text)
|
|
20
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// React FFI 어댑터 - React 원시 함수만 노출
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
|
|
4
|
+
// div 요소에 텍스트 자식을 렌더링
|
|
5
|
+
export function create_div(class_name, text_content) {
|
|
6
|
+
return React.createElement("div", { className: class_name }, text_content);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// props 객체에서 문자열 속성값 추출
|
|
10
|
+
export function get_string_prop(props, key) {
|
|
11
|
+
const value = props[key];
|
|
12
|
+
return value !== undefined && value !== null ? String(value) : "";
|
|
13
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Mendix Studio Pro 속성 패널 설정
|
|
2
|
+
// getProperties, check, getPreview 등을 정의
|
|
3
|
+
|
|
4
|
+
// 외부 타입 (Mendix가 전달하는 JS 객체)
|
|
5
|
+
pub type Values
|
|
6
|
+
|
|
7
|
+
pub type Properties
|
|
8
|
+
|
|
9
|
+
pub type Target
|
|
10
|
+
|
|
11
|
+
/// 속성 패널 설정 - Studio Pro에서 위젯 속성의 가시성을 제어
|
|
12
|
+
pub fn get_properties(
|
|
13
|
+
_values: Values,
|
|
14
|
+
default_properties: Properties,
|
|
15
|
+
_target: Target,
|
|
16
|
+
) -> Properties {
|
|
17
|
+
default_properties
|
|
18
|
+
}
|