@kaspernj/api-maker 1.0.2054 → 1.0.2055
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/build/api.js +64 -212
- package/build/api.js.map +1 -1
- package/build/attribute-not-loaded-error.js +2 -25
- package/build/attribute-not-loaded-error.js.map +1 -1
- package/build/base-component.js +3 -26
- package/build/base-component.js.map +1 -1
- package/build/base-error.js +20 -45
- package/build/base-error.js.map +1 -1
- package/build/base-model/attribute.js +14 -21
- package/build/base-model/attribute.js.map +1 -1
- package/build/base-model/column.js +4 -8
- package/build/base-model/column.js.map +1 -1
- package/build/base-model/reflection.js +11 -51
- package/build/base-model/reflection.js.map +1 -1
- package/build/base-model/scope.js +8 -45
- package/build/base-model/scope.js.map +1 -1
- package/build/base-model.js +583 -836
- package/build/base-model.js.map +1 -1
- package/build/bootstrap/attribute-row.js +87 -172
- package/build/bootstrap/attribute-row.js.map +1 -1
- package/build/bootstrap/attribute-rows.js +21 -50
- package/build/bootstrap/attribute-rows.js.map +1 -1
- package/build/bootstrap/card.js +76 -159
- package/build/bootstrap/card.js.map +1 -1
- package/build/bootstrap/checkbox.js +53 -102
- package/build/bootstrap/checkbox.js.map +1 -1
- package/build/bootstrap/checkboxes.js +116 -202
- package/build/bootstrap/checkboxes.js.map +1 -1
- package/build/bootstrap/input.js +80 -131
- package/build/bootstrap/input.js.map +1 -1
- package/build/bootstrap/invalid-feedback.js +18 -46
- package/build/bootstrap/invalid-feedback.js.map +1 -1
- package/build/bootstrap/paginate.js +99 -164
- package/build/bootstrap/paginate.js.map +1 -1
- package/build/bootstrap/radio-buttons.js +43 -80
- package/build/bootstrap/radio-buttons.js.map +1 -1
- package/build/bootstrap/select.js +43 -90
- package/build/bootstrap/select.js.map +1 -1
- package/build/bootstrap/sort-link.js +68 -151
- package/build/bootstrap/sort-link.js.map +1 -1
- package/build/cable-connection-pool.js +43 -65
- package/build/cable-connection-pool.js.map +1 -1
- package/build/cable-subscription-pool.js +104 -161
- package/build/cable-subscription-pool.js.map +1 -1
- package/build/cable-subscription.js +9 -16
- package/build/cable-subscription.js.map +1 -1
- package/build/cache-key-generator.js +27 -36
- package/build/cache-key-generator.js.map +1 -1
- package/build/can-can.js +80 -201
- package/build/can-can.js.map +1 -1
- package/build/channels-consumer.js +5 -10
- package/build/channels-consumer.js.map +1 -1
- package/build/collection-loader.js +35 -53
- package/build/collection-loader.js.map +1 -1
- package/build/collection.js +160 -307
- package/build/collection.js.map +1 -1
- package/build/command-submit-data.d.ts +1 -1
- package/build/command-submit-data.d.ts.map +1 -1
- package/build/command-submit-data.js +29 -38
- package/build/command-submit-data.js.map +1 -1
- package/build/commands-pool.js +139 -215
- package/build/commands-pool.js.map +1 -1
- package/build/compose.js +3 -11
- package/build/compose.js.map +1 -1
- package/build/config.js +20 -67
- package/build/config.js.map +1 -1
- package/build/custom-error.js +4 -29
- package/build/custom-error.js.map +1 -1
- package/build/data-set-to-attributes.js +5 -41
- package/build/data-set-to-attributes.js.map +1 -1
- package/build/deserializer.js +26 -79
- package/build/deserializer.js.map +1 -1
- package/build/destroy-error.js +4 -29
- package/build/destroy-error.js.map +1 -1
- package/build/devise.js +83 -187
- package/build/devise.js.map +1 -1
- package/build/draggable-sort/controller.js +87 -110
- package/build/draggable-sort/controller.js.map +1 -1
- package/build/draggable-sort/index.js +67 -144
- package/build/draggable-sort/index.js.map +1 -1
- package/build/draggable-sort/item.js +131 -197
- package/build/draggable-sort/item.js.map +1 -1
- package/build/error-logger.js +78 -163
- package/build/error-logger.js.map +1 -1
- package/build/error-messages.js +4 -7
- package/build/error-messages.js.map +1 -1
- package/build/event-connection.js +23 -61
- package/build/event-connection.js.map +1 -1
- package/build/event-emitter-listener.js +6 -23
- package/build/event-emitter-listener.js.map +1 -1
- package/build/event-model-class.js +19 -46
- package/build/event-model-class.js.map +1 -1
- package/build/events.js +3 -8
- package/build/events.js.map +1 -1
- package/build/form.js +65 -153
- package/build/form.js.map +1 -1
- package/build/history-expo.js +12 -24
- package/build/history-expo.js.map +1 -1
- package/build/history-react-native.js +14 -26
- package/build/history-react-native.js.map +1 -1
- package/build/history.js +2 -4
- package/build/history.js.map +1 -1
- package/build/index.js +2 -5
- package/build/index.js.map +1 -1
- package/build/inputs/attachment.js +71 -122
- package/build/inputs/attachment.js.map +1 -1
- package/build/inputs/auto-submit.js +15 -54
- package/build/inputs/auto-submit.js.map +1 -1
- package/build/inputs/checkbox.js +77 -166
- package/build/inputs/checkbox.js.map +1 -1
- package/build/inputs/checkboxes.js +75 -158
- package/build/inputs/checkboxes.js.map +1 -1
- package/build/inputs/id-for-component.js +4 -40
- package/build/inputs/id-for-component.js.map +1 -1
- package/build/inputs/input-wrapper.js +7 -26
- package/build/inputs/input-wrapper.js.map +1 -1
- package/build/inputs/input.js +158 -244
- package/build/inputs/input.js.map +1 -1
- package/build/inputs/money.js +123 -185
- package/build/inputs/money.js.map +1 -1
- package/build/inputs/name-for-component.js +4 -40
- package/build/inputs/name-for-component.js.map +1 -1
- package/build/inputs/select.js +68 -122
- package/build/inputs/select.js.map +1 -1
- package/build/instance-of-class-name.js +15 -20
- package/build/instance-of-class-name.js.map +1 -1
- package/build/is-expo.js +8 -10
- package/build/is-expo.js.map +1 -1
- package/build/key-value-store.js +51 -127
- package/build/key-value-store.js.map +1 -1
- package/build/link.js +51 -114
- package/build/link.js.map +1 -1
- package/build/logger.js +19 -25
- package/build/logger.js.map +1 -1
- package/build/merge-styles.js +5 -9
- package/build/merge-styles.js.map +1 -1
- package/build/modal.js +14 -61
- package/build/modal.js.map +1 -1
- package/build/model-class-require.js +8 -43
- package/build/model-class-require.js.map +1 -1
- package/build/model-events.js +24 -33
- package/build/model-events.js.map +1 -1
- package/build/model-name.js +15 -56
- package/build/model-name.js.map +1 -1
- package/build/model-prop-type.js +51 -62
- package/build/model-prop-type.js.map +1 -1
- package/build/model-recipes-loader.js +16 -24
- package/build/model-recipes-loader.js.map +1 -1
- package/build/model-recipes-model-loader.d.ts +1 -1
- package/build/model-recipes-model-loader.js +129 -207
- package/build/model-recipes-model-loader.js.map +1 -1
- package/build/models-response-reader.js +24 -65
- package/build/models-response-reader.js.map +1 -1
- package/build/models.js +5 -10
- package/build/models.js.map +1 -1
- package/build/money-formatter.d.ts +2 -2
- package/build/money-formatter.d.ts.map +1 -1
- package/build/money-formatter.js +45 -55
- package/build/money-formatter.js.map +1 -1
- package/build/not-loaded-error.js +2 -25
- package/build/not-loaded-error.js.map +1 -1
- package/build/params.js +31 -41
- package/build/params.js.map +1 -1
- package/build/preloaded.js +18 -58
- package/build/preloaded.js.map +1 -1
- package/build/resize-observer.js +5 -11
- package/build/resize-observer.js.map +1 -1
- package/build/rest-props-validator.js +4 -6
- package/build/rest-props-validator.js.map +1 -1
- package/build/result.js +10 -14
- package/build/result.js.map +1 -1
- package/build/router/route.js +178 -311
- package/build/router/route.js.map +1 -1
- package/build/router/switch.js +55 -129
- package/build/router/switch.js.map +1 -1
- package/build/router.js +33 -93
- package/build/router.js.map +1 -1
- package/build/routes-native.js +63 -147
- package/build/routes-native.js.map +1 -1
- package/build/routes.js +25 -79
- package/build/routes.js.map +1 -1
- package/build/run-last.js +19 -24
- package/build/run-last.js.map +1 -1
- package/build/serializer.js +28 -33
- package/build/serializer.js.map +1 -1
- package/build/services.js +9 -18
- package/build/services.js.map +1 -1
- package/build/session-status-updater.js +84 -183
- package/build/session-status-updater.js.map +1 -1
- package/build/source-maps-loader.d.ts +37 -0
- package/build/source-maps-loader.d.ts.map +1 -0
- package/build/source-maps-loader.js +102 -224
- package/build/source-maps-loader.js.map +1 -1
- package/build/super-admin/config-reader.d.ts +2 -2
- package/build/super-admin/config-reader.js +41 -82
- package/build/super-admin/config-reader.js.map +1 -1
- package/build/super-admin/edit-page/edit-attribute-checkbox.js +52 -114
- package/build/super-admin/edit-page/edit-attribute-checkbox.js.map +1 -1
- package/build/super-admin/edit-page/edit-attribute-content.js +46 -76
- package/build/super-admin/edit-page/edit-attribute-content.js.map +1 -1
- package/build/super-admin/edit-page/edit-attribute-input.js +56 -118
- package/build/super-admin/edit-page/edit-attribute-input.js.map +1 -1
- package/build/super-admin/edit-page/edit-attribute.js +39 -103
- package/build/super-admin/edit-page/edit-attribute.js.map +1 -1
- package/build/super-admin/edit-page.js +87 -200
- package/build/super-admin/edit-page.js.map +1 -1
- package/build/super-admin/has-edit-config.js +6 -12
- package/build/super-admin/has-edit-config.js.map +1 -1
- package/build/super-admin/index-page.js +16 -43
- package/build/super-admin/index-page.js.map +1 -1
- package/build/super-admin/index.js +86 -209
- package/build/super-admin/index.js.map +1 -1
- package/build/super-admin/layout/header/index.js +90 -151
- package/build/super-admin/layout/header/index.js.map +1 -1
- package/build/super-admin/layout/index.js +69 -152
- package/build/super-admin/layout/index.js.map +1 -1
- package/build/super-admin/layout/menu/index.js +84 -160
- package/build/super-admin/layout/menu/index.js.map +1 -1
- package/build/super-admin/layout/menu/menu-content.js +24 -84
- package/build/super-admin/layout/menu/menu-content.js.map +1 -1
- package/build/super-admin/layout/menu/menu-item.js +51 -101
- package/build/super-admin/layout/menu/menu-item.js.map +1 -1
- package/build/super-admin/layout/no-access.js +18 -44
- package/build/super-admin/layout/no-access.js.map +1 -1
- package/build/super-admin/model-class-table.js +44 -128
- package/build/super-admin/model-class-table.js.map +1 -1
- package/build/super-admin/models.js +5 -41
- package/build/super-admin/models.js.map +1 -1
- package/build/super-admin/show-nav.js +26 -88
- package/build/super-admin/show-nav.js.map +1 -1
- package/build/super-admin/show-page/belongs-to-attribute-row.js +17 -75
- package/build/super-admin/show-page/belongs-to-attribute-row.js.map +1 -1
- package/build/super-admin/show-page/index.js +100 -186
- package/build/super-admin/show-page/index.js.map +1 -1
- package/build/super-admin/show-reflection-actions.js +38 -99
- package/build/super-admin/show-reflection-actions.js.map +1 -1
- package/build/super-admin/show-reflection-link.js +26 -98
- package/build/super-admin/show-reflection-link.js.map +1 -1
- package/build/super-admin/show-reflection-page.js +33 -96
- package/build/super-admin/show-reflection-page.js.map +1 -1
- package/build/table/column-content.js +76 -120
- package/build/table/column-content.js.map +1 -1
- package/build/table/column-identifier.js +6 -10
- package/build/table/column-identifier.js.map +1 -1
- package/build/table/column-visible.js +1 -4
- package/build/table/column-visible.js.map +1 -1
- package/build/table/components/column.js +12 -59
- package/build/table/components/column.js.map +1 -1
- package/build/table/components/flat-list.js +12 -59
- package/build/table/components/flat-list.js.map +1 -1
- package/build/table/components/header.js +14 -61
- package/build/table/components/header.js.map +1 -1
- package/build/table/components/row.js +15 -62
- package/build/table/components/row.js.map +1 -1
- package/build/table/filters/attribute-element.js +33 -61
- package/build/table/filters/attribute-element.js.map +1 -1
- package/build/table/filters/filter-form.js +279 -482
- package/build/table/filters/filter-form.js.map +1 -1
- package/build/table/filters/filter.js +44 -72
- package/build/table/filters/filter.js.map +1 -1
- package/build/table/filters/index.js +94 -138
- package/build/table/filters/index.js.map +1 -1
- package/build/table/filters/load-search-modal.js +63 -211
- package/build/table/filters/load-search-modal.js.map +1 -1
- package/build/table/filters/reflection-element.js +26 -54
- package/build/table/filters/reflection-element.js.map +1 -1
- package/build/table/filters/save-search-modal.js +43 -139
- package/build/table/filters/save-search-modal.js.map +1 -1
- package/build/table/filters/scope-element.js +27 -55
- package/build/table/filters/scope-element.js.map +1 -1
- package/build/table/header-column-content.js +32 -70
- package/build/table/header-column-content.js.map +1 -1
- package/build/table/header-column.js +88 -217
- package/build/table/header-column.js.map +1 -1
- package/build/table/header-select.js +44 -76
- package/build/table/header-select.js.map +1 -1
- package/build/table/model-callback-args.js +4 -40
- package/build/table/model-callback-args.js.map +1 -1
- package/build/table/model-column.js +58 -143
- package/build/table/model-column.js.map +1 -1
- package/build/table/model-row.js +74 -186
- package/build/table/model-row.js.map +1 -1
- package/build/table/select-calculator.js +26 -85
- package/build/table/select-calculator.js.map +1 -1
- package/build/table/settings/column-row.js +65 -185
- package/build/table/settings/column-row.js.map +1 -1
- package/build/table/settings/download-action.js +37 -73
- package/build/table/settings/download-action.js.map +1 -1
- package/build/table/settings/index.js +37 -101
- package/build/table/settings/index.js.map +1 -1
- package/build/table/table-settings.js +184 -322
- package/build/table/table-settings.js.map +1 -1
- package/build/table/table.js +582 -780
- package/build/table/table.js.map +1 -1
- package/build/table/use-sorting.js +15 -34
- package/build/table/use-sorting.js.map +1 -1
- package/build/table/widths.js +31 -37
- package/build/table/widths.js.map +1 -1
- package/build/table/worker-plugins-check-all-checkbox.js +76 -224
- package/build/table/worker-plugins-check-all-checkbox.js.map +1 -1
- package/build/table/worker-plugins-checkbox.js +73 -184
- package/build/table/worker-plugins-checkbox.js.map +1 -1
- package/build/translated-attributes.js +5 -10
- package/build/translated-attributes.js.map +1 -1
- package/build/translated-collections.js +10 -19
- package/build/translated-collections.js.map +1 -1
- package/build/updated-attribute.js +46 -119
- package/build/updated-attribute.js.map +1 -1
- package/build/url-encode.js +5 -11
- package/build/url-encode.js.map +1 -1
- package/build/use-breakpoint.js +42 -94
- package/build/use-breakpoint.js.map +1 -1
- package/build/use-can-can.js +29 -91
- package/build/use-can-can.js.map +1 -1
- package/build/use-collection.js +118 -228
- package/build/use-collection.js.map +1 -1
- package/build/use-created-event.js +26 -43
- package/build/use-created-event.js.map +1 -1
- package/build/use-current-user-context.js +56 -150
- package/build/use-current-user-context.js.map +1 -1
- package/build/use-current-user.js +13 -31
- package/build/use-current-user.js.map +1 -1
- package/build/use-destroyed-event.js +21 -42
- package/build/use-destroyed-event.js.map +1 -1
- package/build/use-event-emitter.js +9 -14
- package/build/use-event-emitter.js.map +1 -1
- package/build/use-event-listener.js +12 -21
- package/build/use-event-listener.js.map +1 -1
- package/build/use-input.js +48 -68
- package/build/use-input.js.map +1 -1
- package/build/use-model-event.js +21 -42
- package/build/use-model-event.js.map +1 -1
- package/build/use-model.js +95 -198
- package/build/use-model.js.map +1 -1
- package/build/use-resize-observer.js +10 -20
- package/build/use-resize-observer.js.map +1 -1
- package/build/use-router.js +64 -106
- package/build/use-router.js.map +1 -1
- package/build/use-screen-layout.js +16 -18
- package/build/use-screen-layout.js.map +1 -1
- package/build/use-styles.js +23 -74
- package/build/use-styles.js.map +1 -1
- package/build/use-updated-event.js +21 -43
- package/build/use-updated-event.js.map +1 -1
- package/build/use-validation-errors.js +11 -17
- package/build/use-validation-errors.js.map +1 -1
- package/build/utils/button.js +85 -135
- package/build/utils/button.js.map +1 -1
- package/build/utils/card.js +30 -105
- package/build/utils/card.js.map +1 -1
- package/build/utils/checkbox.js +50 -111
- package/build/utils/checkbox.js.map +1 -1
- package/build/utils/checkboxes.js +108 -181
- package/build/utils/checkboxes.js.map +1 -1
- package/build/utils/default-style.js +28 -102
- package/build/utils/default-style.js.map +1 -1
- package/build/utils/header.js +7 -34
- package/build/utils/header.js.map +1 -1
- package/build/utils/icon.js +35 -116
- package/build/utils/icon.js.map +1 -1
- package/build/utils/invalid-feedback.js +15 -42
- package/build/utils/invalid-feedback.js.map +1 -1
- package/build/utils/modal.js +24 -107
- package/build/utils/modal.js.map +1 -1
- package/build/utils/text.js +9 -36
- package/build/utils/text.js.map +1 -1
- package/build/validation-error.js +30 -88
- package/build/validation-error.js.map +1 -1
- package/build/validation-errors.js +60 -110
- package/build/validation-errors.js.map +1 -1
- package/build/with-api-maker.js +14 -66
- package/build/with-api-maker.js.map +1 -1
- package/build/with-collection.js +13 -63
- package/build/with-collection.js.map +1 -1
- package/build/with-current-user.js +6 -22
- package/build/with-current-user.js.map +1 -1
- package/build/with-model.js +10 -26
- package/build/with-model.js.map +1 -1
- package/build/with-router.js +7 -34
- package/build/with-router.js.map +1 -1
- package/package.json +1 -1
package/build/inputs/money.js
CHANGED
|
@@ -1,191 +1,129 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React, { useRef } from "react";
|
|
3
|
+
import { shapeComponent, ShapeComponent } from "set-state-compare/build/shape-component.js";
|
|
4
|
+
import classNames from "classnames";
|
|
5
|
+
import Config from "../config.js";
|
|
6
|
+
import { digg } from "diggerize";
|
|
7
|
+
import idForComponent from "./id-for-component.js";
|
|
8
|
+
import * as inflection from "inflection";
|
|
9
|
+
import memo from "set-state-compare/build/memo.js";
|
|
10
|
+
import MoneyFormatter from "../money-formatter.js";
|
|
11
|
+
import PropTypes from "prop-types";
|
|
12
|
+
import PropTypesExact from "prop-types-exact";
|
|
13
|
+
export default memo(shapeComponent(class ApiMakerInputsMoney extends ShapeComponent {
|
|
14
|
+
static defaultProps = {
|
|
15
|
+
disabled: false,
|
|
16
|
+
showCurrencyOptions: true
|
|
15
17
|
};
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
static propTypes = PropTypesExact({
|
|
19
|
+
attribute: PropTypes.string,
|
|
20
|
+
centsInputName: PropTypes.string,
|
|
21
|
+
className: PropTypes.string,
|
|
22
|
+
currenciesCollection: PropTypes.array,
|
|
23
|
+
currencyName: PropTypes.string,
|
|
24
|
+
currencyRef: PropTypes.object,
|
|
25
|
+
defaultValue: PropTypes.object,
|
|
26
|
+
disabled: PropTypes.bool.isRequired,
|
|
27
|
+
id: PropTypes.string,
|
|
28
|
+
inputRef: PropTypes.object,
|
|
29
|
+
label: PropTypes.any,
|
|
30
|
+
model: PropTypes.object,
|
|
31
|
+
name: PropTypes.string,
|
|
32
|
+
onChange: PropTypes.func,
|
|
33
|
+
placeholder: PropTypes.any,
|
|
34
|
+
showCurrencyOptions: PropTypes.bool,
|
|
35
|
+
small: PropTypes.bool,
|
|
36
|
+
type: PropTypes.string,
|
|
37
|
+
wholeRef: PropTypes.object
|
|
38
|
+
});
|
|
39
|
+
setup() {
|
|
40
|
+
this.inputRef = useRef();
|
|
41
|
+
this.currencyRefBackup = useRef();
|
|
42
|
+
this.currencyRef = this.props.currencyRef || this.currencyRefBackup;
|
|
43
|
+
this.wholeRefBackup = useRef();
|
|
44
|
+
this.wholeRef = this.props.wholeRef || this.wholeRefBackup;
|
|
22
45
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
};
|
|
40
|
-
|
|
46
|
+
getInputRef = () => this.props.inputRef || this.inputRef;
|
|
47
|
+
render() {
|
|
48
|
+
const { attribute, className, disabled, model, showCurrencyOptions } = this.props;
|
|
49
|
+
let { currenciesCollection } = this.props;
|
|
50
|
+
if (!currenciesCollection)
|
|
51
|
+
currenciesCollection = Config.getCurrenciesCollection();
|
|
52
|
+
return (_jsxs("div", { className: "api-maker-inputs-money", "data-attribute": attribute, "data-model-id": model?.id(), children: [_jsx("input", { defaultValue: this.inputDefaultCentsValue(), id: this.inputCentsId(), name: this.inputCentsName(), ref: this.getInputRef(), type: "hidden" }), _jsx("input", { className: classNames("money-cents", className), defaultValue: this.inputDefaultValue(), disabled: disabled, id: this.inputId(), onBlur: this.tt.setAmount, onChange: this.tt.setCents, onKeyUp: this.tt.setCents, placeholder: this.props.placeholder, ref: this.tt.wholeRef, type: "text" }), showCurrencyOptions &&
|
|
53
|
+
_jsxs("select", { className: "money-currency", defaultValue: this.inputCurrencyValue(), disabled: disabled, id: this.inputCurrencyId(), name: this.inputCurrencyName(), onChange: this.tt.onCurrencyChanged, ref: this.tt.currencyRef, children: [_jsx("option", {}), currenciesCollection.map((option) => (_jsxs("option", { value: option[1], children: [this.props.small && option[1], !this.props.small && option[0]] }, `select-option-${option[1]}`)))] })] }));
|
|
54
|
+
}
|
|
55
|
+
inputCurrencyId = () => `${this.inputId()}_currency`;
|
|
56
|
+
inputCurrencyName() {
|
|
57
|
+
if ("currencyName" in this.props)
|
|
58
|
+
return this.props.currencyName;
|
|
59
|
+
return `${this.props.model.modelClassData().paramKey}[${inflection.underscore(this.props.attribute)}_currency]`;
|
|
60
|
+
}
|
|
61
|
+
inputCurrencyValue() {
|
|
62
|
+
const { defaultValue } = this.props;
|
|
63
|
+
if (defaultValue) {
|
|
64
|
+
return MoneyFormatter.currencyFromMoney(defaultValue).code;
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
return "DKK";
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
inputDefaultValue() {
|
|
71
|
+
const { defaultValue } = this.props;
|
|
72
|
+
if (defaultValue) {
|
|
73
|
+
return MoneyFormatter.fromMoney({ amount: defaultValue.amount, currency: this.inputCurrencyValue() }, { decimals: 2, excludeCurrency: true }).toString();
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
return "";
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
inputDefaultCentsValue() {
|
|
80
|
+
const { defaultValue } = this.props;
|
|
81
|
+
if (this.getInputRef().current) {
|
|
82
|
+
return digg(this.getInputRef(), "current", "value");
|
|
83
|
+
}
|
|
84
|
+
else if (defaultValue) {
|
|
85
|
+
return MoneyFormatter.amountFromMoney(defaultValue);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
inputCentsId = () => `${this.inputId()}_cents`;
|
|
89
|
+
inputCentsName() {
|
|
90
|
+
if ("name" in this.props)
|
|
91
|
+
return this.props.name;
|
|
92
|
+
return `${this.props.model.modelClassData().paramKey}[${inflection.underscore(this.props.attribute)}_cents]`;
|
|
93
|
+
}
|
|
94
|
+
inputId = () => idForComponent(this);
|
|
95
|
+
onCurrencyChanged = () => {
|
|
96
|
+
if (this.props.onChange)
|
|
97
|
+
this.props.onChange();
|
|
41
98
|
};
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
99
|
+
setAmount = () => {
|
|
100
|
+
const inputElement = this.getInputRef().current;
|
|
101
|
+
if (!inputElement)
|
|
102
|
+
return;
|
|
103
|
+
if (!inputElement.value && inputElement.value == "") {
|
|
104
|
+
this.wholeRef.current.value = "";
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
const cents = parseFloat(inputElement.value);
|
|
108
|
+
const formatted = MoneyFormatter.fromMoney({ amount: cents, currency: this.inputCurrencyValue() }, { decimals: 2, excludeCurrency: true }).toString();
|
|
109
|
+
this.wholeRef.current.value = formatted;
|
|
110
|
+
}
|
|
48
111
|
};
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
var classnames_1 = __importDefault(require("classnames"));
|
|
59
|
-
var config_js_1 = __importDefault(require("../config.js"));
|
|
60
|
-
var diggerize_1 = require("diggerize");
|
|
61
|
-
var id_for_component_js_1 = __importDefault(require("./id-for-component.js"));
|
|
62
|
-
var inflection = __importStar(require("inflection"));
|
|
63
|
-
var memo_js_1 = __importDefault(require("set-state-compare/build/memo.js"));
|
|
64
|
-
var money_formatter_js_1 = __importDefault(require("../money-formatter.js"));
|
|
65
|
-
var prop_types_1 = __importDefault(require("prop-types"));
|
|
66
|
-
var prop_types_exact_1 = __importDefault(require("prop-types-exact"));
|
|
67
|
-
exports.default = (0, memo_js_1.default)((0, shape_component_js_1.shapeComponent)((_a = /** @class */ (function (_super) {
|
|
68
|
-
__extends(ApiMakerInputsMoney, _super);
|
|
69
|
-
function ApiMakerInputsMoney() {
|
|
70
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
71
|
-
_this.getInputRef = function () { return _this.props.inputRef || _this.inputRef; };
|
|
72
|
-
_this.inputCurrencyId = function () { return "".concat(_this.inputId(), "_currency"); };
|
|
73
|
-
_this.inputCentsId = function () { return "".concat(_this.inputId(), "_cents"); };
|
|
74
|
-
_this.inputId = function () { return (0, id_for_component_js_1.default)(_this); };
|
|
75
|
-
_this.onCurrencyChanged = function () {
|
|
76
|
-
if (_this.props.onChange)
|
|
77
|
-
_this.props.onChange();
|
|
78
|
-
};
|
|
79
|
-
_this.setAmount = function () {
|
|
80
|
-
var inputElement = _this.getInputRef().current;
|
|
81
|
-
if (!inputElement)
|
|
82
|
-
return;
|
|
83
|
-
if (!inputElement.value && inputElement.value == "") {
|
|
84
|
-
_this.wholeRef.current.value = "";
|
|
85
|
-
}
|
|
86
|
-
else {
|
|
87
|
-
var cents = parseFloat(inputElement.value);
|
|
88
|
-
var formatted = money_formatter_js_1.default.fromMoney({ amount: cents, currency: _this.inputCurrencyValue() }, { decimals: 2, excludeCurrency: true }).toString();
|
|
89
|
-
_this.wholeRef.current.value = formatted;
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
_this.setCents = function () {
|
|
93
|
-
var inputElement = _this.getInputRef().current;
|
|
94
|
-
if (!inputElement)
|
|
95
|
-
return;
|
|
96
|
-
var whole = money_formatter_js_1.default.stringToFloat(_this.wholeRef.current.value);
|
|
97
|
-
var cents = parseInt(whole * 100, 10);
|
|
98
|
-
var oldCents = parseInt(inputElement.value, 10);
|
|
99
|
-
if (typeof cents == "number") {
|
|
100
|
-
inputElement.value = cents;
|
|
101
|
-
}
|
|
102
|
-
else {
|
|
103
|
-
inputElement.value = '';
|
|
104
|
-
}
|
|
105
|
-
if (_this.props.onChange && oldCents != cents)
|
|
106
|
-
_this.props.onChange();
|
|
107
|
-
};
|
|
108
|
-
return _this;
|
|
112
|
+
setCents = () => {
|
|
113
|
+
const inputElement = this.getInputRef().current;
|
|
114
|
+
if (!inputElement)
|
|
115
|
+
return;
|
|
116
|
+
let whole = MoneyFormatter.stringToFloat(this.wholeRef.current.value);
|
|
117
|
+
let cents = parseInt(whole * 100, 10);
|
|
118
|
+
let oldCents = parseInt(inputElement.value, 10);
|
|
119
|
+
if (typeof cents == "number") {
|
|
120
|
+
inputElement.value = cents;
|
|
109
121
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
this.
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
ApiMakerInputsMoney.prototype.render = function () {
|
|
118
|
-
var _this = this;
|
|
119
|
-
var _b = this.props, attribute = _b.attribute, className = _b.className, disabled = _b.disabled, model = _b.model, showCurrencyOptions = _b.showCurrencyOptions;
|
|
120
|
-
var currenciesCollection = this.props.currenciesCollection;
|
|
121
|
-
if (!currenciesCollection)
|
|
122
|
-
currenciesCollection = config_js_1.default.getCurrenciesCollection();
|
|
123
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: "api-maker-inputs-money", "data-attribute": attribute, "data-model-id": model === null || model === void 0 ? void 0 : model.id(), children: [(0, jsx_runtime_1.jsx)("input", { defaultValue: this.inputDefaultCentsValue(), id: this.inputCentsId(), name: this.inputCentsName(), ref: this.getInputRef(), type: "hidden" }), (0, jsx_runtime_1.jsx)("input", { className: (0, classnames_1.default)("money-cents", className), defaultValue: this.inputDefaultValue(), disabled: disabled, id: this.inputId(), onBlur: this.tt.setAmount, onChange: this.tt.setCents, onKeyUp: this.tt.setCents, placeholder: this.props.placeholder, ref: this.tt.wholeRef, type: "text" }), showCurrencyOptions &&
|
|
124
|
-
(0, jsx_runtime_1.jsxs)("select", { className: "money-currency", defaultValue: this.inputCurrencyValue(), disabled: disabled, id: this.inputCurrencyId(), name: this.inputCurrencyName(), onChange: this.tt.onCurrencyChanged, ref: this.tt.currencyRef, children: [(0, jsx_runtime_1.jsx)("option", {}), currenciesCollection.map(function (option) { return ((0, jsx_runtime_1.jsxs)("option", { value: option[1], children: [_this.props.small && option[1], !_this.props.small && option[0]] }, "select-option-".concat(option[1]))); })] })] }));
|
|
125
|
-
};
|
|
126
|
-
ApiMakerInputsMoney.prototype.inputCurrencyName = function () {
|
|
127
|
-
if ("currencyName" in this.props)
|
|
128
|
-
return this.props.currencyName;
|
|
129
|
-
return "".concat(this.props.model.modelClassData().paramKey, "[").concat(inflection.underscore(this.props.attribute), "_currency]");
|
|
130
|
-
};
|
|
131
|
-
ApiMakerInputsMoney.prototype.inputCurrencyValue = function () {
|
|
132
|
-
var defaultValue = this.props.defaultValue;
|
|
133
|
-
if (defaultValue) {
|
|
134
|
-
return money_formatter_js_1.default.currencyFromMoney(defaultValue).code;
|
|
135
|
-
}
|
|
136
|
-
else {
|
|
137
|
-
return "DKK";
|
|
138
|
-
}
|
|
139
|
-
};
|
|
140
|
-
ApiMakerInputsMoney.prototype.inputDefaultValue = function () {
|
|
141
|
-
var defaultValue = this.props.defaultValue;
|
|
142
|
-
if (defaultValue) {
|
|
143
|
-
return money_formatter_js_1.default.fromMoney({ amount: defaultValue.amount, currency: this.inputCurrencyValue() }, { decimals: 2, excludeCurrency: true }).toString();
|
|
144
|
-
}
|
|
145
|
-
else {
|
|
146
|
-
return "";
|
|
147
|
-
}
|
|
148
|
-
};
|
|
149
|
-
ApiMakerInputsMoney.prototype.inputDefaultCentsValue = function () {
|
|
150
|
-
var defaultValue = this.props.defaultValue;
|
|
151
|
-
if (this.getInputRef().current) {
|
|
152
|
-
return (0, diggerize_1.digg)(this.getInputRef(), "current", "value");
|
|
153
|
-
}
|
|
154
|
-
else if (defaultValue) {
|
|
155
|
-
return money_formatter_js_1.default.amountFromMoney(defaultValue);
|
|
156
|
-
}
|
|
157
|
-
};
|
|
158
|
-
ApiMakerInputsMoney.prototype.inputCentsName = function () {
|
|
159
|
-
if ("name" in this.props)
|
|
160
|
-
return this.props.name;
|
|
161
|
-
return "".concat(this.props.model.modelClassData().paramKey, "[").concat(inflection.underscore(this.props.attribute), "_cents]");
|
|
162
|
-
};
|
|
163
|
-
return ApiMakerInputsMoney;
|
|
164
|
-
}(shape_component_js_1.ShapeComponent)),
|
|
165
|
-
_a.defaultProps = {
|
|
166
|
-
disabled: false,
|
|
167
|
-
showCurrencyOptions: true
|
|
168
|
-
},
|
|
169
|
-
_a.propTypes = (0, prop_types_exact_1.default)({
|
|
170
|
-
attribute: prop_types_1.default.string,
|
|
171
|
-
centsInputName: prop_types_1.default.string,
|
|
172
|
-
className: prop_types_1.default.string,
|
|
173
|
-
currenciesCollection: prop_types_1.default.array,
|
|
174
|
-
currencyName: prop_types_1.default.string,
|
|
175
|
-
currencyRef: prop_types_1.default.object,
|
|
176
|
-
defaultValue: prop_types_1.default.object,
|
|
177
|
-
disabled: prop_types_1.default.bool.isRequired,
|
|
178
|
-
id: prop_types_1.default.string,
|
|
179
|
-
inputRef: prop_types_1.default.object,
|
|
180
|
-
label: prop_types_1.default.any,
|
|
181
|
-
model: prop_types_1.default.object,
|
|
182
|
-
name: prop_types_1.default.string,
|
|
183
|
-
onChange: prop_types_1.default.func,
|
|
184
|
-
placeholder: prop_types_1.default.any,
|
|
185
|
-
showCurrencyOptions: prop_types_1.default.bool,
|
|
186
|
-
small: prop_types_1.default.bool,
|
|
187
|
-
type: prop_types_1.default.string,
|
|
188
|
-
wholeRef: prop_types_1.default.object
|
|
189
|
-
}),
|
|
190
|
-
_a)));
|
|
122
|
+
else {
|
|
123
|
+
inputElement.value = '';
|
|
124
|
+
}
|
|
125
|
+
if (this.props.onChange && oldCents != cents)
|
|
126
|
+
this.props.onChange();
|
|
127
|
+
};
|
|
128
|
+
}));
|
|
191
129
|
//# sourceMappingURL=money.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"money.js","sourceRoot":"/src/","sources":["inputs/money.jsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"money.js","sourceRoot":"/src/","sources":["inputs/money.jsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,EAAC,MAAM,EAAC,MAAM,OAAO,CAAA;AACnC,OAAO,EAAC,cAAc,EAAE,cAAc,EAAC,MAAM,4CAA4C,CAAA;AACzF,OAAO,UAAU,MAAM,YAAY,CAAA;AACnC,OAAO,MAAM,MAAM,cAAc,CAAA;AACjC,OAAO,EAAC,IAAI,EAAC,MAAM,WAAW,CAAA;AAC9B,OAAO,cAA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G,GAAG,EAAE,EAAE,CAAC,CAAA;QACrC,IAAI,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,KAAK,EAAE,EAAE,CAAC,CAAA;QAE/C,IAAI,OAAO,KAAK,IAAI,QAAQ,EAAE,CAAC;YAC7B,YAAY,CAAC,KAAK,GAAG,KAAK,CAAA;QAC5B,CAAC;aAAM,CAAC;YACN,YAAY,CAAC,KAAK,GAAG,EAAE,CAAA;QACzB,CAAC;QAED,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,IAAI,QAAQ,IAAI,KAAK;YAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAA;IACrE,CAAC,CAAA;CACF,CAAC,CAAC,CAAA"}
|
|
@@ -1,50 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.default = apiMakerNameForComponent;
|
|
37
|
-
var inflection = __importStar(require("inflection"));
|
|
38
|
-
function apiMakerNameForComponent(component) {
|
|
1
|
+
import * as inflection from "inflection";
|
|
2
|
+
export default function apiMakerNameForComponent(component) {
|
|
39
3
|
if ("name" in component.props) {
|
|
40
4
|
return component.props.name;
|
|
41
5
|
}
|
|
42
6
|
else if (component.props.attribute && component.props.model) {
|
|
43
|
-
|
|
7
|
+
let attributeName = inflection.underscore(component.props.attribute);
|
|
44
8
|
if (component.props.type == "money") {
|
|
45
9
|
attributeName += "_cents";
|
|
46
10
|
}
|
|
47
|
-
return
|
|
11
|
+
return `${component.props.model.modelClassData().paramKey}[${attributeName}]`;
|
|
48
12
|
}
|
|
49
13
|
}
|
|
50
14
|
//# sourceMappingURL=name-for-component.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"name-for-component.js","sourceRoot":"/src/","sources":["inputs/name-for-component.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"name-for-component.js","sourceRoot":"/src/","sources":["inputs/name-for-component.js"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,YAAY,CAAA;AAExC,MAAM,CAAC,OAAO,UAAU,wBAAwB,CAAE,SAAS;IACzD,IAAI,MAAM,IAAI,SAAS,CAAC,KAAK,EAAE,CAAC;QAC9B,OAAO,SAAS,CAAC,KAAK,CAAC,IAAI,CAAA;IAC7B,CAAC;SAAM,IAAI,SAAS,CAAC,KAAK,CAAC,SAAS,IAAI,SAAS,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;QAC9D,IAAI,aAAa,GAAG,UAAU,CAAC,UAAU,CAAC,SAAS,CAAC,KAAK,CAAC,SAAS,CAAC,CAAA;QAEpE,IAAI,SAAS,CAAC,KAAK,CAAC,IAAI,IAAI,OAAO,EAAE,CAAC;YACpC,aAAa,IAAI,QAAQ,CAAA;QAC3B,CAAC;QAED,OAAO,GAAG,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,cAAc,EAAE,CAAC,QAAQ,IAAI,aAAa,GAAG,CAAA;IAC/E,CAAC;AACH,CAAC"}
|
package/build/inputs/select.js
CHANGED
|
@@ -1,128 +1,74 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import BaseComponent from "../base-component.js";
|
|
3
|
+
import inputWrapper from "./input-wrapper";
|
|
4
|
+
import memo from "set-state-compare/build/memo.js";
|
|
5
|
+
import PropTypes from "prop-types";
|
|
6
|
+
import React from "react";
|
|
7
|
+
import { shapeComponent } from "set-state-compare/build/shape-component.js";
|
|
8
|
+
import { useForm } from "../form";
|
|
9
|
+
const ApiMakerInputsSelect = memo(shapeComponent(class ApiMakerInputsSelect extends BaseComponent {
|
|
10
|
+
static propTypes = {
|
|
11
|
+
attribute: PropTypes.string,
|
|
12
|
+
children: PropTypes.any,
|
|
13
|
+
defaultValue: PropTypes.oneOfType([PropTypes.array, PropTypes.number, PropTypes.string]),
|
|
14
|
+
id: PropTypes.string,
|
|
15
|
+
includeBlank: PropTypes.oneOfType([PropTypes.bool, PropTypes.any]),
|
|
16
|
+
inputProps: PropTypes.object.isRequired,
|
|
17
|
+
model: PropTypes.object,
|
|
18
|
+
name: PropTypes.string,
|
|
19
|
+
onChange: PropTypes.func,
|
|
20
|
+
options: PropTypes.array,
|
|
21
|
+
wrapperOpts: PropTypes.object.isRequired
|
|
8
22
|
};
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
23
|
+
setup() {
|
|
24
|
+
this.form = useForm();
|
|
25
|
+
}
|
|
26
|
+
render() {
|
|
27
|
+
const { attribute, children, defaultValue, id, includeBlank, inputProps, inputRef, model, name, onChange, options, wrapperOpts, ...restProps } = this.props;
|
|
28
|
+
return (_jsxs("select", { onChange: this.tt.onChange, ...inputProps, ...restProps, children: [this.includeBlank() &&
|
|
29
|
+
_jsx("option", { "data-include-blank": "true", children: typeof includeBlank != "boolean" ? includeBlank : null }), options && options.map((option) => _jsx("option", { value: this.optionValue(option), children: this.optionLabel(option) }, this.optionKey(option))), children] }));
|
|
30
|
+
}
|
|
31
|
+
onChange = (e) => {
|
|
32
|
+
const { form } = this.tt;
|
|
33
|
+
const { name, onChange } = this.props;
|
|
34
|
+
if (form && name)
|
|
35
|
+
form.setValue(name, e.target.value);
|
|
36
|
+
if (onChange)
|
|
37
|
+
onChange(e);
|
|
15
38
|
};
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
-
s = arguments[i];
|
|
21
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
-
t[p] = s[p];
|
|
39
|
+
optionKey(option) {
|
|
40
|
+
if (Array.isArray(option)) {
|
|
41
|
+
return `select-option-${option[1]}`;
|
|
23
42
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
43
|
+
else {
|
|
44
|
+
return `select-option-${option}`;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
optionLabel(option) {
|
|
48
|
+
if (Array.isArray(option)) {
|
|
49
|
+
return option[0];
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
return option;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
optionValue(option) {
|
|
56
|
+
if (Array.isArray(option)) {
|
|
57
|
+
return option[1];
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
return option;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
includeBlank() {
|
|
64
|
+
if (this.props.includeBlank && !this.props.multiple) {
|
|
65
|
+
return true;
|
|
36
66
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
40
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
41
|
-
};
|
|
42
|
-
var _a;
|
|
43
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
|
-
exports.Select = void 0;
|
|
45
|
-
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
46
|
-
var base_component_js_1 = __importDefault(require("../base-component.js"));
|
|
47
|
-
var input_wrapper_1 = __importDefault(require("./input-wrapper"));
|
|
48
|
-
var memo_js_1 = __importDefault(require("set-state-compare/build/memo.js"));
|
|
49
|
-
var prop_types_1 = __importDefault(require("prop-types"));
|
|
50
|
-
var react_1 = __importDefault(require("react"));
|
|
51
|
-
var shape_component_js_1 = require("set-state-compare/build/shape-component.js");
|
|
52
|
-
var form_1 = require("../form");
|
|
53
|
-
var ApiMakerInputsSelect = (0, memo_js_1.default)((0, shape_component_js_1.shapeComponent)((_a = /** @class */ (function (_super) {
|
|
54
|
-
__extends(ApiMakerInputsSelect, _super);
|
|
55
|
-
function ApiMakerInputsSelect() {
|
|
56
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
57
|
-
_this.onChange = function (e) {
|
|
58
|
-
var form = _this.tt.form;
|
|
59
|
-
var _b = _this.props, name = _b.name, onChange = _b.onChange;
|
|
60
|
-
if (form && name)
|
|
61
|
-
form.setValue(name, e.target.value);
|
|
62
|
-
if (onChange)
|
|
63
|
-
onChange(e);
|
|
64
|
-
};
|
|
65
|
-
return _this;
|
|
67
|
+
else {
|
|
68
|
+
return false;
|
|
66
69
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
var _this = this;
|
|
72
|
-
var _b = this.props, attribute = _b.attribute, children = _b.children, defaultValue = _b.defaultValue, id = _b.id, includeBlank = _b.includeBlank, inputProps = _b.inputProps, inputRef = _b.inputRef, model = _b.model, name = _b.name, onChange = _b.onChange, options = _b.options, wrapperOpts = _b.wrapperOpts, restProps = __rest(_b, ["attribute", "children", "defaultValue", "id", "includeBlank", "inputProps", "inputRef", "model", "name", "onChange", "options", "wrapperOpts"]);
|
|
73
|
-
return ((0, jsx_runtime_1.jsxs)("select", __assign({ onChange: this.tt.onChange }, inputProps, restProps, { children: [this.includeBlank() &&
|
|
74
|
-
(0, jsx_runtime_1.jsx)("option", { "data-include-blank": "true", children: typeof includeBlank != "boolean" ? includeBlank : null }), options && options.map(function (option) {
|
|
75
|
-
return (0, jsx_runtime_1.jsx)("option", { value: _this.optionValue(option), children: _this.optionLabel(option) }, _this.optionKey(option));
|
|
76
|
-
}), children] })));
|
|
77
|
-
};
|
|
78
|
-
ApiMakerInputsSelect.prototype.optionKey = function (option) {
|
|
79
|
-
if (Array.isArray(option)) {
|
|
80
|
-
return "select-option-".concat(option[1]);
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
return "select-option-".concat(option);
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
ApiMakerInputsSelect.prototype.optionLabel = function (option) {
|
|
87
|
-
if (Array.isArray(option)) {
|
|
88
|
-
return option[0];
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
return option;
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
ApiMakerInputsSelect.prototype.optionValue = function (option) {
|
|
95
|
-
if (Array.isArray(option)) {
|
|
96
|
-
return option[1];
|
|
97
|
-
}
|
|
98
|
-
else {
|
|
99
|
-
return option;
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
ApiMakerInputsSelect.prototype.includeBlank = function () {
|
|
103
|
-
if (this.props.includeBlank && !this.props.multiple) {
|
|
104
|
-
return true;
|
|
105
|
-
}
|
|
106
|
-
else {
|
|
107
|
-
return false;
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
return ApiMakerInputsSelect;
|
|
111
|
-
}(base_component_js_1.default)),
|
|
112
|
-
_a.propTypes = {
|
|
113
|
-
attribute: prop_types_1.default.string,
|
|
114
|
-
children: prop_types_1.default.any,
|
|
115
|
-
defaultValue: prop_types_1.default.oneOfType([prop_types_1.default.array, prop_types_1.default.number, prop_types_1.default.string]),
|
|
116
|
-
id: prop_types_1.default.string,
|
|
117
|
-
includeBlank: prop_types_1.default.oneOfType([prop_types_1.default.bool, prop_types_1.default.any]),
|
|
118
|
-
inputProps: prop_types_1.default.object.isRequired,
|
|
119
|
-
model: prop_types_1.default.object,
|
|
120
|
-
name: prop_types_1.default.string,
|
|
121
|
-
onChange: prop_types_1.default.func,
|
|
122
|
-
options: prop_types_1.default.array,
|
|
123
|
-
wrapperOpts: prop_types_1.default.object.isRequired
|
|
124
|
-
},
|
|
125
|
-
_a)));
|
|
126
|
-
exports.Select = ApiMakerInputsSelect;
|
|
127
|
-
exports.default = (0, input_wrapper_1.default)(ApiMakerInputsSelect);
|
|
70
|
+
}
|
|
71
|
+
}));
|
|
72
|
+
export { ApiMakerInputsSelect as Select };
|
|
73
|
+
export default inputWrapper(ApiMakerInputsSelect);
|
|
128
74
|
//# sourceMappingURL=select.js.map
|