@makeform/base 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.
Files changed (3) hide show
  1. package/README.md +80 -0
  2. package/index.html +1 -0
  3. package/package.json +1 -0
package/README.md ADDED
@@ -0,0 +1,80 @@
1
+ # @makeform widgets
2
+
3
+ All @makeform blocks should provide a form.widget ( from `@plotdb/form` ) as its interface. There is no other requirement - or we can say that the widget spec defines the requirement.
4
+
5
+ However, to minimize duplicated works between blocks, you can build a form block by extending `@makeform/base`. In this case you should follow the requiredment of the `@makeform/base` block and implement accordingly.
6
+
7
+
8
+ ## @makeform/base
9
+
10
+ Implement following parts when extending `@makeform/base`:
11
+
12
+ - HTML
13
+ - CSS
14
+ - JS
15
+
16
+
17
+ ### HTML
18
+
19
+ Implement `widget` plug ( for more about a `plug`, see `@plotdb/block` ) which will be used to plug into `@makeform/base`'s DOM.
20
+
21
+ Additionally, consider following `bootstrap`'s `form-group` + `label` structure when building a block-based widget. A possible construct of a widget:
22
+
23
+ .form-group
24
+ label.d-flex
25
+ div
26
+ div(ld="label")
27
+ span.variant
28
+ .flex-grow-1
29
+ .m-edit(ld="limitation")
30
+ .m-edit(ld-each="note")
31
+ .m-view(ld="content")
32
+
33
+
34
+ There is no other requirement about HTML, however `@makeform/base` expects child blocks to implement their dynamics with `ldview` ( and thus the library is preloaded in `@makeform/base` ), so consider using `ldview` before implementing a form block.
35
+
36
+
37
+ #### Additional Concepts
38
+
39
+ - `note`: list of additional notes for users.
40
+ - `limitation`: limitation of this field. should be short.
41
+ - `variant`: variation of a certain field. e.g., `zh` and `en`.
42
+ - `content`: content for viewing in view mode
43
+
44
+
45
+
46
+ ### CSS Framework
47
+
48
+ `@makeform/base` is built upon CSS Framework of following:
49
+
50
+ - bootstrap@4.6.1
51
+ - @loadingio/bootstrap.ext
52
+ - @loadingio/loading.css ( lite )
53
+ - ldiconfont
54
+ - ldbutton
55
+ - ldcover
56
+
57
+ For other CSS libraries, please import them in separated blocks.
58
+
59
+
60
+ ### CSS
61
+
62
+ Following CSS classes are preserved:
63
+
64
+ - `m-edit`: widget is rendered in edit mode ( mutual exclusive with `m-view` )
65
+ - `m-view`: widget is rendered in view mode ( mutual exclusive with `m-edit` )
66
+ - `m-inline`: widget is rendered in inline mode
67
+ - `has-variant`, `variant`
68
+ - by default `variant` isn't displayed
69
+ - use `has-variant` to show `variant` field.
70
+ - `content`: by default, content is displayed as `pre-wrap`.
71
+
72
+
73
+ ### JS
74
+
75
+ `@makeform/base`
76
+
77
+
78
+ ## Other Design Consideration
79
+
80
+ - we used to add `text-capitalize` in label but decide to remove it so user have total control of their label
package/index.html ADDED
@@ -0,0 +1 @@
1
+ <div><plug name="widget"></plug><style type="text/css">:scope{break-inside:avoid}:scope.m-view *[ld=label]{opacity:.85;text-decoration:underline}:scope.m-view .m-edit{display:none !important}:scope.m-edit .m-view{display:none !important}*[ld=content]{white-space:pre-wrap;word-break:break-all}</style><script type="@plotdb/block">module.exports={pkg:{dependencies:[{name:"proxise"},{name:"ldview"},{name:"@plotdb/form"}],i18n:{en:{required:"required"},"zh-TW":{required:"必填"}}},init:function(e){var n,i,t,r,o,d,u=this;n=e.root,i=e.data,t=e.ctx,r=e.pubsub,o=e.i18n;d=t.form;if(i.i18n){o.addResourceBundles(i.i18n)}i.config||(i.config={});return r.on("init",function(e){e==null&&(e={});u.widget=new d.widget(import$({root:n},e));u.widget.on("mode",function(i){if(!n){retrun}return["view","edit","config"].map(function(e){return n.classList.toggle("m-"+e,i===e)})});if(n){n.classList.toggle("m-edit",(e.mode||"edit")==="edit")}return u.widget.init().then(function(){u.widget.deserialize(i||{},{init:true});return u.widget})})},interface:function(){return this.widget}};function import$(e,i){var n={}.hasOwnProperty;for(var t in i)if(n.call(i,t))e[t]=i[t];return e}</script></div>
package/package.json ADDED
@@ -0,0 +1 @@
1
+ {"name":"@makeform/base","version":"1.0.0","description":"","scripts":{},"keywords":[],"author":"zbryikt","license":"MIT","dependencies":{"@plotdb/srcbuild":"^0.0.51"},"devDependencies":{"fedep":"^1.1.7"}}