create-mendix-widget-gleam 1.0.3 → 1.0.5

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.
@@ -1,106 +0,0 @@
1
- // Mendix ListValue 타입 — 데이터 소스에서 가져온 객체 목록
2
- // 사용: 데이터 그리드, 리스트 뷰 등
3
-
4
- import gleam/option.{type Option}
5
- import widget/mendix.{type ObjectItem, type ValueStatus}
6
-
7
- // === 타입 ===
8
-
9
- pub type ListValue
10
-
11
- pub type FilterCondition
12
-
13
- pub type SortInstruction
14
-
15
- pub type SortDirection {
16
- Asc
17
- Desc
18
- }
19
-
20
- // === 접근자 ===
21
-
22
- @external(javascript, "../mendix_ffi.mjs", "get_status")
23
- fn get_status_raw(lv: ListValue) -> String
24
-
25
- /// 현재 상태 (Available, Loading, Unavailable)
26
- pub fn status(lv: ListValue) -> ValueStatus {
27
- mendix.to_value_status(get_status_raw(lv))
28
- }
29
-
30
- /// 아이템 목록 (로딩 중이면 None)
31
- @external(javascript, "../mendix_ffi.mjs", "get_list_items")
32
- pub fn items(lv: ListValue) -> Option(List(ObjectItem))
33
-
34
- /// 현재 오프셋
35
- @external(javascript, "../mendix_ffi.mjs", "get_list_offset")
36
- pub fn offset(lv: ListValue) -> Int
37
-
38
- /// 현재 페이지 크기
39
- @external(javascript, "../mendix_ffi.mjs", "get_list_limit")
40
- pub fn limit(lv: ListValue) -> Int
41
-
42
- /// 더 많은 아이템이 있는지 (불확실하면 None)
43
- @external(javascript, "../mendix_ffi.mjs", "get_list_has_more_items")
44
- pub fn has_more_items(lv: ListValue) -> Option(Bool)
45
-
46
- /// 전체 아이템 수 (요청하지 않았으면 None)
47
- @external(javascript, "../mendix_ffi.mjs", "get_list_total_count")
48
- pub fn total_count(lv: ListValue) -> Option(Int)
49
-
50
- /// 현재 정렬 순서
51
- @external(javascript, "../mendix_ffi.mjs", "get_list_sort_order")
52
- pub fn sort_order(lv: ListValue) -> List(SortInstruction)
53
-
54
- /// 현재 필터 조건 (없으면 None)
55
- @external(javascript, "../mendix_ffi.mjs", "get_list_filter")
56
- pub fn filter(lv: ListValue) -> Option(FilterCondition)
57
-
58
- // === 메서드 ===
59
-
60
- /// 오프셋 설정 (페이지네이션)
61
- @external(javascript, "../mendix_ffi.mjs", "list_set_offset")
62
- pub fn set_offset(lv: ListValue, offset: Int) -> Nil
63
-
64
- /// 페이지 크기 설정
65
- @external(javascript, "../mendix_ffi.mjs", "list_set_limit")
66
- pub fn set_limit(lv: ListValue, limit: Int) -> Nil
67
-
68
- /// 필터 조건 설정 (None → 필터 해제)
69
- @external(javascript, "../mendix_ffi.mjs", "list_set_filter")
70
- pub fn set_filter(lv: ListValue, filter: Option(FilterCondition)) -> Nil
71
-
72
- /// 정렬 순서 설정
73
- @external(javascript, "../mendix_ffi.mjs", "list_set_sort_order")
74
- pub fn set_sort_order(lv: ListValue, order: List(SortInstruction)) -> Nil
75
-
76
- /// 데이터 새로고침
77
- @external(javascript, "../mendix_ffi.mjs", "list_reload")
78
- pub fn reload(lv: ListValue) -> Nil
79
-
80
- /// 전체 아이템 수 요청 (True → 요청, False → 해제)
81
- @external(javascript, "../mendix_ffi.mjs", "list_request_total_count")
82
- pub fn request_total_count(lv: ListValue, need: Bool) -> Nil
83
-
84
- // === SortInstruction 빌더 ===
85
-
86
- @external(javascript, "../mendix_ffi.mjs", "make_sort_instruction")
87
- fn make_sort_raw(id: String, asc: Bool) -> SortInstruction
88
-
89
- /// 정렬 명령 생성
90
- pub fn sort(id: String, direction: SortDirection) -> SortInstruction {
91
- make_sort_raw(id, direction == Asc)
92
- }
93
-
94
- @external(javascript, "../mendix_ffi.mjs", "get_sort_id")
95
- pub fn sort_id(instr: SortInstruction) -> String
96
-
97
- @external(javascript, "../mendix_ffi.mjs", "get_sort_asc")
98
- fn sort_asc_raw(instr: SortInstruction) -> Bool
99
-
100
- /// 정렬 방향 조회
101
- pub fn sort_direction(instr: SortInstruction) -> SortDirection {
102
- case sort_asc_raw(instr) {
103
- True -> Asc
104
- False -> Desc
105
- }
106
- }
@@ -1,47 +0,0 @@
1
- // Mendix Reference 타입 — 연관 관계 (Association) 값
2
- // ReferenceValue: 단일 참조, ReferenceSetValue: 다중 참조
3
- // 둘 다 ModifiableValue 패턴을 따름
4
-
5
- import gleam/option.{type Option}
6
-
7
- // === 타입 ===
8
-
9
- pub type ReferenceValue
10
-
11
- pub type ReferenceSetValue
12
-
13
- // === ReferenceValue (단일 참조) ===
14
-
15
- /// 참조 값 (없으면 None)
16
- @external(javascript, "../mendix_ffi.mjs", "get_modifiable_value")
17
- pub fn value(ref: ReferenceValue) -> Option(a)
18
-
19
- /// 참조 설정 (None → 참조 해제)
20
- @external(javascript, "../mendix_ffi.mjs", "modifiable_set_value")
21
- pub fn set_value(ref: ReferenceValue, value: Option(a)) -> Nil
22
-
23
- /// 읽기 전용 여부
24
- @external(javascript, "../mendix_ffi.mjs", "get_modifiable_read_only")
25
- pub fn read_only(ref: ReferenceValue) -> Bool
26
-
27
- /// 유효성 검사 메시지 (없으면 None)
28
- @external(javascript, "../mendix_ffi.mjs", "get_modifiable_validation")
29
- pub fn validation(ref: ReferenceValue) -> Option(String)
30
-
31
- // === ReferenceSetValue (다중 참조) ===
32
-
33
- /// 참조 목록 (없으면 None) — JS Array↔Gleam List 변환 포함
34
- @external(javascript, "../mendix_ffi.mjs", "get_reference_set_value")
35
- pub fn multi_value(rset: ReferenceSetValue) -> Option(List(a))
36
-
37
- /// 참조 목록 설정 (None → 전체 해제) — Gleam List→JS Array 변환 포함
38
- @external(javascript, "../mendix_ffi.mjs", "set_reference_set_value")
39
- pub fn set_multi_value(rset: ReferenceSetValue, value: Option(List(a))) -> Nil
40
-
41
- /// 읽기 전용 여부
42
- @external(javascript, "../mendix_ffi.mjs", "get_modifiable_read_only")
43
- pub fn multi_read_only(rset: ReferenceSetValue) -> Bool
44
-
45
- /// 유효성 검사 메시지 (없으면 None)
46
- @external(javascript, "../mendix_ffi.mjs", "get_modifiable_validation")
47
- pub fn multi_validation(rset: ReferenceSetValue) -> Option(String)
@@ -1,31 +0,0 @@
1
- // Mendix Selection 타입 — 단일/다중 선택
2
- // 사용: 데이터 그리드 선택, 리스트 선택 등
3
-
4
- import gleam/option.{type Option}
5
- import widget/mendix.{type ObjectItem}
6
-
7
- // === 타입 ===
8
-
9
- pub type SelectionSingleValue
10
-
11
- pub type SelectionMultiValue
12
-
13
- // === 단일 선택 ===
14
-
15
- /// 현재 선택된 아이템 (없으면 None)
16
- @external(javascript, "../mendix_ffi.mjs", "get_selection_single")
17
- pub fn selection(sel: SelectionSingleValue) -> Option(ObjectItem)
18
-
19
- /// 선택 설정 (None → 선택 해제)
20
- @external(javascript, "../mendix_ffi.mjs", "set_selection_single")
21
- pub fn set_selection(sel: SelectionSingleValue, item: Option(ObjectItem)) -> Nil
22
-
23
- // === 다중 선택 ===
24
-
25
- /// 현재 선택된 아이템 목록
26
- @external(javascript, "../mendix_ffi.mjs", "get_selection_multi")
27
- pub fn selections(sel: SelectionMultiValue) -> List(ObjectItem)
28
-
29
- /// 선택 목록 설정
30
- @external(javascript, "../mendix_ffi.mjs", "set_selection_multi")
31
- pub fn set_selections(sel: SelectionMultiValue, items: List(ObjectItem)) -> Nil
@@ -1,65 +0,0 @@
1
- // Mendix Pluggable Widget API - 핵심 타입 + JsProps 접근자
2
- // ValueStatus, ObjectItem 타입과 props 접근 유틸리티
3
-
4
- import gleam/option.{type Option}
5
- import widget/react.{type JsProps}
6
-
7
- // === ValueStatus ===
8
-
9
- pub type ValueStatus {
10
- Available
11
- Unavailable
12
- Loading
13
- }
14
-
15
- pub fn to_value_status(status: String) -> ValueStatus {
16
- case status {
17
- "available" -> Available
18
- "loading" -> Loading
19
- _ -> Unavailable
20
- }
21
- }
22
-
23
- // === ObjectItem ===
24
-
25
- pub type ObjectItem
26
-
27
- @external(javascript, "./mendix_ffi.mjs", "get_object_id")
28
- pub fn object_id(item: ObjectItem) -> String
29
-
30
- // === JsProps 접근자 ===
31
-
32
- /// Mendix props에서 값 추출 (undefined → None)
33
- @external(javascript, "./mendix_ffi.mjs", "get_mendix_prop")
34
- pub fn get_prop(props: JsProps, key: String) -> Option(a)
35
-
36
- /// Mendix props에서 항상 존재하는 값 추출
37
- @external(javascript, "./mendix_ffi.mjs", "get_mendix_prop_required")
38
- pub fn get_prop_required(props: JsProps, key: String) -> a
39
-
40
- /// Mendix props에서 문자열 속성값 추출 (undefined → "")
41
- @external(javascript, "./react_ffi.mjs", "get_string_prop")
42
- pub fn get_string_prop(props: JsProps, key: String) -> String
43
-
44
- /// Mendix props에서 키 존재 확인
45
- @external(javascript, "./react_ffi.mjs", "has_prop")
46
- pub fn has_prop(props: JsProps, key: String) -> Bool
47
-
48
- // === Status 접근 (status 속성을 가진 모든 Mendix 객체) ===
49
-
50
- @external(javascript, "./mendix_ffi.mjs", "get_status")
51
- fn get_status_raw(obj: a) -> String
52
-
53
- pub fn get_status(obj: a) -> ValueStatus {
54
- to_value_status(get_status_raw(obj))
55
- }
56
-
57
- // === Option 변환 유틸리티 (FFI 경계 처리) ===
58
-
59
- /// JS 값을 Gleam Option으로 변환 (undefined/null → None)
60
- @external(javascript, "./mendix_ffi.mjs", "to_option")
61
- pub fn to_option(value: a) -> Option(a)
62
-
63
- /// Gleam Option을 JS 값으로 변환 (None → undefined)
64
- @external(javascript, "./mendix_ffi.mjs", "from_option")
65
- pub fn from_option(option: Option(a)) -> a