form_props 0.0.3 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/form_props/action_view_extensions/form_helper.rb +8 -8
- data/lib/form_props/form_builder.rb +4 -3
- data/lib/form_props/helper.rb +534 -0
- data/lib/form_props/inputs/base.rb +7 -2
- data/lib/form_props/inputs/check_box.rb +1 -1
- data/lib/form_props/inputs/collection_check_boxes.rb +2 -2
- data/lib/form_props/inputs/collection_radio_buttons.rb +2 -2
- data/lib/form_props/inputs/radio_button.rb +1 -1
- data/lib/form_props/inputs/text_area.rb +1 -1
- data/lib/form_props/inputs/text_field.rb +1 -1
- data/lib/form_props/version.rb +1 -1
- data/lib/form_props.rb +1 -0
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c4781f03e94d7cdc4b2c3868e6283c8e3c6241e97eb869d957121b665b2deeb
|
4
|
+
data.tar.gz: c5696aaf2cd138ca74869c228dee0d1f368ed3822c72df389dbfa5d3aaa36103
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e51e3147f39f549f35d940d5b1f900213e363c6108e06b190d7d1d6dfa318795092986e87edf3cf26bbffcfa4f89b2be4fe623213acc913530902928614b7691
|
7
|
+
data.tar.gz: 63047633479d69d86f7bbd219e760e4d28825a2d2a68863266331365ccab6140cf480221ad2192ff96996a7684d5456e62423b60ae88a20f3bc30965e6368783
|
@@ -40,12 +40,12 @@ module FormProps
|
|
40
40
|
end
|
41
41
|
|
42
42
|
html_options = html_options_for_form_with(url, model, **options)
|
43
|
-
html_options["acceptCharset"] ||= html_options.delete("accept-charset")
|
44
43
|
|
45
44
|
json.extras do
|
46
45
|
extra_props_for_form(json, html_options)
|
47
46
|
end
|
48
|
-
|
47
|
+
|
48
|
+
json.props(FormProps::Helper.format_keys(html_options))
|
49
49
|
end
|
50
50
|
|
51
51
|
private
|
@@ -62,8 +62,8 @@ module FormProps
|
|
62
62
|
json.set!("csrf") do
|
63
63
|
json.name request_forgery_protection_token.to_s
|
64
64
|
json.type "hidden"
|
65
|
-
json.
|
66
|
-
json.
|
65
|
+
json.defaultValue token
|
66
|
+
json.autoComplete "off"
|
67
67
|
end
|
68
68
|
end
|
69
69
|
end
|
@@ -72,8 +72,8 @@ module FormProps
|
|
72
72
|
json.set!("method") do
|
73
73
|
json.name "_method"
|
74
74
|
json.type "hidden"
|
75
|
-
json.
|
76
|
-
json.
|
75
|
+
json.defaultValue method.to_s
|
76
|
+
json.autoComplete "off"
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
@@ -81,8 +81,8 @@ module FormProps
|
|
81
81
|
json.set!("utf8") do
|
82
82
|
json.name "utf8"
|
83
83
|
json.type "hidden"
|
84
|
-
json.
|
85
|
-
json.
|
84
|
+
json.defaultValue "✓"
|
85
|
+
json.autoComplete "off"
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
@@ -140,6 +140,7 @@ module FormProps
|
|
140
140
|
def fields_for_with_nested_attributes(association_name, association, options, block)
|
141
141
|
name = "#{object_name}[#{association_name}_attributes]"
|
142
142
|
association = convert_to_model(association)
|
143
|
+
json = @template.instance_variable_get(:@__json)
|
143
144
|
|
144
145
|
if association.respond_to?(:persisted?)
|
145
146
|
association = [association] if @object.public_send(association_name).respond_to?(:to_ary)
|
@@ -150,8 +151,8 @@ module FormProps
|
|
150
151
|
if association.respond_to?(:to_ary)
|
151
152
|
explicit_child_index = options[:child_index]
|
152
153
|
|
153
|
-
|
154
|
-
|
154
|
+
json.set!("#{association_name}Attributes") do
|
155
|
+
json.array! association do |child|
|
155
156
|
if explicit_child_index
|
156
157
|
options[:child_index] = explicit_child_index.call if explicit_child_index.respond_to?(:call)
|
157
158
|
else
|
@@ -162,7 +163,7 @@ module FormProps
|
|
162
163
|
end
|
163
164
|
end
|
164
165
|
elsif association
|
165
|
-
|
166
|
+
json.set!("#{association_name}Attributes") do
|
166
167
|
fields_for_nested_model(name, association, options, block)
|
167
168
|
end
|
168
169
|
end
|
@@ -0,0 +1,534 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Keep up to date with
|
4
|
+
# https://github.com/facebook/react/blob/main/packages/react-dom-bindings/src/shared/possibleStandardNames.js
|
5
|
+
module FormProps
|
6
|
+
POSSIBLE_STANDARD_NAMES = {
|
7
|
+
## HTML
|
8
|
+
accept: "accept",
|
9
|
+
acceptcharset: "acceptCharset",
|
10
|
+
"accept-charset": "acceptCharset",
|
11
|
+
accesskey: "accessKey",
|
12
|
+
action: "action",
|
13
|
+
allowfullscreen: "allowFullScreen",
|
14
|
+
alt: "alt",
|
15
|
+
as: "as",
|
16
|
+
async: "async",
|
17
|
+
autocapitalize: "autoCapitalize",
|
18
|
+
autocomplete: "autoComplete",
|
19
|
+
autocorrect: "autoCorrect",
|
20
|
+
autofocus: "autoFocus",
|
21
|
+
autoplay: "autoPlay",
|
22
|
+
autosave: "autoSave",
|
23
|
+
capture: "capture",
|
24
|
+
cellpadding: "cellPadding",
|
25
|
+
cellspacing: "cellSpacing",
|
26
|
+
challenge: "challenge",
|
27
|
+
charset: "charSet",
|
28
|
+
checked: "checked",
|
29
|
+
children: "children",
|
30
|
+
cite: "cite",
|
31
|
+
class: "className",
|
32
|
+
classid: "classID",
|
33
|
+
classname: "className",
|
34
|
+
cols: "cols",
|
35
|
+
colspan: "colSpan",
|
36
|
+
content: "content",
|
37
|
+
contenteditable: "contentEditable",
|
38
|
+
contextmenu: "contextMenu",
|
39
|
+
controls: "controls",
|
40
|
+
controlslist: "controlsList",
|
41
|
+
coords: "coords",
|
42
|
+
crossorigin: "crossOrigin",
|
43
|
+
dangerouslysetinnerhtml: "dangerouslySetInnerHTML",
|
44
|
+
data: "data",
|
45
|
+
datetime: "dateTime",
|
46
|
+
default: "default",
|
47
|
+
defaultchecked: "defaultChecked",
|
48
|
+
defaultvalue: "defaultValue",
|
49
|
+
defer: "defer",
|
50
|
+
dir: "dir",
|
51
|
+
disabled: "disabled",
|
52
|
+
disablepictureinpicture: "disablePictureInPicture",
|
53
|
+
disableremoteplayback: "disableRemotePlayback",
|
54
|
+
download: "download",
|
55
|
+
draggable: "draggable",
|
56
|
+
enctype: "encType",
|
57
|
+
enterkeyhint: "enterKeyHint",
|
58
|
+
fetchpriority: "fetchPriority",
|
59
|
+
for: "htmlFor",
|
60
|
+
form: "form",
|
61
|
+
formmethod: "formMethod",
|
62
|
+
formaction: "formAction",
|
63
|
+
formenctype: "formEncType",
|
64
|
+
formnovalidate: "formNoValidate",
|
65
|
+
formtarget: "formTarget",
|
66
|
+
frameborder: "frameBorder",
|
67
|
+
headers: "headers",
|
68
|
+
height: "height",
|
69
|
+
hidden: "hidden",
|
70
|
+
high: "high",
|
71
|
+
href: "href",
|
72
|
+
hreflang: "hrefLang",
|
73
|
+
htmlfor: "htmlFor",
|
74
|
+
httpequiv: "httpEquiv",
|
75
|
+
"http-equiv": "httpEquiv",
|
76
|
+
icon: "icon",
|
77
|
+
id: "id",
|
78
|
+
imagesizes: "imageSizes",
|
79
|
+
imagesrcset: "imageSrcSet",
|
80
|
+
innerhtml: "innerHTML",
|
81
|
+
inputmode: "inputMode",
|
82
|
+
integrity: "integrity",
|
83
|
+
is: "is",
|
84
|
+
itemid: "itemID",
|
85
|
+
itemprop: "itemProp",
|
86
|
+
itemref: "itemRef",
|
87
|
+
itemscope: "itemScope",
|
88
|
+
itemtype: "itemType",
|
89
|
+
keyparams: "keyParams",
|
90
|
+
keytype: "keyType",
|
91
|
+
kind: "kind",
|
92
|
+
label: "label",
|
93
|
+
lang: "lang",
|
94
|
+
list: "list",
|
95
|
+
loop: "loop",
|
96
|
+
low: "low",
|
97
|
+
manifest: "manifest",
|
98
|
+
marginwidth: "marginWidth",
|
99
|
+
marginheight: "marginHeight",
|
100
|
+
max: "max",
|
101
|
+
maxlength: "maxLength",
|
102
|
+
media: "media",
|
103
|
+
mediagroup: "mediaGroup",
|
104
|
+
method: "method",
|
105
|
+
min: "min",
|
106
|
+
minlength: "minLength",
|
107
|
+
multiple: "multiple",
|
108
|
+
muted: "muted",
|
109
|
+
name: "name",
|
110
|
+
nomodule: "noModule",
|
111
|
+
nonce: "nonce",
|
112
|
+
novalidate: "noValidate",
|
113
|
+
open: "open",
|
114
|
+
optimum: "optimum",
|
115
|
+
pattern: "pattern",
|
116
|
+
placeholder: "placeholder",
|
117
|
+
playsinline: "playsInline",
|
118
|
+
poster: "poster",
|
119
|
+
preload: "preload",
|
120
|
+
profile: "profile",
|
121
|
+
radiogroup: "radioGroup",
|
122
|
+
readonly: "readOnly",
|
123
|
+
referrerpolicy: "referrerPolicy",
|
124
|
+
rel: "rel",
|
125
|
+
required: "required",
|
126
|
+
reversed: "reversed",
|
127
|
+
role: "role",
|
128
|
+
rows: "rows",
|
129
|
+
rowspan: "rowSpan",
|
130
|
+
sandbox: "sandbox",
|
131
|
+
scope: "scope",
|
132
|
+
scoped: "scoped",
|
133
|
+
scrolling: "scrolling",
|
134
|
+
seamless: "seamless",
|
135
|
+
selected: "selected",
|
136
|
+
shape: "shape",
|
137
|
+
size: "size",
|
138
|
+
sizes: "sizes",
|
139
|
+
span: "span",
|
140
|
+
spellcheck: "spellCheck",
|
141
|
+
src: "src",
|
142
|
+
srcdoc: "srcDoc",
|
143
|
+
srclang: "srcLang",
|
144
|
+
srcset: "srcSet",
|
145
|
+
start: "start",
|
146
|
+
step: "step",
|
147
|
+
style: "style",
|
148
|
+
summary: "summary",
|
149
|
+
tabindex: "tabIndex",
|
150
|
+
target: "target",
|
151
|
+
title: "title",
|
152
|
+
type: "type",
|
153
|
+
usemap: "useMap",
|
154
|
+
value: "value",
|
155
|
+
width: "width",
|
156
|
+
wmode: "wmode",
|
157
|
+
wrap: "wrap",
|
158
|
+
|
159
|
+
# SVG
|
160
|
+
about: "about",
|
161
|
+
accentheight: "accentHeight",
|
162
|
+
"accent-height": "accentHeight",
|
163
|
+
accumulate: "accumulate",
|
164
|
+
additive: "additive",
|
165
|
+
alignmentbaseline: "alignmentBaseline",
|
166
|
+
"alignment-baseline": "alignmentBaseline",
|
167
|
+
allowreorder: "allowReorder",
|
168
|
+
alphabetic: "alphabetic",
|
169
|
+
amplitude: "amplitude",
|
170
|
+
arabicform: "arabicForm",
|
171
|
+
"arabic-form": "arabicForm",
|
172
|
+
ascent: "ascent",
|
173
|
+
attributename: "attributeName",
|
174
|
+
attributetype: "attributeType",
|
175
|
+
autoreverse: "autoReverse",
|
176
|
+
azimuth: "azimuth",
|
177
|
+
basefrequency: "baseFrequency",
|
178
|
+
baselineshift: "baselineShift",
|
179
|
+
"baseline-shift": "baselineShift",
|
180
|
+
baseprofile: "baseProfile",
|
181
|
+
bbox: "bbox",
|
182
|
+
begin: "begin",
|
183
|
+
bias: "bias",
|
184
|
+
by: "by",
|
185
|
+
calcmode: "calcMode",
|
186
|
+
capheight: "capHeight",
|
187
|
+
"cap-height": "capHeight",
|
188
|
+
clip: "clip",
|
189
|
+
clippath: "clipPath",
|
190
|
+
"clip-path": "clipPath",
|
191
|
+
clippathunits: "clipPathUnits",
|
192
|
+
cliprule: "clipRule",
|
193
|
+
"clip-rule": "clipRule",
|
194
|
+
color: "color",
|
195
|
+
colorinterpolation: "colorInterpolation",
|
196
|
+
"color-interpolation": "colorInterpolation",
|
197
|
+
colorinterpolationfilters: "colorInterpolationFilters",
|
198
|
+
"color-interpolation-filters": "colorInterpolationFilters",
|
199
|
+
colorprofile: "colorProfile",
|
200
|
+
"color-profile": "colorProfile",
|
201
|
+
colorrendering: "colorRendering",
|
202
|
+
"color-rendering": "colorRendering",
|
203
|
+
contentscripttype: "contentScriptType",
|
204
|
+
contentstyletype: "contentStyleType",
|
205
|
+
cursor: "cursor",
|
206
|
+
cx: "cx",
|
207
|
+
cy: "cy",
|
208
|
+
d: "d",
|
209
|
+
datatype: "datatype",
|
210
|
+
decelerate: "decelerate",
|
211
|
+
descent: "descent",
|
212
|
+
diffuseconstant: "diffuseConstant",
|
213
|
+
direction: "direction",
|
214
|
+
display: "display",
|
215
|
+
divisor: "divisor",
|
216
|
+
dominantbaseline: "dominantBaseline",
|
217
|
+
"dominant-baseline": "dominantBaseline",
|
218
|
+
dur: "dur",
|
219
|
+
dx: "dx",
|
220
|
+
dy: "dy",
|
221
|
+
edgemode: "edgeMode",
|
222
|
+
elevation: "elevation",
|
223
|
+
enablebackground: "enableBackground",
|
224
|
+
"enable-background": "enableBackground",
|
225
|
+
end: "end",
|
226
|
+
exponent: "exponent",
|
227
|
+
externalresourcesrequired: "externalResourcesRequired",
|
228
|
+
fill: "fill",
|
229
|
+
fillopacity: "fillOpacity",
|
230
|
+
"fill-opacity": "fillOpacity",
|
231
|
+
fillrule: "fillRule",
|
232
|
+
"fill-rule": "fillRule",
|
233
|
+
filter: "filter",
|
234
|
+
filterres: "filterRes",
|
235
|
+
filterunits: "filterUnits",
|
236
|
+
floodopacity: "floodOpacity",
|
237
|
+
"flood-opacity": "floodOpacity",
|
238
|
+
floodcolor: "floodColor",
|
239
|
+
"flood-color": "floodColor",
|
240
|
+
focusable: "focusable",
|
241
|
+
fontfamily: "fontFamily",
|
242
|
+
"font-family": "fontFamily",
|
243
|
+
fontsize: "fontSize",
|
244
|
+
"font-size": "fontSize",
|
245
|
+
fontsizeadjust: "fontSizeAdjust",
|
246
|
+
"font-size-adjust": "fontSizeAdjust",
|
247
|
+
fontstretch: "fontStretch",
|
248
|
+
"font-stretch": "fontStretch",
|
249
|
+
fontstyle: "fontStyle",
|
250
|
+
"font-style": "fontStyle",
|
251
|
+
fontvariant: "fontVariant",
|
252
|
+
"font-variant": "fontVariant",
|
253
|
+
fontweight: "fontWeight",
|
254
|
+
"font-weight": "fontWeight",
|
255
|
+
format: "format",
|
256
|
+
from: "from",
|
257
|
+
fx: "fx",
|
258
|
+
fy: "fy",
|
259
|
+
g1: "g1",
|
260
|
+
g2: "g2",
|
261
|
+
glyphname: "glyphName",
|
262
|
+
"glyph-name": "glyphName",
|
263
|
+
glyphorientationhorizontal: "glyphOrientationHorizontal",
|
264
|
+
"glyph-orientation-horizontal": "glyphOrientationHorizontal",
|
265
|
+
glyphorientationvertical: "glyphOrientationVertical",
|
266
|
+
"glyph-orientation-vertical": "glyphOrientationVertical",
|
267
|
+
glyphref: "glyphRef",
|
268
|
+
gradienttransform: "gradientTransform",
|
269
|
+
gradientunits: "gradientUnits",
|
270
|
+
hanging: "hanging",
|
271
|
+
horizadvx: "horizAdvX",
|
272
|
+
"horiz-adv-x": "horizAdvX",
|
273
|
+
horizoriginx: "horizOriginX",
|
274
|
+
"horiz-origin-x": "horizOriginX",
|
275
|
+
ideographic: "ideographic",
|
276
|
+
imagerendering: "imageRendering",
|
277
|
+
"image-rendering": "imageRendering",
|
278
|
+
in2: "in2",
|
279
|
+
in: "in",
|
280
|
+
inlist: "inlist",
|
281
|
+
intercept: "intercept",
|
282
|
+
k1: "k1",
|
283
|
+
k2: "k2",
|
284
|
+
k3: "k3",
|
285
|
+
k4: "k4",
|
286
|
+
k: "k",
|
287
|
+
kernelmatrix: "kernelMatrix",
|
288
|
+
kernelunitlength: "kernelUnitLength",
|
289
|
+
kerning: "kerning",
|
290
|
+
keypoints: "keyPoints",
|
291
|
+
keysplines: "keySplines",
|
292
|
+
keytimes: "keyTimes",
|
293
|
+
lengthadjust: "lengthAdjust",
|
294
|
+
letterspacing: "letterSpacing",
|
295
|
+
"letter-spacing": "letterSpacing",
|
296
|
+
lightingcolor: "lightingColor",
|
297
|
+
"lighting-color": "lightingColor",
|
298
|
+
limitingconeangle: "limitingConeAngle",
|
299
|
+
local: "local",
|
300
|
+
markerend: "markerEnd",
|
301
|
+
"marker-end": "markerEnd",
|
302
|
+
markerheight: "markerHeight",
|
303
|
+
markermid: "markerMid",
|
304
|
+
"marker-mid": "markerMid",
|
305
|
+
markerstart: "markerStart",
|
306
|
+
"marker-start": "markerStart",
|
307
|
+
markerunits: "markerUnits",
|
308
|
+
markerwidth: "markerWidth",
|
309
|
+
mask: "mask",
|
310
|
+
maskcontentunits: "maskContentUnits",
|
311
|
+
maskunits: "maskUnits",
|
312
|
+
mathematical: "mathematical",
|
313
|
+
mode: "mode",
|
314
|
+
numoctaves: "numOctaves",
|
315
|
+
offset: "offset",
|
316
|
+
opacity: "opacity",
|
317
|
+
operator: "operator",
|
318
|
+
order: "order",
|
319
|
+
orient: "orient",
|
320
|
+
orientation: "orientation",
|
321
|
+
origin: "origin",
|
322
|
+
overflow: "overflow",
|
323
|
+
overlineposition: "overlinePosition",
|
324
|
+
"overline-position": "overlinePosition",
|
325
|
+
overlinethickness: "overlineThickness",
|
326
|
+
"overline-thickness": "overlineThickness",
|
327
|
+
paintorder: "paintOrder",
|
328
|
+
"paint-order": "paintOrder",
|
329
|
+
panose1: "panose1",
|
330
|
+
"panose-1": "panose1",
|
331
|
+
pathlength: "pathLength",
|
332
|
+
patterncontentunits: "patternContentUnits",
|
333
|
+
patterntransform: "patternTransform",
|
334
|
+
patternunits: "patternUnits",
|
335
|
+
pointerevents: "pointerEvents",
|
336
|
+
"pointer-events": "pointerEvents",
|
337
|
+
points: "points",
|
338
|
+
pointsatx: "pointsAtX",
|
339
|
+
pointsaty: "pointsAtY",
|
340
|
+
pointsatz: "pointsAtZ",
|
341
|
+
prefix: "prefix",
|
342
|
+
preservealpha: "preserveAlpha",
|
343
|
+
preserveaspectratio: "preserveAspectRatio",
|
344
|
+
primitiveunits: "primitiveUnits",
|
345
|
+
property: "property",
|
346
|
+
r: "r",
|
347
|
+
radius: "radius",
|
348
|
+
refx: "refX",
|
349
|
+
refy: "refY",
|
350
|
+
renderingintent: "renderingIntent",
|
351
|
+
"rendering-intent": "renderingIntent",
|
352
|
+
repeatcount: "repeatCount",
|
353
|
+
repeatdur: "repeatDur",
|
354
|
+
requiredextensions: "requiredExtensions",
|
355
|
+
requiredfeatures: "requiredFeatures",
|
356
|
+
resource: "resource",
|
357
|
+
restart: "restart",
|
358
|
+
result: "result",
|
359
|
+
results: "results",
|
360
|
+
rotate: "rotate",
|
361
|
+
rx: "rx",
|
362
|
+
ry: "ry",
|
363
|
+
scale: "scale",
|
364
|
+
security: "security",
|
365
|
+
seed: "seed",
|
366
|
+
shaperendering: "shapeRendering",
|
367
|
+
"shape-rendering": "shapeRendering",
|
368
|
+
slope: "slope",
|
369
|
+
spacing: "spacing",
|
370
|
+
specularconstant: "specularConstant",
|
371
|
+
specularexponent: "specularExponent",
|
372
|
+
speed: "speed",
|
373
|
+
spreadmethod: "spreadMethod",
|
374
|
+
startoffset: "startOffset",
|
375
|
+
stddeviation: "stdDeviation",
|
376
|
+
stemh: "stemh",
|
377
|
+
stemv: "stemv",
|
378
|
+
stitchtiles: "stitchTiles",
|
379
|
+
stopcolor: "stopColor",
|
380
|
+
"stop-color": "stopColor",
|
381
|
+
stopopacity: "stopOpacity",
|
382
|
+
"stop-opacity": "stopOpacity",
|
383
|
+
strikethroughposition: "strikethroughPosition",
|
384
|
+
"strikethrough-position": "strikethroughPosition",
|
385
|
+
strikethroughthickness: "strikethroughThickness",
|
386
|
+
"strikethrough-thickness": "strikethroughThickness",
|
387
|
+
string: "string",
|
388
|
+
stroke: "stroke",
|
389
|
+
strokedasharray: "strokeDasharray",
|
390
|
+
"stroke-dasharray": "strokeDasharray",
|
391
|
+
strokedashoffset: "strokeDashoffset",
|
392
|
+
"stroke-dashoffset": "strokeDashoffset",
|
393
|
+
strokelinecap: "strokeLinecap",
|
394
|
+
"stroke-linecap": "strokeLinecap",
|
395
|
+
strokelinejoin: "strokeLinejoin",
|
396
|
+
"stroke-linejoin": "strokeLinejoin",
|
397
|
+
strokemiterlimit: "strokeMiterlimit",
|
398
|
+
"stroke-miterlimit": "strokeMiterlimit",
|
399
|
+
strokewidth: "strokeWidth",
|
400
|
+
"stroke-width": "strokeWidth",
|
401
|
+
strokeopacity: "strokeOpacity",
|
402
|
+
"stroke-opacity": "strokeOpacity",
|
403
|
+
suppresscontenteditablewarning: "suppressContentEditableWarning",
|
404
|
+
suppresshydrationwarning: "suppressHydrationWarning",
|
405
|
+
surfacescale: "surfaceScale",
|
406
|
+
systemlanguage: "systemLanguage",
|
407
|
+
tablevalues: "tableValues",
|
408
|
+
targetx: "targetX",
|
409
|
+
targety: "targetY",
|
410
|
+
textanchor: "textAnchor",
|
411
|
+
"text-anchor": "textAnchor",
|
412
|
+
textdecoration: "textDecoration",
|
413
|
+
"text-decoration": "textDecoration",
|
414
|
+
textlength: "textLength",
|
415
|
+
textrendering: "textRendering",
|
416
|
+
"text-rendering": "textRendering",
|
417
|
+
to: "to",
|
418
|
+
transform: "transform",
|
419
|
+
transformorigin: "transformOrigin",
|
420
|
+
"transform-origin": "transformOrigin",
|
421
|
+
typeof: "typeof",
|
422
|
+
u1: "u1",
|
423
|
+
u2: "u2",
|
424
|
+
underlineposition: "underlinePosition",
|
425
|
+
"underline-position": "underlinePosition",
|
426
|
+
underlinethickness: "underlineThickness",
|
427
|
+
"underline-thickness": "underlineThickness",
|
428
|
+
unicode: "unicode",
|
429
|
+
unicodebidi: "unicodeBidi",
|
430
|
+
"unicode-bidi": "unicodeBidi",
|
431
|
+
unicoderange: "unicodeRange",
|
432
|
+
"unicode-range": "unicodeRange",
|
433
|
+
unitsperem: "unitsPerEm",
|
434
|
+
"units-per-em": "unitsPerEm",
|
435
|
+
unselectable: "unselectable",
|
436
|
+
valphabetic: "vAlphabetic",
|
437
|
+
"v-alphabetic": "vAlphabetic",
|
438
|
+
values: "values",
|
439
|
+
vectoreffect: "vectorEffect",
|
440
|
+
"vector-effect": "vectorEffect",
|
441
|
+
version: "version",
|
442
|
+
vertadvy: "vertAdvY",
|
443
|
+
"vert-adv-y": "vertAdvY",
|
444
|
+
vertoriginx: "vertOriginX",
|
445
|
+
"vert-origin-x": "vertOriginX",
|
446
|
+
vertoriginy: "vertOriginY",
|
447
|
+
"vert-origin-y": "vertOriginY",
|
448
|
+
vhanging: "vHanging",
|
449
|
+
"v-hanging": "vHanging",
|
450
|
+
videographic: "vIdeographic",
|
451
|
+
"v-ideographic": "vIdeographic",
|
452
|
+
viewbox: "viewBox",
|
453
|
+
viewtarget: "viewTarget",
|
454
|
+
visibility: "visibility",
|
455
|
+
vmathematical: "vMathematical",
|
456
|
+
"v-mathematical": "vMathematical",
|
457
|
+
vocab: "vocab",
|
458
|
+
widths: "widths",
|
459
|
+
wordspacing: "wordSpacing",
|
460
|
+
"word-spacing": "wordSpacing",
|
461
|
+
writingmode: "writingMode",
|
462
|
+
"writing-mode": "writingMode",
|
463
|
+
x1: "x1",
|
464
|
+
x2: "x2",
|
465
|
+
x: "x",
|
466
|
+
xchannelselector: "xChannelSelector",
|
467
|
+
xheight: "xHeight",
|
468
|
+
"x-height": "xHeight",
|
469
|
+
xlinkactuate: "xlinkActuate",
|
470
|
+
"xlink:actuate": "xlinkActuate",
|
471
|
+
xlinkarcrole: "xlinkArcrole",
|
472
|
+
"xlink:arcrole": "xlinkArcrole",
|
473
|
+
xlinkhref: "xlinkHref",
|
474
|
+
"xlink:href": "xlinkHref",
|
475
|
+
xlinkrole: "xlinkRole",
|
476
|
+
"xlink:role": "xlinkRole",
|
477
|
+
xlinkshow: "xlinkShow",
|
478
|
+
"xlink:show": "xlinkShow",
|
479
|
+
xlinktitle: "xlinkTitle",
|
480
|
+
"xlink:title": "xlinkTitle",
|
481
|
+
xlinktype: "xlinkType",
|
482
|
+
"xlink:type": "xlinkType",
|
483
|
+
xmlbase: "xmlBase",
|
484
|
+
"xml:base": "xmlBase",
|
485
|
+
xmllang: "xmlLang",
|
486
|
+
"xml:lang": "xmlLang",
|
487
|
+
xmlns: "xmlns",
|
488
|
+
"xml:space": "xmlSpace",
|
489
|
+
xmlnsxlink: "xmlnsXlink",
|
490
|
+
"xmlns:xlink": "xmlnsXlink",
|
491
|
+
xmlspace: "xmlSpace",
|
492
|
+
y1: "y1",
|
493
|
+
y2: "y2",
|
494
|
+
y: "y",
|
495
|
+
ychannelselector: "yChannelSelector",
|
496
|
+
z: "z",
|
497
|
+
zoomandpan: "zoomAndPan"
|
498
|
+
}
|
499
|
+
|
500
|
+
OPTION_STANDARD_NAMES = {
|
501
|
+
default_value: "defaultValue",
|
502
|
+
default_checked: "defaultChecked",
|
503
|
+
checked_value: "checkedValue",
|
504
|
+
unchecked_value: "uncheckedValue",
|
505
|
+
include_hidden: "includeHidden",
|
506
|
+
include_blank: "includeBlank",
|
507
|
+
max_length: "maxLength",
|
508
|
+
min_length: "minLength",
|
509
|
+
class_name: "className",
|
510
|
+
auto_complete: "autoComplete",
|
511
|
+
read_only: "readOnly"
|
512
|
+
}
|
513
|
+
|
514
|
+
STANDARD_NAMES = POSSIBLE_STANDARD_NAMES.merge(OPTION_STANDARD_NAMES)
|
515
|
+
|
516
|
+
module Helper
|
517
|
+
extend self
|
518
|
+
|
519
|
+
def format_key(key)
|
520
|
+
if STANDARD_NAMES.has_key?(key.to_sym)
|
521
|
+
STANDARD_NAMES[key.to_sym]
|
522
|
+
else
|
523
|
+
key
|
524
|
+
end
|
525
|
+
end
|
526
|
+
|
527
|
+
def format_keys(props)
|
528
|
+
props.each_with_object({}) do |(key, val), memo|
|
529
|
+
key = format_key(key)
|
530
|
+
memo[key] = val
|
531
|
+
end
|
532
|
+
end
|
533
|
+
end
|
534
|
+
end
|
@@ -16,6 +16,10 @@ module FormProps
|
|
16
16
|
|
17
17
|
private
|
18
18
|
|
19
|
+
def sanitized_key
|
20
|
+
sanitized_method_name.camelize(:lower)
|
21
|
+
end
|
22
|
+
|
19
23
|
def add_options(option_tags, options, value = nil)
|
20
24
|
if options[:include_blank]
|
21
25
|
content = (options[:include_blank] if options[:include_blank].is_a?(String))
|
@@ -95,6 +99,7 @@ module FormProps
|
|
95
99
|
end
|
96
100
|
end
|
97
101
|
|
102
|
+
key = FormProps::Helper.format_key(key)
|
98
103
|
json.set!(key, value)
|
99
104
|
end
|
100
105
|
|
@@ -150,11 +155,11 @@ module FormProps
|
|
150
155
|
end
|
151
156
|
end
|
152
157
|
|
153
|
-
json.set!(
|
158
|
+
json.set!(sanitized_key) do
|
154
159
|
input_props(html_options)
|
155
160
|
|
156
161
|
if options.key?(:include_hidden)
|
157
|
-
json.
|
162
|
+
json.includeHidden options[:include_hidden]
|
158
163
|
end
|
159
164
|
json.options(option_tags)
|
160
165
|
end
|
@@ -21,12 +21,12 @@ module FormProps
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def render
|
24
|
-
json.set!(
|
24
|
+
json.set!(sanitized_key) do
|
25
25
|
json.collection do
|
26
26
|
render_collection_for(CheckBoxBuilder)
|
27
27
|
end
|
28
28
|
|
29
|
-
json.
|
29
|
+
json.includeHidden(@options.fetch(:include_hidden) { true })
|
30
30
|
|
31
31
|
input_props(@html_options)
|
32
32
|
end
|
@@ -20,12 +20,12 @@ module FormProps
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def render
|
23
|
-
json.set!(
|
23
|
+
json.set!(sanitized_key) do
|
24
24
|
json.collection do
|
25
25
|
render_collection_for(RadioButtonBuilder)
|
26
26
|
end
|
27
27
|
|
28
|
-
json.
|
28
|
+
json.includeHidden(@options.fetch(:include_hidden) { true })
|
29
29
|
|
30
30
|
input_props(@html_options)
|
31
31
|
end
|
@@ -22,7 +22,7 @@ module FormProps
|
|
22
22
|
@options[:value] = @tag_value
|
23
23
|
@options[:checked] = true if input_checked?(@options)
|
24
24
|
|
25
|
-
name_for_key = sanitized_method_name + "_#{sanitized_value(@tag_value)}"
|
25
|
+
name_for_key = (sanitized_method_name + "_#{sanitized_value(@tag_value)}").camelize(:lower)
|
26
26
|
|
27
27
|
body_block = -> {
|
28
28
|
add_default_name_and_id_for_value(@tag_value, @options)
|
@@ -8,7 +8,7 @@ module FormProps
|
|
8
8
|
include ActionView::Helpers::Tags::Placeholderable
|
9
9
|
|
10
10
|
def render
|
11
|
-
json.set!(
|
11
|
+
json.set!(sanitized_key) do
|
12
12
|
add_default_name_and_id(@options)
|
13
13
|
@options[:type] ||= field_type
|
14
14
|
@options[:value] = @options.fetch(:value) { value_before_type_cast }
|
@@ -12,7 +12,7 @@ module FormProps
|
|
12
12
|
@options[:type] ||= field_type
|
13
13
|
@options[:value] = @options.fetch(:value) { value_before_type_cast } unless field_type == "file"
|
14
14
|
|
15
|
-
json.set!(
|
15
|
+
json.set!(sanitized_key) do
|
16
16
|
add_default_name_and_id(@options)
|
17
17
|
input_props(@options)
|
18
18
|
end
|
data/lib/form_props/version.rb
CHANGED
data/lib/form_props.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: form_props
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Johny Ho
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-11-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.
|
47
|
+
version: 0.30.0
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.
|
54
|
+
version: 0.30.0
|
55
55
|
description: Form props is a Rails form builder that renders form attributes in JSON
|
56
56
|
email: johny@thoughtbot.com
|
57
57
|
executables: []
|
@@ -63,6 +63,7 @@ files:
|
|
63
63
|
- lib/form_props/action_view_extensions/form_helper.rb
|
64
64
|
- lib/form_props/form_builder.rb
|
65
65
|
- lib/form_props/form_options_helper.rb
|
66
|
+
- lib/form_props/helper.rb
|
66
67
|
- lib/form_props/inputs/base.rb
|
67
68
|
- lib/form_props/inputs/check_box.rb
|
68
69
|
- lib/form_props/inputs/collection_check_boxes.rb
|
@@ -106,7 +107,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
106
107
|
requirements:
|
107
108
|
- - ">="
|
108
109
|
- !ruby/object:Gem::Version
|
109
|
-
version: '2.
|
110
|
+
version: '2.7'
|
110
111
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
112
|
requirements:
|
112
113
|
- - ">="
|